libRocket
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Functions | Variables
Rocket::Core::Math Namespace Reference

Functions

template<typename Type >
Type Max (Type a, Type b)
 
template<typename Type >
Type Min (Type a, Type b)
 
template<typename Type >
Type ClampLower (Type value, Type min)
 
template<typename Type >
Type ClampUpper (Type value, Type max)
 
template<typename Type >
Type Clamp (Type value, Type min, Type max)
 
ROCKETCORE_API bool IsZero (float value)
 
ROCKETCORE_API bool AreEqual (float value_0, float value_1)
 
ROCKETCORE_API float AbsoluteValue (float value)
 
ROCKETCORE_API float Cos (float angle)
 
ROCKETCORE_API float ACos (float value)
 
ROCKETCORE_API float Sin (float angle)
 
ROCKETCORE_API float ASin (float angle)
 
ROCKETCORE_API float Tan (float angle)
 
ROCKETCORE_API float ATan2 (float y, float x)
 
ROCKETCORE_API float RadiansToDegrees (float angle)
 
ROCKETCORE_API float DegreesToRadians (float angle)
 
ROCKETCORE_API float NormaliseAngle (float angle)
 
ROCKETCORE_API float SquareRoot (float value)
 
ROCKETCORE_API int Round (float value)
 
ROCKETCORE_API int RoundUp (float value)
 
ROCKETCORE_API int RoundDown (float value)
 
ROCKETCORE_API int RealToInteger (float value)
 
ROCKETCORE_API int ToPowerOfTwo (int value)
 
ROCKETCORE_API int HexToDecimal (char hex_digit)
 
ROCKETCORE_API float RandomReal (float max_value)
 
ROCKETCORE_API int RandomInteger (int max_value)
 
ROCKETCORE_API bool RandomBool ()
 

Variables

ROCKETCORE_API const float ROCKET_PI
 

Function Documentation

ROCKETCORE_API float Rocket::Core::Math::AbsoluteValue ( float  value)

Calculates the absolute value of a number.

Parameters
[in]valueThe number of get the absolute value of.
Returns
The absolute value of the number.
ROCKETCORE_API float Rocket::Core::Math::ACos ( float  value)

Calculates the arc-cosine of an value.

Parameters
[in]angleThe value to calculate the arc-cosine of.
Returns
The angle, in radians.
ROCKETCORE_API bool Rocket::Core::Math::AreEqual ( float  value_0,
float  value_1 
)

Evaluates if two floating-point numbers are equal, or so similar that they could be considered so.

Parameters
[in]value_0The first number to compare.
[in]value_1The second number to compare.
Returns
True if the numbers are similar or equal.
ROCKETCORE_API float Rocket::Core::Math::ASin ( float  angle)

Calculates the arc-sine of an value.

Parameters
[in]angleThe value to calculate the arc-sine of.
Returns
The angle, in radians.
ROCKETCORE_API float Rocket::Core::Math::ATan2 ( float  y,
float  x 
)

Calculates the angle of a two-dimensional line.

Parameters
[in]yThe y-component of the line.
[in]xThe x-component of the line.
Returns
The angle of the line in radians.
template<typename Type >
Type Rocket::Core::Math::Clamp ( Type  value,
Type  min,
Type  max 
)
template<typename Type >
Type Rocket::Core::Math::ClampLower ( Type  value,
Type  min 
)
template<typename Type >
Type Rocket::Core::Math::ClampUpper ( Type  value,
Type  max 
)
ROCKETCORE_API float Rocket::Core::Math::Cos ( float  angle)

Calculates the cosine of an angle.

Parameters
[in]angleThe angle to calculate the cosine of, in radians.
Returns
The cosine of the angle.
ROCKETCORE_API float Rocket::Core::Math::DegreesToRadians ( float  angle)

Converts an angle from degrees to radians.

Parameters
[in]Theangle, in degrees.
Returns
The angle converted to radians.
ROCKETCORE_API int Rocket::Core::Math::HexToDecimal ( char  hex_digit)

Converts from the ASCII-representation of a hexadecimal digit to decimal.

Parameters
[in]hex_digitThe hexadecimal digit to convert to decimal.
Returns
The digit in decimal.
ROCKETCORE_API bool Rocket::Core::Math::IsZero ( float  value)

Evaluates if a number is, or close to, zero.

Parameters
[in]valueThe number to compare to zero.
Returns
True if the number if zero or close to it, false otherwise.
template<typename Type >
Type Rocket::Core::Math::Max ( Type  a,
Type  b 
)
template<typename Type >
Type Rocket::Core::Math::Min ( Type  a,
Type  b 
)
ROCKETCORE_API float Rocket::Core::Math::NormaliseAngle ( float  angle)

Normalises and angle in radians

Parameters
[in]Theangle, in randians
Returns
The normalised angle
ROCKETCORE_API float Rocket::Core::Math::RadiansToDegrees ( float  angle)

Converts an angle from radians to degrees.

Parameters
[in]Theangle, in radians.
Returns
The angle converted to degrees.
ROCKETCORE_API bool Rocket::Core::Math::RandomBool ( )

Generates a random boolean value, with equal chance of true or false.

Returns
The random value.
ROCKETCORE_API int Rocket::Core::Math::RandomInteger ( int  max_value)

Generates a random integer value between 0 and a user-specified value.

Parameters
[in]max_valueThe limit to random value. The generated value will be guaranteed to be below this limit.
Returns
The random value.
ROCKETCORE_API float Rocket::Core::Math::RandomReal ( float  max_value)

Generates a random floating-point value between 0 and a user-specified value.

Parameters
[in]max_valueThe limit to random value. The generated value will be guaranteed to be below this limit.
Returns
The random value.
ROCKETCORE_API int Rocket::Core::Math::RealToInteger ( float  value)

Efficiently truncates a floating-point value into an integer.

Parameters
[in]valueThe value to truncate.
Returns
The truncated value as a signed integer.
ROCKETCORE_API int Rocket::Core::Math::Round ( float  value)

Rounds a floating-point value to the nearest integer.

Parameters
[in]valueThe value to round.
Returns
The rounded integer.
ROCKETCORE_API int Rocket::Core::Math::RoundDown ( float  value)

Rounds a floating-point value down to the nearest integer.

Parameters
[in]valueThe value to round.
Returns
The rounded integer.
ROCKETCORE_API int Rocket::Core::Math::RoundUp ( float  value)

Rounds a floating-point value up to the nearest integer.

Parameters
[in]valueThe value to round.
Returns
The rounded integer.
ROCKETCORE_API float Rocket::Core::Math::Sin ( float  angle)

Calculates the sine of an angle.

Parameters
[in]angleThe angle to calculate the sine of, in radians.
Returns
The sine of the angle.
ROCKETCORE_API float Rocket::Core::Math::SquareRoot ( float  value)

Calculates the square root of a value.

Parameters
[in]valueThe value to calculate the square root of. This must be above zero.
Returns
The square root of the value.
ROCKETCORE_API float Rocket::Core::Math::Tan ( float  angle)

Calculates the tangent of an angle.

Parameters
[in]angleThe angle to calculate the tangent of, in radians.
Returns
The tanget of the angle.
ROCKETCORE_API int Rocket::Core::Math::ToPowerOfTwo ( int  value)

Converts a number to the nearest power of two, rounding up if necessary.

Parameters
[in]valueThe value to convert to a power-of-two.
Returns
The smallest power of two that is as least as big as the input value.

Variable Documentation

ROCKETCORE_API const float Rocket::Core::Math::ROCKET_PI