CryEngine.MathHelpers

Static Public Member Functions

static bool Approximately (float lhs, float rhs)
Returns true if absolute difference between lhs and rhs is less than or equal to Epsilon More...
static bool Approximately (float lhs, float rhs, float precision)
Returns true if absolute difference between lhs and rhs is less than or equal to precision More...
static float Clamp (float value, float min, float max)
Clamps specified float value between minimum float and maximum float and returns the clamped float value More...
static int Clamp (int value, int min, int max)
Clamps the specified integer value between minimum integer and maximum integer and returns the clamped integer value More...
static float Clamp01 (float value)
Clamps the specified value between 0.0 and 1.0. More...
static float DegreesToRadians (float degrees)
Convert degrees to radians. More...
static float RadiansToDegrees (float rad)
Convert Radians to degrees. More...
static bool IsInRange< T > (T value, T min, T max)
Determines whether a value is inside the specified range. More...
static T Clamp< T > (T value, T min, T max)
Clamps a value given a specified range. More...
static float ClampAngleDegrees (float angle, float min, float max)
Clamps the specified angle between minimum angle and maximum angle and returns the clamped value More...
static T Max< T > (T val1, T val2)
Returns the largest of the 2 specified values More...
static T Min< T > (T val1, T val2)
Returns the smallest of the 2 specified values More...
static bool IsPowerOfTwo (int value)
Returns true if the specified int value is a power of two More...
static float ISqrt (float d)
Returns the inversed square root of the specified value More...
static void SinCos (float angle, out float sin, out float cos)
Outputs the sine and cosine of specified angle in radians when called More...
static float Square (float value)
Returns the square of the specified value More...
static float LerpUnclamped (float a, float b, float t)
Returns the linearly interpolated value between a and b with no restriction to t More...
static float Lerp (float a, float b, float t)
Returns the clamped value a and b More...
static Vector3 Lerp (Vector3 a, Vector3 b, float t)
Returns the unclamped linearly interpolated vector between a and b More...
static float Repeat (float length, float t)
Keeps the value between 0 and length, but instead of clamping the value it will loop it. More...
static float PingPong (float length, float t)
Keeps the value between 0 and length, but instead of clamping the value it will move back and forth between 0 and length. More...

Static Public Attributes

static readonly float Epsilon = Debug.MathHelpers.EpsilonData.IsDeNormalizedFloatEnabled ? Debug.MathHelpers.EpsilonData.MagicNumber : Debug.MathHelpers.EpsilonData.FloatMinVal
The smallest number a float can be, without being zero. More...

Member Function Documentation

◆ Approximately() [1/2]

static bool CryEngine.MathHelpers.Approximately ( float lhs,
float rhs
)
inline
static

Returns true if absolute difference between lhs and rhs is less than or equal to Epsilon

Parameters
lhs
rhs
Returns

◆ Approximately() [2/2]

static bool CryEngine.MathHelpers.Approximately ( float lhs,
float rhs,
float precision
)
inline
static

Returns true if absolute difference between lhs and rhs is less than or equal to precision

Parameters
lhs
rhs
precision
Returns

◆ Clamp() [1/2]

static float CryEngine.MathHelpers.Clamp ( float value,
float min,
float max
)
inline
static

Clamps specified float value between minimum float and maximum float and returns the clamped float value

Parameters
value
min
max
Returns

◆ Clamp() [2/2]

static int CryEngine.MathHelpers.Clamp ( int value,
int min,
int max
)
inline
static

Clamps the specified integer value between minimum integer and maximum integer and returns the clamped integer value

Parameters
value
min
max
Returns

◆ Clamp01()

static float CryEngine.MathHelpers.Clamp01 ( float value)
inline
static

Clamps the specified value between 0.0 and 1.0.

Returns
The value clamped between 0.0 and 1.0.
Parameters
valueValue that needs to be clamped.

◆ Clamp< T >()

static T CryEngine.MathHelpers.Clamp< T > ( T value,
T min,
T max
)
inline
static

