Tizen Native API  6.5

Classes for basic math.

## Classes

struct  Dali::AngleAxis
An angle & axis pair. More...
struct  Dali::Power< mantissa, exponent >
Compiles time template to calculate base to the power of N. More...
struct  Dali::Power< mantissa, 1 >
Compiles time template to calculate base to the power of N. More...
struct  Dali::Power< mantissa, 0 >
Compiles time template to calculate base to the power of N. More...
struct  Dali::Log< number, base >
Compiles time template to calculate base logarithm of N. More...
struct  Dali::Log< 1, base >
Compiles time template to calculate base logarithm of N. More...
struct  Dali::Log< 0, base >
Compiles time template to calculate base logarithm of N. More...
struct  Dali::Epsilon< N >
Compiles time template to calculate the machine epsilon for a given floating point number. More...
struct  Dali::Epsilon< 1 >
Compiles time template to calculate the machine epsilon for a given floating point number. More...
struct  Dali::Epsilon< 0 >
Compiles time template to calculate the machine epsilon for a given floating point number. More...
struct  Dali::Degree
An angle in degrees. More...
class  Dali::Matrix
The Matrix class represents transformations and projections. More...
class  Dali::Matrix3
A 3x3 matrix. More...
class  Dali::Quaternion
The Quaternion class encapsulates the mathematics of the quaternion. More...
struct  Dali::Rect< T >
Template class to create and operate on rectangles. More...
class  Dali::Uint16Pair
Simple class for passing around pairs of small unsigned integers. More...
struct  Dali::Vector2
A two dimensional vector. More...
struct  Dali::Vector3
A three dimensional vector. More...
struct  Dali::Vector4
A four dimensional vector. More...

## Functions

