Tizen Native API  5.0
Math

Classes for basic math.

Classes

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::Radian
 An angle in radians. 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 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)
 Clamps a radian value.
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, Radian rhs)
 Compares equality between two radians.
bool Dali::operator!= (Radian lhs, Radian rhs)
 Compares inequality between two radians.
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.
bool Dali::operator> (Radian lhs, Radian rhs)
 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.
bool Dali::operator< (Radian lhs, Radian rhs)
 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.
Radian Dali::operator* (Radian lhs, float rhs)
 Multiplies Radian with a float.
Radian Dali::operator- (Radian in)
 Negates the radian.
Radian Dali::Clamp (Radian angle, float min, float max)
 Clamps a radian value.
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<int32_t> 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]valueThe value to clamp.
[in]minThe minimum allowed value.
[in]maxThe maximum allowed value.
Returns:
T the clamped value
Degree Dali::Clamp ( Degree  angle,
float  min,
float  max 
)

Clamps a radian value.

Since:
2.4, DALi version 1.0.0
Parameters:
angleto clamp
minvalue
maxvalue
Returns:
The resulting radian
Radian Dali::Clamp ( Radian  angle,
float  min,
float  max 
)

Clamps a radian value.

Since:
2.4, DALi version 1.0.0
Parameters:
angleto clamp
minvalue
maxvalue
Returns:
The resulting radian
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]vA vector
[in]minThe minimum value
[in]maxThe 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]vA vector
[in]minThe minimum value
[in]maxThe 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]vA vector
[in]minThe minimum value
[in]maxThe 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]valueThe value that will be clamped.
[in]minThe minimum allowed value.
[in]maxThe 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]athe first value to compare
[in]bthe 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]athe first value to compare
[in]bthe second value to compare
[in]epsilonthe 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]valuethe 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]athe first value in the range
[in]bthe 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]iInput 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]offsetThe offset through the range low to high. This value is clamped between 0 and 1.
[in]lowLowest value in range
[in]highHighest 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]aA vector
[in]bA 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]aA vector
[in]bA 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]aA vector
[in]bA 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]aA vector
[in]bA 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]aA vector
[in]bA 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]aA vector
[in]bA 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]iInput 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]lhsDegree to compare
[in]rhsDegree to compare to
Returns:
True if the values are not identical
bool Dali::operator!= ( Radian  lhs,
Radian  rhs 
)

Compares inequality between two radians.

Since:
2.4, DALi version 1.0.0
Parameters:
[in]lhsRadian to compare
[in]rhsRadian to compare to
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]lhsRadian to compare
[in]rhsDegree 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]lhsDegree to compare
[in]rhsRadian to compare to
Returns:
True if the values are not identical
Radian Dali::operator* ( Radian  lhs,
float  rhs 
)

Multiplies Radian with a float.

Since:
2.4, DALi version 1.0.0
Parameters:
[in]lhsRadian to multiply
[in]rhsfloat to multiply
Returns:
Result of the multiplication
Radian Dali::operator- ( Radian  in)

Negates the radian.

Since:
2.4, DALi version 1.0.0
Parameters:
[in]inRadian to negate
Returns:
The negative angle
bool Dali::operator< ( Radian  lhs,
Radian  rhs 
)

Compares less than between two radians.

Since:
2.4, DALi version 1.0.0
Parameters:
[in]lhsRadian to compare
[in]rhsRadian to compare to
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]lhsRadian to compare
[in]rhsDegree 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]lhsDegree to compare
[in]rhsRadian to compare to
Returns:
True if lhs is less than rhs
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]oThe output stream operator
[in]matrixThe matrix to print
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]oThe output stream operator
[in]matrixThe 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]oThe output stream operator
[in]vectorThe 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]oThe output stream operator
[in]quaternionThe 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]oThe output stream operator
[in]vectorThe 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]oThe output stream operator
[in]vectorThe vector to print
Returns:
The output stream operator
bool Dali::operator== ( const Degree &  lhs,
const Degree &  rhs 
)

Compares equality between two degrees.

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

Compares equality between two radians.

Since:
2.4, DALi version 1.0.0
Parameters:
[in]lhsRadian to compare
[in]rhsRadian to compare to
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]lhsRadian to compare
[in]rhsDegree 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]lhsDegree to compare
[in]rhsRadian to compare to
Returns:
True if the values are identical
bool Dali::operator> ( Radian  lhs,
Radian  rhs 
)

Compares greater than between two radians.

Since:
2.4, DALi version 1.0.0
Parameters:
[in]lhsRadian to compare
[in]rhsRadian to compare to
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]lhsRadian to compare
[in]rhsDegree 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]lhsRadian to compare
[in]rhsDegree 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]valuefloat value
[in]posdecimal 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 determing the closest object to a given point, or determing 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:
athe current value
bthe target value
startthe start of the domain
endthe 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 ( value)

Extracts the sign of a number.

Since:
2.4, DALi version 1.0.0
Parameters:
[in]valueThe 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]xthe point to be wrapped within the domain
[in]startThe start of the domain
[in]endThe 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.