Clamps a value given a specified range.

Template Parameters
T
Parameters
value
min
max
Returns
Type Constraints
T :IComparable

◆ ClampAngleDegrees()

static float CryEngine.MathHelpers.ClampAngleDegrees ( float angle,
float min,
float max
)
inline
static

Clamps the specified angle between minimum angle and maximum angle and returns the clamped value

Parameters
angle
min
max
Returns

◆ DegreesToRadians()

static float CryEngine.MathHelpers.DegreesToRadians ( float degrees)
inline
static

Convert degrees to radians.

Returns
Angle in radians.
Parameters
degreesAngle in degrees.

◆ IsInRange< T >()

static bool CryEngine.MathHelpers.IsInRange< T > ( T value,
T min,
T max
)
inline
static

Determines whether a value is inside the specified range.

Template Parameters
T
Parameters
value
min
max
Returns
Type Constraints
T :IComparable

◆ IsPowerOfTwo()

static bool CryEngine.MathHelpers.IsPowerOfTwo ( int value)
inline
static

Returns true if the specified int value is a power of two

Parameters
value
Returns

◆ ISqrt()

static float CryEngine.MathHelpers.ISqrt ( float d)
inline
static

Returns the inversed square root of the specified value

Parameters
d
Returns

◆ Lerp() [1/2]

static float CryEngine.MathHelpers.Lerp ( float a,
float b,
float t
)
inline
static

Returns the clamped value a and b

Parameters
a
b
t
Returns

◆ Lerp() [2/2]

static Vector3 CryEngine.MathHelpers.Lerp ( Vector3 a,
Vector3 b,
float t
)
inline
static

Returns the unclamped linearly interpolated vector between a and b

Parameters
a
b
t
Returns

◆ LerpUnclamped()

static float CryEngine.MathHelpers.LerpUnclamped ( float a,
float b,
float t
)
inline
static

Returns the linearly interpolated value between a and b with no restriction to t

Parameters
a
b
t
Returns

◆ Max< T >()

static T CryEngine.MathHelpers.Max< T > ( T val1,
T val2
)
inline
static

Returns the largest of the 2 specified values

Template Parameters
T
Parameters
val1
val2
Returns
Type Constraints
T :IComparable

◆ Min< T >()

static T CryEngine.MathHelpers.Min< T > ( T val1,
T val2
)
inline
static

Returns the smallest of the 2 specified values

Template Parameters
T
Parameters
val1
val2
Returns
Type Constraints
T :IComparable

◆ PingPong()

static float CryEngine.MathHelpers.PingPong ( float length,
float t
)
inline
static

Keeps the value between 0 and length, but instead of clamping the value it will move back and forth between 0 and length.

Returns
The ping ponged value.
Parameters
tT.
lengthLength.

◆ RadiansToDegrees()

static float CryEngine.MathHelpers.RadiansToDegrees ( float rad)
inline
static

Convert Radians to degrees.

Returns
Angle in degrees.
Parameters
radAngle in radians.

◆ Repeat()

static float CryEngine.MathHelpers.Repeat ( float length,
float t
)
inline
static

Keeps the value between 0 and length, but instead of clamping the value it will loop it.

Returns
The repeated value.
Parameters
tT.
lengthLength.

◆ SinCos()

static void CryEngine.MathHelpers.SinCos ( float angle,
out float sin,
out float cos
)
inline
static

Outputs the sine and cosine of specified angle in radians when called

Parameters
angle
sin
cos

◆ Square()

static float CryEngine.MathHelpers.Square ( float value)
inline
static

Returns the square of the specified value

Parameters
value
Returns

Member Data Documentation

◆ Epsilon

readonly float CryEngine.MathHelpers.Epsilon = Debug.MathHelpers.EpsilonData.IsDeNormalizedFloatEnabled ? Debug.MathHelpers.EpsilonData.MagicNumber : Debug.MathHelpers.EpsilonData.FloatMinVal
static

The smallest number a float can be, without being zero.