bool Dali::operator== (const Dali::AngleAxis &lhs, const Dali::AngleAxis &rhs)
Compares two angle axis for equality.
std::ostream & Dali::operator<< (std::ostream &o, const Dali::AngleAxis &angleAxis)
Prints an angle axis.
bool Dali::operator== (const Degree &lhs, const Degree &rhs)
Compares equality between two degrees.
bool Dali::operator!= (const Degree &lhs, const Degree &rhs)
Compares inequality between two degrees.
Degree Dali::Clamp (Degree angle, float min, float max)
uint32_t Dali::NextPowerOfTwo (uint32_t i)
Returns the next power of two.
bool Dali::IsPowerOfTwo (uint32_t i)
Whether a number is power of two.
template<typename T >
const T & Dali::Clamp (const T &value, const T &min, const T &max)
Clamp a value.
template<typename T >
void Dali::ClampInPlace (T &value, const T &min, const T &max)
Clamp a value directly.
template<typename T >
const T Dali::Lerp (const float offset, const T &low, const T &high)
Linear interpolation between two values.
float Dali::GetRangedEpsilon (float a, float b)
Get an epsilon that is valid for the given range.
bool Dali::EqualsZero (float value)
Helper function to compare equality of a floating point value with zero.
bool Dali::Equals (float a, float b)
Helper function to compare equality of two floating point values.
bool Dali::Equals (float a, float b, float epsilon)
Helper function to compare equality of two floating point values.
float Dali::Round (float value, int32_t pos)
Get an float that is rounded at specified place of decimals.
float Dali::WrapInDomain (float x, float start, float end)
Wrap x in domain (start) to (end).
float Dali::ShortestDistanceInDomain (float a, float b, float start, float end)
Find the shortest distance (magnitude) and direction (sign) from (a) to (b) in domain (start) to (end).
template<typename T >
int32_t Dali::Sign (T value)
Extracts the sign of a number.
DALI_CORE_API std::ostream & Dali::operator<< (std::ostream &o, const Matrix &matrix)
Prints a matrix.
DALI_CORE_API std::ostream & Dali::operator<< (std::ostream &o, const Matrix3 &matrix)
Prints a 3x3 matrix.
DALI_CORE_API std::ostream & Dali::operator<< (std::ostream &o, const Quaternion &quaternion)
Prints a Quaternion.
bool Dali::operator== (Radian lhs, Degree rhs)
Compares equality between a radian and degree.
bool Dali::operator!= (Radian lhs, Degree rhs)
Compares inequality between a radian and a degree.
bool Dali::operator== (Degree lhs, Radian rhs)
Compares equality between a degree and a radian.
bool Dali::operator!= (Degree lhs, Radian rhs)
Compares inequality between a degree and a radian.
Compares greater than between two radians.
bool Dali::operator> (Radian lhs, Degree rhs)
Compares greater than between a radian and a degree.
bool Dali::operator> (Degree lhs, Radian rhs)
Compares greater than between a radian and a degree.
Compares less than between two radians.
bool Dali::operator< (Radian lhs, Degree rhs)
Compares less than between a radian and a degree.
bool Dali::operator< (Degree lhs, Radian rhs)
Compares less than between a degree and a radian.
template<typename T >
bool Dali::operator== (const Rect< T > &lhs, const Rect< T > &rhs)
Equality operator.
template<typename T >
bool Dali::operator!= (const Rect< T > &lhs, const Rect< T > &rhs)
Inequality operator.
template<>
bool Dali::operator== (const Rect< float > &lhs, const Rect< float > &rhs)
Equality operator specialization for float.
template<typename T >
std::ostream & Dali::operator<< (std::ostream &stream, const Rect< T > &rectangle)
Converts the value of the rectangle into a string and insert in to an output stream.
DALI_CORE_API std::ostream & Dali::operator<< (std::ostream &o, const Vector2 &vector)
Print a Vector2.
Vector2 Dali::Min (const Vector2 &a, const Vector2 &b)
Returns a vector with components set to the minimum of the corresponding component in a and b.
Vector2 Dali::Max (const Vector2 &a, const Vector2 &b)
Returns a vector with components set to the maximum of the corresponding component in a and b.
DALI_CORE_API Vector2 Dali::Clamp (const Vector2 &v, const float &min, const float &max)
Clamps each of vector v's components between minimum and maximum values.
DALI_CORE_API std::ostream & Dali::operator<< (std::ostream &o, const Vector3 &vector)
Prints a Vector3.
Vector3 Dali::Min (const Vector3 &a, const Vector3 &b)
Returns a vector with components set to the minimum of the corresponding component in a and b.
Vector3 Dali::Max (const Vector3 &a, const Vector3 &b)
Returns a vector with components set to the maximum of the corresponding component in a and b.
DALI_CORE_API Vector3 Dali::Clamp (const Vector3 &v, const float &min, const float &max)
Clamps each of vector v's components between minimum and maximum values.
DALI_CORE_API std::ostream & Dali::operator<< (std::ostream &o, const Vector4 &vector)
Print a Vector4.
Vector4 Dali::Min (const Vector4 &a, const Vector4 &b)
Returns a vector with components set to the minimum of the corresponding component in a and b.
Vector4 Dali::Max (const Vector4 &a, const Vector4 &b)
Returns a vector with components set to the maximum of the corresponding component in a and b.
DALI_CORE_API Vector4 Dali::Clamp (const Vector4 &v, const float &min, const float &max)
Clamps each of vector v's components between minimum and maximum values.

## Namespaces

namespace  Dali::Random

Provides methods to generate and use random values.

## Typedefs

typedef Vector2 Dali::Size
Size is an alias of Dali::Vector2.
typedef Rect< int32_t > Dali::Viewport
Typedef for a viewport ( a rectangle representing a screen area ).

## Typedef Documentation

 typedef Vector2 Dali::Size

Size is an alias of Dali::Vector2.

Since:
2.4, DALi version 1.0.0
 typedef Rect Dali::Viewport

Typedef for a viewport ( a rectangle representing a screen area ).

Since:
2.4, DALi version 1.0.0

## Function Documentation

template<typename T >
 const T& Dali::Clamp ( const T & value, const T & min, const T & max )

Clamp a value.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] value The value to clamp. [in] min The minimum allowed value. [in] max The maximum allowed value.
Returns:
T the clamped value
 Degree Dali::Clamp ( Degree angle, float min, float max )

Since:
2.4, DALi version 1.0.0
Parameters:
 angle to clamp min value max value
Returns:

