CMath

Math functions

Type: Reference type

Methods

Declaration Description
int32 RandomLong(int32 low, int32 high) Returns a random integer between low and high
float RandomFloat(float low, float high) Returns a random float between low and high
void MakeVectors(const Vector& in vecAngles) Makes vectors
Vector RotateVector(Vector& in vecToRotate,const Vector& in vecAngles, const Vector& in vecOffset) Rotate vector
void MakeAimVectors(const Vector& in vecAngles) Make aim vectors
void MakeInvVectors(const Vector& in vecAngles) Make inverted vectors
float VecToYaw(const Vector& in vec) Transforms a vector to a yaw value
Vector VecToAngles(const Vector& in vec) Transforms a vector to an angle
float AngleMod(float flAngle) Clamps the given angle between 0 and 360
float AngleDiff(float flDestAngle, float flSrcAngle) Returns the difference between 2 angles
float ApproachAngle(float target, float value, float speed) Given a target and current angle value, and a rotation speed, all in degrees, returns a new angle that is either between value and target, or target, depending on whether the speed is high enough to reach that angle.
float AngleDistance(float flNext, float flCur) Returns the distance between 2 angles
uint64 min(uint64 lhs, uint64 rhs) const Returns the smaller of the two values
int64 min(int64 lhs, int64 rhs) const Returns the smaller of the two values
float min(float lhs, float rhs) const Returns the smaller of the two values
uint64 max(uint64 lhs, uint64 rhs) const Returns the larger of the two values
int64 max(int64 lhs, int64 rhs) const Returns the larger of the two values
float max(float lhs, float rhs) const Returns the larger of the two values
int clamp(int min, int max, int value) const Clamps a value between a range
float clamp(float min, float max, float value) const Clamps a value between a range
float Floor(float flValue) const Returns the float value, rounded down to the nearest whole number
float Ceil(float flValue) const Returns the float value, rounded up to the nearest whole number
float DegreesToRadians(float flDegrees) const Returns the given value in degrees as radians
float RadiansToDegrees(float flRadians) const Returns the given value in radians as degrees
bool Compare(float flLhs, float flRhs, float flEpsilon) const Compares the given floating point variables and returns whether they are equal, considering certain variance (epsilon) between them.
bool Compare(double flLhs, double flRhs, double flEpsilon) const Compares the given floating point variables and returns whether they are equal, considering certain variance (epsilon) between them.

Properties

Declaration Description
const int8 INT8_MIN Int8 minimum value
const int16 INT16_MIN Int16 minimum value
const int32 INT32_MIN Int32 minimum value
const int64 INT64_MIN Int64 minimum value
const int8 INT8_MAX Int8 maximum value
const int16 INT16_MAX Int16 maximum value
const int32 INT32_MAX Int32 maximum value
const int64 INT64_MAX Int64 maximum value
const uint8 UINT8_MAX Uint8 maximum value
const uint16 UINT16_MAX Uint16 maximum value
const uint32 UINT32_MAX Uint32 maximum value
const uint64 UINT64_MAX Uint64 maximum value
const size_t SIZE_MAX Size_t maximum value
const float FLOAT_MIN Float minimum positive value
const double DOUBLE_MIN Double minimum positive value
const float FLOAT_MAX Float maximum positive value
const double DOUBLE_MAX Double maximum positive value
const double PI PI