Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
(NazaraMath) Mathematics module

Classes

class  Nz::BoundingVolume< T >
 Math class that represents a bounding volume, a combination of a box and an oriented box. More...
 
class  Nz::Box< T >
 Math class that represents a three dimensional box. More...
 
class  Nz::EulerAngles< T >
 Math class that represents an Euler angle. Those describe a rotation transformation by rotating an object on its various axes in specified amounts per axis, and a specified axis order. More...
 
class  Nz::Frustum< T >
 Math class that represents a frustum in the three dimensional vector space. More...
 
class  Nz::Matrix4< T >
 Math class that represents a transformation of the four dimensional vector space with the notion of projectivity. More...
 
class  Nz::OrientedBox< T >
 Math class that represents an oriented three dimensional box. More...
 
class  Nz::Plane< T >
 Math class that represents a plane in 3D. More...
 
class  Nz::Quaternion< T >
 Math class that represents an element of the quaternions. More...
 
class  Nz::Ray< T >
 Math class that represents a ray or a straight line in 3D space. More...
 
class  Nz::Rect< T >
 Math class that represents an axis-aligned rectangle in two dimensions. More...
 
class  Nz::Sphere< T >
 Math class that represents a sphere "S2" in a three dimensional euclidean space. More...
 
class  Nz::Vector2< T >
 Math class that represents an element of the two dimensional vector space. More...
 
class  Nz::Vector3< T >
 Math class that represents an element of the three dimensional vector space. More...
 
class  Nz::Vector4< T >
 Math class that represents an element of the three dimensional vector space with the notion of projectivity. When the fourth component is 1, it describes an 'usual' point and when it is 0, it represents the point at infinity. More...
 

Functions

template<typename T >
Nz::Approach (T value, T objective, T increment)
 Approaches the objective, beginning with value and with increment. More...
 
template<typename T >
constexpr T Nz::Clamp (T value, T min, T max)
 Clamps value between min and max and returns the expected value. More...
 
template<typename T >
std::size_t Nz::CountBits (T value)
 Gets number of bits set in the number. More...
 
template<typename T >
constexpr T Nz::DegreeToRadian (T degrees)
 Converts degree to radian. More...
 
template<typename T >
constexpr T Nz::FromDegrees (T degrees)
 Gets the unit from degree and convert it according to NAZARA_MATH_ANGLE_RADIAN. More...
 
template<typename T >
constexpr T Nz::FromRadians (T radians)
 Gets the unit from radian and convert it according to NAZARA_MATH_ANGLE_RADIAN. More...
 
template<typename T >
Nz::GetNearestPowerOfTwo (T number)
 Gets the nearest power of two for the number. More...
 
unsigned int Nz::GetNumberLength (signed char number)
 Gets the number of digits to represent the number in base 10. More...
 
unsigned int Nz::GetNumberLength (unsigned char number)
 Gets the number of digits to represent the number in base 10. More...
 
unsigned int Nz::GetNumberLength (int number)
 Gets the number of digits to represent the number in base 10. More...
 
unsigned int Nz::GetNumberLength (unsigned int number)
 Gets the number of digits to represent the number in base 10. More...
 
unsigned int Nz::GetNumberLength (long long number)
 Gets the number of digits to represent the number in base 10. More...
 
unsigned int Nz::GetNumberLength (unsigned long long number)
 Gets the number of digits to represent the number in base 10. More...
 
unsigned int Nz::GetNumberLength (float number, UInt8 precision)
 Gets the number of digits to represent the number in base 10. More...
 
unsigned int Nz::GetNumberLength (double number, UInt8 precision)
 Gets the number of digits to represent the number in base 10. More...
 
unsigned int Nz::GetNumberLength (long double number, UInt8 precision)
 Gets the number of digits to represent the number in base 10. More...
 
template<typename T >
unsigned int Nz::IntegralLog2 (T number)
 Gets the log in base 2 of integral number. More...
 
template<typename T >
unsigned int Nz::IntegralLog2Pot (T pot)
 Gets the log in base 2 of integral number, only works for power of two ! More...
 
template<typename T >
Nz::IntegralPow (T base, unsigned int exponent)
 Gets the power of integrals. More...
 
template<typename T , typename T2 >
constexpr T Nz::Lerp (const T &from, const T &to, const T2 &interpolation)
 Interpolates the value to other one with a factor of interpolation. More...
 
template<typename T >
constexpr T Nz::MultiplyAdd (T x, T y, T z)
 Multiplies X and Y, then add Z. More...
 
template<typename T >
Nz::NormalizeAngle (T angle)
 Normalizes the angle. More...
 
template<typename T >
bool Nz::NumberEquals (T a, T b)
 Checks whether two numbers are equal. More...
 