Since:
2.4, DALi version 1.0.0
Parameters:
 angle to clamp min value max value
Returns:
 DALI_CORE_API Vector2 Dali::Clamp ( const Vector2 & v, const float & min, const float & max )

Clamps each of vector v's components between minimum and maximum values.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] v A vector [in] min The minimum value [in] max The maximum value
Returns:
A vector containing the clamped components of v
 DALI_CORE_API Vector3 Dali::Clamp ( const Vector3 & v, const float & min, const float & max )

Clamps each of vector v's components between minimum and maximum values.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] v A vector [in] min The minimum value [in] max The maximum value
Returns:
A vector containing the clamped components of v
 DALI_CORE_API Vector4 Dali::Clamp ( const Vector4 & v, const float & min, const float & max )

Clamps each of vector v's components between minimum and maximum values.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] v A vector [in] min The minimum value [in] max The maximum value
Returns:
A vector containing the clamped components of v
template<typename T >
 void Dali::ClampInPlace ( T & value, const T & min, const T & max )

Clamp a value directly.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in,out] value The value that will be clamped. [in] min The minimum allowed value. [in] max The maximum allowed value.
 bool Dali::Equals ( float a, float b )

Helper function to compare equality of two floating point values.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] a the first value to compare [in] b the second value to compare
Returns:
true if the values are equal within a minimal epsilon for their values
 bool Dali::Equals ( float a, float b, float epsilon )

Helper function to compare equality of two floating point values.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] a the first value to compare [in] b the second value to compare [in] epsilon the minimum epsilon value that will be used to consider the values different
Returns:
true if the difference between the values is less than the epsilon
 bool Dali::EqualsZero ( float value )

Helper function to compare equality of a floating point value with zero.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] value the value to compare
Returns:
true if the value is equal to zero
 float Dali::GetRangedEpsilon ( float a, float b )

Get an epsilon that is valid for the given range.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] a the first value in the range [in] b the second value in the range.
Returns:
a suitable epsilon
 bool Dali::IsPowerOfTwo ( uint32_t i )

Whether a number is power of two.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] i Input number
Returns:
True if i is power of two.
template<typename T >
 const T Dali::Lerp ( const float offset, const T & low, const T & high )

Linear interpolation between two values.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] offset The offset through the range `low` to `high`. This value is clamped between 0 and 1. [in] low Lowest value in range [in] high Highest value in range
Returns:
A value between low and high.
 Vector2 Dali::Max ( const Vector2 & a, const Vector2 & b )

Returns a vector with components set to the maximum of the corresponding component in a and b.

If a=0,1 and b=1,0 returns a vector of 1,1.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] a A vector [in] b A vector
Returns:
A vector containing the maximum of each component from a and b
 Vector3 Dali::Max ( const Vector3 & a, const Vector3 & b )

Returns a vector with components set to the maximum of the corresponding component in a and b.

If a=0,1 and b=1,0 returns a vector of 1,1.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] a A vector [in] b A vector
Returns:
A vector containing the maximum of each component from a and b
 Vector4 Dali::Max ( const Vector4 & a, const Vector4 & b )

Returns a vector with components set to the maximum of the corresponding component in a and b.

If a=0,1,2,3 and b=4,0,1,2 returns a vector of 4,1,2,3.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] a A vector [in] b A vector
Returns:
A vector containing the maximum of each component from a and b
 Vector2 Dali::Min ( const Vector2 & a, const Vector2 & b )

Returns a vector with components set to the minimum of the corresponding component in a and b.

If a=0,1 and b=1,0 returns a vector of 0,0.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] a A vector [in] b A vector
Returns:
A vector containing the minimum of each component from a and b
 Vector3 Dali::Min ( const Vector3 & a, const Vector3 & b )

Returns a vector with components set to the minimum of the corresponding component in a and b.

If a=0,1,2 and b=2,1,0 returns a vector of 2,1,2.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] a A vector [in] b A vector
Returns:
A vector containing the minimum of each component from a and b
 Vector4 Dali::Min ( const Vector4 & a, const Vector4 & b )

Returns a vector with components set to the minimum of the corresponding component in a and b.

