Math
Functions
RotationF
AddRotation(RotationF a, RotationF b)
Adds two rotations together.
Point3F
getBoxCenter(Box3F box)
Get the center point of an axis-aligned box.
float
getMax(float v1, float v2)
Calculate the greater of two specified numbers.
float
getMin(float v1, float v2)
Calculate the lesser of two specified numbers.
Point3F
getRotationDirection(RotationF rot)
Gets the direction from the rotation's angles.
VectorF
getRotationForwardVector(RotationF rot)
Get the forward vector of a rotation.
VectorF
getRotationRightVector(RotationF rot)
Gets the right vector of a rotation.
VectorF
getRotationUpVector(RotationF rot)
Gets the up vector of a rotation.
RotationF
InterpolateRotation(RotationF a, RotationF b, float factor)
Interpolates between two rotations.
float
m2Pi()
Return the value of 2*PI (full-circle in radians).
float
mAbs(float v)
Calculate absolute value of specified value.
float
mAcos(float v)
Calculate the arc-cosine of v.
float
mAsin(float v)
Calculate the arc-sine of v.
float
mAtan(float rise, float run)
Calculate the arc-tangent (slope) of a line defined by rise and run.
void
mathInit(... )
Install the math library with specified extensions.
int
mCeil(float v)
Round v up to the nearest integer.
float
mClamp(float v, float min, float max)
Clamp the specified value between two bounds.
float
mCos(float v)
Calculate the cosine of v.
float
mDegToRad(float degrees)
Convert specified degrees into radians.
string
mFloatLength(float v, uint precision)
Formats the specified number to the given number of decimal places.
int
mFloor(float v)
Round v down to the nearest integer.
float
mFMod(float v, float d)
Calculate the remainder of v/d.
float
mGetAngleBetweenVectors(VectorF vecA, VectorF vecB)
Returns angle between two vectors.
float
mGetSignedAngleBetweenVectors(VectorF vecA, VectorF vecB, VectorF norm)
Returns signed angle between two vectors, using a normal for orientation.
bool
mIsPow2(int v)
Returns whether the value is an exact power of two.
float
mLerp(float v1, float v2, float time)
Calculate linearly interpolated value between two specified numbers using specified normalized time.
float
mLog(float v)
Calculate the natural logarithm of v.
float
mPi()
Return the value of PI (half-circle in radians).
float
mPow(float v, float p)
Calculate b raised to the p-th power.
float
mRadToDeg(float radians)
Convert specified radians into degrees.
Point3F
mRandomDir(Point3F axis, float angleMin, float angleMax)
Returns a randomized direction based on a starting axis and the min/max angles.
Point3F
mRandomPointInSphere(float radius)
Returns a randomized point inside a sphere of a given radius.
float
mSaturate(float v)
Clamp the specified value between 0 and 1 (inclusive).
float
mSin(float v)
Calculate the sine of v.
string
mSolveCubic(float a, float b, float c, float d)
Solve a cubic equation (3rd degree polynomial) of form a*x^3 + b*x^2 + c*x + d = 0.
string
mSolveQuadratic(float a, float b, float c)
Solve a quadratic equation (2nd degree polynomial) of form a*x^2 + b*x + c = 0.
string
mSolveQuartic(float a, float b, float c, float d, float e)
Solve a quartic equation (4th degree polynomial) of form a*x^4 + b*x^3 + c*x^2 + d*x + e = 0.
float
mSqrt(float v)
Calculate the square-root of v.
float
mTan(float v)
Calculate the tangent of v.
int
mWrap(int v, int min, int max)
Wrap the specified value between two bounds.
float
mWrapF(float v, float min, float max)
Wrap the specified value between two bounds.
RotationF
RotationLookAt(Point3F origin, Point3F target, Point3F up)
Provides a rotation orientation to look at a target from a given position.
RotationF
setRotationRightVector(RotationF rot, VectorF rightVec)
Sets the right vector of the rotation.
RotationF
setRotationUpVector(RotationF rot, VectorF upVec)
Sets the up vector of the rotation.
RotationF
SubtractRotation(RotationF a, RotationF b)
Subtracts two rotations.
Detailed Description
Functions
AddRotation(RotationF a, RotationF b)
Adds two rotations together.
Parameters:
a | Rotation one. |
b | Rotation two. |
v sum of both rotations.
getBoxCenter(Box3F box)
Get the center point of an axis-aligned box.
Parameters:
b | A Box3F, in string format using "minExtentX minExtentY minExtentZ maxExtentX maxExtentY maxExtentZ" |
Center of the box.
getMax(float v1, float v2)
Calculate the greater of two specified numbers.
Parameters:
v1 | Input value. |
v2 | Input value. |
The greater value of the two specified values.
getMin(float v1, float v2)
Calculate the lesser of two specified numbers.
Parameters:
v1 | Input value. |
v2 | Input value. |
The lesser value of the two specified values.
getRotationDirection(RotationF rot)
Gets the direction from the rotation's angles.
Parameters:
Our | rotation. |
getRotationForwardVector(RotationF rot)
Get the forward vector of a rotation.
getRotationRightVector(RotationF rot)
Gets the right vector of a rotation.
Parameters:
Our | rotation. |
getRotationUpVector(RotationF rot)
Gets the up vector of a rotation.
Parameters:
Our | rotation. |
InterpolateRotation(RotationF a, RotationF b, float factor)
Interpolates between two rotations.
Parameters:
a | Rotation one. |
b | Rotation two. |
factor | The amount to interpolate between the two. |
v, interpolated result.
m2Pi()
Return the value of 2*PI (full-circle in radians).
The value of 2*PI.
mAbs(float v)
Calculate absolute value of specified value.
Parameters:
v | Input Value. |
Absolute value of specified value.
mAcos(float v)
Calculate the arc-cosine of v.
Parameters:
v | Input Value (in radians). |
The arc-cosine of the input value.
mAsin(float v)
Calculate the arc-sine of v.
Parameters:
v | Input Value (in radians). |
The arc-sine of the input value.
mAtan(float rise, float run)
Calculate the arc-tangent (slope) of a line defined by rise and run.
Parameters:
rise | of line. |
run | of line. |
The arc-tangent (slope) of a line defined by rise and run.
mathInit(... )
Install the math library with specified extensions.
Possible parameters are:
- 'DETECT' Autodetect math lib settings. - 'C' Enable the C math routines. C routines are always enabled. - 'SSE' Enable SSE math routines.
mCeil(float v)
Round v up to the nearest integer.
Parameters:
v | Number to convert to integer. |
Number converted to integer.
mClamp(float v, float min, float max)
Clamp the specified value between two bounds.
Parameters:
v | Input value. |
min | Minimum Bound. |
max | Maximum Bound. |
The specified value clamped to the specified bounds.
mCos(float v)
Calculate the cosine of v.
Parameters:
v | Input Value (in radians). |
The cosine of the input value.
mDegToRad(float degrees)
Convert specified degrees into radians.
Parameters:
degrees | Input Value (in degrees). |
The specified degrees value converted to radians.
mFloatLength(float v, uint precision)
Formats the specified number to the given number of decimal places.
Parameters:
v | Number to format. |
precision | Number of decimal places to format to (1-9). |
Number formatted to the specified number of decimal places.
mFloor(float v)
Round v down to the nearest integer.
Parameters:
v | Number to convert to integer. |
Number converted to integer.
mFMod(float v, float d)
Calculate the remainder of v/d.
Parameters:
v | Input Value. |
d | Divisor Value. |
The remainder of v/d.
mGetAngleBetweenVectors(VectorF vecA, VectorF vecB)
Returns angle between two vectors.
Parameters:
vecA | First input vector. |
vecB | Second input vector. |
Angle between both vectors in radians.
mGetSignedAngleBetweenVectors(VectorF vecA, VectorF vecB, VectorF norm)
Returns signed angle between two vectors, using a normal for orientation.
Parameters:
vecA | First input vector. |
vecB | Second input vector. |
norm | Normal/Cross Product vector. |
Angle between both vectors in radians.
mIsPow2(int v)
Returns whether the value is an exact power of two.
Parameters:
v | Input value. |
Whether the specified value is an exact power of two.
mLerp(float v1, float v2, float time)
Calculate linearly interpolated value between two specified numbers using specified normalized time.
Parameters:
v1 | Interpolate From Input value. |
v2 | Interpolate To Input value. |
time | Normalized time used to interpolate values (0-1). |
The interpolated value between the two specified values at normalized time t.
mLog(float v)
Calculate the natural logarithm of v.
Parameters:
v | Input Value. |
The natural logarithm of the input value.
mPi()
Return the value of PI (half-circle in radians).
The value of PI.
mPow(float v, float p)
Calculate b raised to the p-th power.
Parameters:
v | Input Value. |
p | Power to raise value by. |
v raised to the p-th power.
mRadToDeg(float radians)
Convert specified radians into degrees.
Parameters:
radians | Input Value (in radians). |
The specified radians value converted to degrees.
mRandomDir(Point3F axis, float angleMin, float angleMax)
Returns a randomized direction based on a starting axis and the min/max angles.
Parameters:
axis | Main axis to deviate the direction from. |
angleMin | minimum amount of deviation from the axis. |
angleMax | maximum amount of deviation from the axis. |
Randomized direction vector.
mRandomPointInSphere(float radius)
Returns a randomized point inside a sphere of a given radius.
Parameters:
radius | The radius of the sphere to find a point in. |
Randomized point inside a sphere.
mSaturate(float v)
Clamp the specified value between 0 and 1 (inclusive).
Parameters:
v | Input value. |
The specified value clamped between 0 and 1 (inclusive).
mSin(float v)
Calculate the sine of v.
Parameters:
v | Input Value (in radians). |
The sine of the input value.
mSolveCubic(float a, float b, float c, float d)
Solve a cubic equation (3rd degree polynomial) of form a*x^3 + b*x^2 + c*x + d = 0.
Parameters:
a | First Coefficient. |
b | Second Coefficient. |
c | Third Coefficient. |
d | Fourth Coefficient. |
A 4-tuple, containing: (sol x0 x1 x2). (sol) is the number of solutions(being 0, 1, 2 or 3), and (x0), (x1) and (x2) are the solutions, if any.
mSolveQuadratic(float a, float b, float c)
Solve a quadratic equation (2nd degree polynomial) of form a*x^2 + b*x + c = 0.
Parameters:
a | First Coefficient. |
b | Second Coefficient. |
c | Third Coefficient. |
A triple, containing: (sol x0 x1). (sol) is the number of solutions(being 0, 1, or 2), and (x0) and (x1) are the solutions, if any.
mSolveQuartic(float a, float b, float c, float d, float e)
Solve a quartic equation (4th degree polynomial) of form a*x^4 + b*x^3 + c*x^2 + d*x + e = 0.
Parameters:
a | First Coefficient. |
b | Second Coefficient. |
c | Third Coefficient. |
d | Fourth Coefficient. |
e | Fifth Coefficient. |
A 5-tuple, containing: (sol x0 x1 x2 c3). (sol) is the number of solutions(being 0, 1, 2, 3 or 4), and (x0), (x1), (x2) and (x3) are the solutions, if any.
mSqrt(float v)
Calculate the square-root of v.
Parameters:
v | Input Value. |
The square-root of the input value.
mTan(float v)
Calculate the tangent of v.
Parameters:
v | Input Value (in radians). |
The tangent of the input value.
mWrap(int v, int min, int max)
Wrap the specified value between two bounds.
Parameters:
v | Input value. |
min | Minimum Bound. |
max | Maximum Bound. |
The specified value wrapped to the specified bounds.
mWrapF(float v, float min, float max)
Wrap the specified value between two bounds.
Parameters:
v | Input value. |
min | Minimum Bound. |
max | Maximum Bound. |
The specified value wrapped to the specified bounds.
RotationLookAt(Point3F origin, Point3F target, Point3F up)
Provides a rotation orientation to look at a target from a given position.
Parameters:
origin | Position of the object doing the looking. |
target | Position to be looked at. |
up | The up angle to orient the rotation. |
v orientation result.
setRotationRightVector(RotationF rot, VectorF rightVec)
Sets the right vector of the rotation.
Parameters:
Starting | rotation. |
New | up vector. |
New rotation with the set right vector.
setRotationUpVector(RotationF rot, VectorF upVec)
Sets the up vector of the rotation.
Parameters:
Starting | rotation. |
New | up vector. |
New rotation with the set up vector.
SubtractRotation(RotationF a, RotationF b)
Subtracts two rotations.
Parameters:
a | Rotation one. |
b | Rotation two. |
v difference of both rotations.