template<typename T >
bool Nz::NumberEquals (T a, T b, T maxDifference)
 Checks whether two numbers are equal. More...
 
String Nz::NumberToString (long long number, UInt8 radix)
 Converts the number to String. More...
 
template<typename T >
constexpr T Nz::RadianToDegree (T radians)
 Converts radian to degree. More...
 
long long Nz::StringToNumber (String str, UInt8 radix, bool *ok)
 Converts the string to number. More...
 
template<typename T >
constexpr T Nz::ToDegrees (T angle)
 Gets the degree from unit and convert it according to NAZARA_MATH_ANGLE_RADIAN. More...
 
template<typename T >
constexpr T Nz::ToRadians (T angle)
 Gets the radian from unit and convert it according to NAZARA_MATH_ANGLE_RADIAN. More...
 

Detailed Description

2D/3D mathematics module including matrix, vector, box, sphere, quaternion, ...

Function Documentation

◆ Approach()

template<typename T >
T Nz::Approach ( value,
objective,
increment 
)
inline

Approaches the objective, beginning with value and with increment.

Returns
The nearest value of the objective you can get with the value and the increment for one step
Parameters
valueInitial value
objectiveTarget value
incrementOne step value

◆ Clamp()

template<typename T >
constexpr T Nz::Clamp ( value,
min,
max 
)

Clamps value between min and max and returns the expected value.

Returns
If value is not in the interval of min..max, value obtained is the nearest limit of this interval
Parameters
valueValue to clamp
minMinimum of the interval
maxMaximum of the interval

◆ CountBits()

template<typename T >
std::size_t Nz::CountBits ( value)
inline

Gets number of bits set in the number.

Returns
The number of bits set to 1
Parameters
valueThe value to count bits

◆ DegreeToRadian()

template<typename T >
constexpr T Nz::DegreeToRadian ( degrees)

Converts degree to radian.

Returns
The representation in radian of the angle in degree (0..2*pi)
Parameters
degreesAngle in degree (this is expected between 0..360)

◆ FromDegrees()

template<typename T >
constexpr T Nz::FromDegrees ( degrees)

Gets the unit from degree and convert it according to NAZARA_MATH_ANGLE_RADIAN.

Returns
Express the degrees
Parameters
degreesConvert degree to NAZARA_MATH_ANGLE_RADIAN unit

◆ FromRadians()

template<typename T >
constexpr T Nz::FromRadians ( radians)

Gets the unit from radian and convert it according to NAZARA_MATH_ANGLE_RADIAN.

Returns
Express the radians
Parameters
radiansConvert radian to NAZARA_MATH_ANGLE_RADIAN unit

◆ GetNearestPowerOfTwo()

template<typename T >
T Nz::GetNearestPowerOfTwo ( number)
inline

Gets the nearest power of two for the number.

Returns
First power of two containing the number
Parameters
numberNumber to get nearest power

◆ GetNumberLength() [1/9]

unsigned int Nz::GetNumberLength ( signed char  number)
inline

Gets the number of digits to represent the number in base 10.

Returns
Number of digits
Parameters
numberNumber to get number of digits

◆ GetNumberLength() [2/9]

unsigned int Nz::GetNumberLength ( unsigned char  number)
inline

Gets the number of digits to represent the number in base 10.

Returns
Number of digits
Parameters
numberNumber to get number of digits

◆ GetNumberLength() [3/9]

unsigned int Nz::GetNumberLength ( int  number)
inline

Gets the number of digits to represent the number in base 10.

Returns
Number of digits
Parameters
numberNumber to get number of digits

◆ GetNumberLength() [4/9]

unsigned int Nz::GetNumberLength ( unsigned int  number)
inline

Gets the number of digits to represent the number in base 10.

Returns
Number of digits
Parameters
numberNumber to get number of digits

◆ GetNumberLength() [5/9]

unsigned int Nz::GetNumberLength ( long long  number)
inline

Gets the number of digits to represent the number in base 10.

Returns
Number of digits
Parameters
numberNumber to get number of digits

◆ GetNumberLength() [6/9]

unsigned int Nz::GetNumberLength ( unsigned long long  number)
inline

Gets the number of digits to represent the number in base 10.

Returns
Number of digits
Parameters
numberNumber to get number of digits

◆ GetNumberLength() [7/9]

unsigned int Nz::GetNumberLength ( float  number,
UInt8  precision 
)
inline

Gets the number of digits to represent the number in base 10.

Returns
Number of digits + 1 for the dot
Parameters
numberNumber to get number of digits
precisionNumber of digit after the dot

◆ GetNumberLength() [8/9]

unsigned int Nz::GetNumberLength ( double  number,
UInt8  precision 
)
inline