If a=0,1,2,3 and b=4,0,1,2 returns a vector of 0,0,1,2.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] a A vector [in] b A vector
Returns:
A vector containing the minimum of each component from a and b
 uint32_t Dali::NextPowerOfTwo ( uint32_t i )

Returns the next power of two.

In case of numbers which are already a power of two this function returns the original number. If i is zero returns 1.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] i Input number
Returns:
The next power of two or i itself in case it's a power of two
 bool Dali::operator!= ( const Degree & lhs, const Degree & rhs )

Compares inequality between two degrees.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] lhs Degree to compare [in] rhs Degree to compare to
Returns:
True if the values are not identical

Since:
2.4, DALi version 1.0.0
Parameters:
Returns:
True if the values are not identical
 bool Dali::operator!= ( Radian lhs, Degree rhs )

Compares inequality between a radian and a degree.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] lhs Radian to compare [in] rhs Degree to compare to
Returns:
True if the values are not identical
 bool Dali::operator!= ( Degree lhs, Radian rhs )

Compares inequality between a degree and a radian.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] lhs Degree to compare [in] rhs Radian to compare to
Returns:
True if the values are not identical
template<typename T >
 bool Dali::operator!= ( const Rect< T > & lhs, const Rect< T > & rhs )

Inequality operator.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] lhs The first rectangle [in] rhs The second rectangle
Returns:
True if rectangles are not identical

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] lhs Radian to multiply [in] rhs float to multiply
Returns:
Result of the multiplication

Since:
2.4, DALi version 1.0.0
Parameters:
Returns:
The negative angle

Compares less than between two radians.

Since:
2.4, DALi version 1.0.0
Parameters:
Returns:
True if lhs is less than rhs
 bool Dali::operator< ( Radian lhs, Degree rhs )

Compares less than between a radian and a degree.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] lhs Radian to compare [in] rhs Degree to compare to
Returns:
True if lhs is less than rhs
 bool Dali::operator< ( Degree lhs, Radian rhs )

Compares less than between a degree and a radian.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] lhs Degree to compare [in] rhs Radian to compare to
Returns:
True if lhs is less than rhs
 std::ostream& Dali::operator<< ( std::ostream & o, const Dali::AngleAxis & angleAxis )

Prints an angle axis.

Since:
3.0, DALi version 1.1.33
Parameters:
 [in] o The output stream operator [in] angleAxis The angle axis to print
Returns:
The output stream operator
 DALI_CORE_API std::ostream& Dali::operator<< ( std::ostream & o, const Matrix3 & matrix )

Prints a 3x3 matrix.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] o The output stream operator [in] matrix The matrix to print
Returns:
The output stream operator
template<typename T >
 std::ostream& Dali::operator<< ( std::ostream & stream, const Rect< T > & rectangle )

Converts the value of the rectangle into a string and insert in to an output stream.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] stream The output stream operator [in] rectangle the rectangle to output
Returns:
The output stream operator
 DALI_CORE_API std::ostream& Dali::operator<< ( std::ostream & o, const Matrix & matrix )

Prints a matrix.

It is printed in memory order.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] o The output stream operator [in] matrix The matrix to print
Returns:
The output stream operator
 DALI_CORE_API std::ostream& Dali::operator<< ( std::ostream & o, const Vector2 & vector )

Print a Vector2.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] o The output stream operator [in] vector The vector to print
Returns:
The output stream operator
 DALI_CORE_API std::ostream& Dali::operator<< ( std::ostream & o, const Quaternion & quaternion )

Prints a Quaternion.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] o The output stream operator [in] quaternion The quaternion to print
Returns:
The output stream operator
 DALI_CORE_API std::ostream& Dali::operator<< ( std::ostream & o, const Vector3 & vector )

Prints a Vector3.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] o The output stream operator [in] vector The vector to print
Returns:
The output stream operator
 DALI_CORE_API std::ostream& Dali::operator<< ( std::ostream & o, const Vector4 & vector )

Print a Vector4.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] o The output stream operator [in] vector The vector to print
Returns:
The output stream operator
 bool Dali::operator== ( const Dali::AngleAxis & lhs, const Dali::AngleAxis & rhs )

Compares two angle axis for equality.

Since:
2.4, DALi version 1.0.0
Parameters:
 lhs angle axis rhs angle axis
Returns:
True if they are equal
 bool Dali::operator== ( const Degree & lhs, const Degree & rhs )

Compares equality between two degrees.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] lhs Degree to compare [in] rhs Degree to compare to
Returns:
True if the values are identical

Since:
2.4, DALi version 1.0.0
Parameters:
Returns:
True if the values are identical
 bool Dali::operator== ( Radian lhs, Degree rhs )

Compares equality between a radian and degree.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] lhs Radian to compare [in] rhs Degree to compare to
Returns:
True if the values are identical
 bool Dali::operator== ( Degree lhs, Radian rhs )

Compares equality between a degree and a radian.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] lhs Degree to compare [in] rhs Radian to compare to
Returns:
True if the values are identical
template<typename T >
 bool Dali::operator== ( const Rect< T > & lhs, const Rect< T > & rhs )

Equality operator.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] lhs First operand [in] rhs Second operand
Returns:
True if boxes are exactly same
template<>
 bool Dali::operator== ( const Rect< float > & lhs, const Rect< float > & rhs )

Equality operator specialization for float.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] lhs The first rectangle [in] rhs The second rectangle
Returns:
True if rectangles are exactly same

Compares greater than between two radians.

Since:
2.4, DALi version 1.0.0
Parameters:
Returns:
True if lhs is greater than rhs
 bool Dali::operator> ( Radian lhs, Degree rhs )

Compares greater than between a radian and a degree.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] lhs Radian to compare [in] rhs Degree to compare to
Returns:
True if lhs is greater than rhs
 bool Dali::operator> ( Degree lhs, Radian rhs )

Compares greater than between a radian and a degree.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] lhs Radian to compare [in] rhs Degree to compare to
Returns:
True if lhs is greater than rhs
 float Dali::Round ( float value, int32_t pos )

Get an float that is rounded at specified place of decimals.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] value float value [in] pos decimal place
Returns:
a rounded float
 float Dali::ShortestDistanceInDomain ( float a, float b, float start, float end )

Find the shortest distance (magnitude) and direction (sign) from (a) to (b) in domain (start) to (end).

```  (\ / start)               (\ / end)
|-a                 b<----|
```

Knowing the shortest distance is useful with wrapped domains to solve problems such as determining the closest object to a given point, or determining whether turning left or turning right is the shortest route to get from angle 10 degrees to angle 350 degrees (clearly in a 0-360 degree domain, turning left 20 degrees is quicker than turning right 340 degrees).

The value returned holds the distance and the direction from value a to value b. For instance in the above example it would return -20. i.e. subtract 20 from current value (10) to reach target wrapped value (350).

Since:
2.4, DALi version 1.0.0
Parameters:
 a the current value b the target value start the start of the domain end the end of the domain
Returns:
the shortest direction (the sign) and distance (the magnitude)
Note:
Assumes both (a) and (b) are already within the domain (start) to (end).
template<typename T >
 int32_t Dali::Sign ( T value )

Extracts the sign of a number.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] value The value we want to extract the sign
Returns:
-1 for negative values, +1 for positive values and 0 if value is 0
 float Dali::WrapInDomain ( float x, float start, float end )

Wrap x in domain (start) to (end).

This works like a floating point version of the % modulo operation. But with an offset (start).

For instance a domain is specified as: start: 2 end: 8

```   2                         8
(\ / start)               (\ / end)
|----x                    |
```

The value x will be confined to this domain. If x is below 2 e.g. 0, then it is wrapped to 6. If x is above or equal to 8 e.g. 8.1 then it is wrapped to 2.1.

Domain wrapping is useful for various problems from calculating positions in a space that repeats, to computing angles that range from 0 to 360.

Since:
2.4, DALi version 1.0.0
Parameters:
 [in] x the point to be wrapped within the domain [in] start The start of the domain [in] end The end of the domain
Returns:
the wrapped value over the domain (start) (end)
Note:
If start = end (i.e. size of domain 0), then wrapping will not occur and result will always be equal to start.