Gets the number of digits to represent the number in base 10.

Returns
Number of digits + 1 for the dot
Parameters
numberNumber to get number of digits
precisionNumber of digit after the dot

◆ GetNumberLength() [9/9]

unsigned int Nz::GetNumberLength ( long double  number,
UInt8  precision 
)
inline

Gets the number of digits to represent the number in base 10.

Returns
Number of digits + 1 for the dot
Parameters
numberNumber to get number of digits
precisionNumber of digit after the dot

◆ IntegralLog2()

template<typename T >
unsigned int Nz::IntegralLog2 ( number)
inline

Gets the log in base 2 of integral number.

Returns
Log of the number (floor)
Parameters
numberTo get log in base 2
Remarks
If number is 0, 0 is returned

◆ IntegralLog2Pot()

template<typename T >
unsigned int Nz::IntegralLog2Pot ( pot)
inline

Gets the log in base 2 of integral number, only works for power of two !

Returns
Log of the number
Parameters
potTo get log in base 2
Remarks
Only works for power of two
If number is 0, 0 is returned

◆ IntegralPow()

template<typename T >
T Nz::IntegralPow ( base,
unsigned int  exponent 
)

Gets the power of integrals.

Returns
base^exponent for integral
Parameters
baseBase of the exponentation
exponentPower for the base

◆ Lerp()

template<typename T , typename T2 >
constexpr T Nz::Lerp ( const T &  from,
const T &  to,
const T2 &  interpolation 
)

Interpolates the value to other one with a factor of interpolation.

Returns
A new value which is the interpolation of two values
Parameters
fromInitial value
toTarget value
interpolationFactor of interpolation
Remarks
interpolation is meant to be between 0 and 1, other values are potentially undefined behavior
With NAZARA_DEBUG, a NazaraWarning is produced
See also
Lerp

◆ MultiplyAdd()

template<typename T >
constexpr T Nz::MultiplyAdd ( x,
y,
z 
)

Multiplies X and Y, then add Z.

Returns
The result of X * Y + Z
Parameters
xis X
yis Y
zis Z
Remarks
This function is meant to use a special faster instruction in CPU if possible

◆ NormalizeAngle()

template<typename T >
T Nz::NormalizeAngle ( angle)
inline

Normalizes the angle.

Returns
Normalized value between 0..2*(pi if radian or 180 if degrees)
Parameters
angleAngle to normalize

◆ NumberEquals() [1/2]

template<typename T >
bool Nz::NumberEquals ( a,
b 
)
inline

Checks whether two numbers are equal.

Returns
true if they are equal within a certain epsilon
Parameters
aFirst value
bSecond value

◆ NumberEquals() [2/2]

template<typename T >
bool Nz::NumberEquals ( a,
b,
maxDifference 
)
inline

Checks whether two numbers are equal.

Returns
true if they are equal within the max difference
Parameters
aFirst value
bSecond value
maxDifferenceEpsilon of comparison (expected to be positive)

◆ NumberToString()

String Nz::NumberToString ( long long  number,
UInt8  radix 
)
inline

Converts the number to String.

Returns
String representation of the number
Parameters
numberNumber to represent
radixBase of the number
Remarks
radix is meant to be between 2 and 36, other values are potentially undefined behavior
With NAZARA_MATH_SAFE, a NazaraError is produced and String() is returned

◆ RadianToDegree()

template<typename T >
constexpr T Nz::RadianToDegree ( radians)

Converts radian to degree.

Returns
The representation in degree of the angle in radian (0..360)
Parameters
radiansAngle in radian (this is expected between 0..2*pi)

◆ StringToNumber()

long long Nz::StringToNumber ( String  str,
UInt8  radix,
bool *  ok 
)
inline

Converts the string to number.

Returns
Number which is represented by the string
Parameters
strString representation
radixBase of the number
okOptional argument to know if convertion is correct
Remarks
radix is meant to be between 2 and 36, other values are potentially undefined behavior
With NAZARA_MATH_SAFE, a NazaraError is produced and 0 is returned

◆ ToDegrees()

template<typename T >
constexpr T Nz::ToDegrees ( angle)

Gets the degree from unit and convert it according to NAZARA_MATH_ANGLE_RADIAN.

Returns
Express in degrees
Parameters
angleConvert degree from NAZARA_MATH_ANGLE_RADIAN unit to degrees

◆ ToRadians()

template<typename T >
constexpr T Nz::ToRadians ( angle)

Gets the radian from unit and convert it according to NAZARA_MATH_ANGLE_RADIAN.

Returns
Express in radians
Parameters
angleConvert degree from NAZARA_MATH_ANGLE_RADIAN unit to radians