ezEngine  Milestone 7
ezMath Namespace Reference

This namespace provides common math-functionality as functions. More...

Classes

struct  BasicType
 

Functions

ezUInt32 Log2i (ezUInt32 val)
 Returns the integral logarithm to the base 2, that comes closest to the given integer.
 
EZ_FORCE_INLINE int Pow2 (ezInt32 i)
 Returns 2^f.
 
int Pow (ezInt32 base, ezInt32 exp)
 Returns base^exp.
 
template<typename T >
EZ_FORCE_INLINE T Square (T f)
 Returns f * f.
 
template<typename T >
EZ_FORCE_INLINE T Sign (T f)
 Returns the sign of f (i.e: -1, 1 or 0)
 
template<typename T >
EZ_FORCE_INLINE T Abs (T f)
 Returns the absolute value of f.
 
template<typename T >
EZ_FORCE_INLINE T Min (T f1, T f2)
 Returns the smaller value, f1 or f2.
 
template<typename T >
EZ_FORCE_INLINE T Min (T f1, T f2, T f3)
 Returns the smaller value, f1 or f2 or f3.
 
template<typename T >
EZ_FORCE_INLINE T Min (T f1, T f2, T f3, T f4)
 Returns the smaller value, f1 or f2 or f3 or f4.
 
template<typename T >
EZ_FORCE_INLINE T Max (T f1, T f2)
 Returns the greater value, f1 or f2.
 
template<typename T >
EZ_FORCE_INLINE T Max (T f1, T f2, T f3)
 Returns the smaller value, f1 or f2 or f3.
 
template<typename T >
EZ_FORCE_INLINE T Max (T f1, T f2, T f3, T f4)
 Returns the smaller value, f1 or f2 or f3 or f4.
 
template<typename T >
EZ_FORCE_INLINE T Clamp (T value, T min_val, T max_val)
 Clamps "value" to the range [min; max]. Returns "value", if it is inside the range already.
 
ezInt32 Floor (ezInt32 i, ezUInt32 uiMultiple)
 Returns a multiple of uiMultiple that is smaller than i.
 
ezInt32 Ceil (ezInt32 i, ezUInt32 uiMultiple)
 Returns a multiple of uiMultiple that is larger than i.
 
template<typename Type >
Type Invert (Type f)
 Returns 1 / f.
 
EZ_FORCE_INLINE bool IsOdd (ezInt32 i)
 Returns true, if i is an odd number.
 
EZ_FORCE_INLINE bool IsEven (ezInt32 i)
 Returns true, if i is an even number.
 
template<typename T >
EZ_FORCE_INLINE void Swap (T &f1, T &f2)
 Swaps the values in the two variables f1 and f2.
 
template<typename T >
EZ_FORCE_INLINE T Lerp (T f1, T f2, float factor)
 Returns the linear interpolation of f1 and f2. factor is a value between 0 and 1.
 
template<typename T >
EZ_FORCE_INLINE T Step (T value, T edge)
 Returns 0, if value < edge, and 1, if value >= edge.
 
EZ_FORCE_INLINE bool IsPowerOf2 (ezInt32 value)
 Returns true, if there exists some x with 2^x == value.
 
template<typename Type >
bool IsEqual (Type lhs, Type rhs, Type fEpsilon)
 Checks, whether fValue is in the range [fDesired - fMaxImprecision; fDesired + fMaxImprecision].
 
template<typename T >
bool IsInRange (T Value, T MinVal, T MaxVal)
 Checks whether the value of the first parameter lies between the value of the second and third.
 
template<typename Type >
bool IsZero (Type f, Type fEpsilon)
 Checks whether the given number is close to zero.
 
template<typename Type >
EZ_FORCE_INLINE Type Trunc (Type f)
 Returns the integer-part of f (removes the fraction).
 
template<typename Type >
EZ_FORCE_INLINE Type Round (Type f)
 Rounds f to the next integer. If f is positive 0.5 is rounded UP (i.e. to 1), if f is negative, -0.5 is rounded DOWN (i.e. to -1).
 
template<typename Type >
EZ_FORCE_INLINE Type Round (Type f, Type fRoundTo)
 Rounds f to the closest multiple of fRoundTo.
 
template<typename Type >
EZ_FORCE_INLINE Type Fraction (Type f)
 Returns the fraction-part of f.
 
template<typename Type >
Type SmoothStep (Type value, Type edge1, Type edge2)
 Returns 0, if value is <= edge1, 1 if value >= edge2 and the hermite interpolation in between.
 
EZ_FORCE_INLINE bool IsFinite (double value)
 
EZ_FORCE_INLINE bool IsNaN (double value)
 
EZ_FORCE_INLINE double Floor (double f)
 
EZ_FORCE_INLINE double Ceil (double f)
 
double Floor (double f, double fMultiple)
 
double Ceil (double f, double fMultiple)
 
EZ_FORCE_INLINE double Exp (double f)
 
EZ_FORCE_INLINE double Ln (double f)
 
EZ_FORCE_INLINE double Log2 (double f)
 
EZ_FORCE_INLINE double Log10 (double f)
 
EZ_FORCE_INLINE double Log (double fBase, double f)
 
EZ_FORCE_INLINE double Pow2 (double f)
 
EZ_FORCE_INLINE double Pow (double base, double exp)
 
EZ_FORCE_INLINE double Root (double f, double NthRoot)
 
EZ_FORCE_INLINE double Sqrt (double f)
 
EZ_FORCE_INLINE double Mod (double f, double div)
 
 FIXEDPOINT_OVERLOADS (1)
 
 FIXEDPOINT_OVERLOADS (2)
 
 FIXEDPOINT_OVERLOADS (3)
 
 FIXEDPOINT_OVERLOADS (4)
 
 FIXEDPOINT_OVERLOADS (5)
 
 FIXEDPOINT_OVERLOADS (6)
 
 FIXEDPOINT_OVERLOADS (7)
 
 FIXEDPOINT_OVERLOADS (8)
 
 FIXEDPOINT_OVERLOADS (9)
 
 FIXEDPOINT_OVERLOADS (10)
 
 FIXEDPOINT_OVERLOADS (11)
 
 FIXEDPOINT_OVERLOADS (12)
 
 FIXEDPOINT_OVERLOADS (13)
 
 FIXEDPOINT_OVERLOADS (14)
 
 FIXEDPOINT_OVERLOADS (15)
 
 FIXEDPOINT_OVERLOADS (16)
 
 FIXEDPOINT_OVERLOADS (17)
 
 FIXEDPOINT_OVERLOADS (18)
 
 FIXEDPOINT_OVERLOADS (19)
 
 FIXEDPOINT_OVERLOADS (20)
 
 FIXEDPOINT_OVERLOADS (21)
 
 FIXEDPOINT_OVERLOADS (22)
 
 FIXEDPOINT_OVERLOADS (23)
 
 FIXEDPOINT_OVERLOADS (24)
 
 FIXEDPOINT_OVERLOADS (25)
 
 FIXEDPOINT_OVERLOADS (26)
 
 FIXEDPOINT_OVERLOADS (27)
 
 FIXEDPOINT_OVERLOADS (28)
 
 FIXEDPOINT_OVERLOADS (29)
 
 FIXEDPOINT_OVERLOADS (30)
 
template<ezUInt8 DecimalBits>
EZ_FORCE_INLINE ezFixedPoint
< DecimalBits > 
Floor (ezFixedPoint< DecimalBits > f)
 
template<ezUInt8 DecimalBits>
EZ_FORCE_INLINE ezFixedPoint
< DecimalBits > 
Ceil (ezFixedPoint< DecimalBits > f)
 
template<ezUInt8 DecimalBits>
ezFixedPoint< DecimalBits > Floor (ezFixedPoint< DecimalBits > f, ezFixedPoint< DecimalBits > fMultiple)
 
template<ezUInt8 DecimalBits>
ezFixedPoint< DecimalBits > Ceil (ezFixedPoint< DecimalBits > f, ezFixedPoint< DecimalBits > fMultiple)
 
template<ezUInt8 DecimalBits>
EZ_FORCE_INLINE ezFixedPoint
< DecimalBits > 
Exp (ezFixedPoint< DecimalBits > f)
 
template<ezUInt8 DecimalBits>
EZ_FORCE_INLINE ezFixedPoint
< DecimalBits > 
Ln (ezFixedPoint< DecimalBits > f)
 
template<ezUInt8 DecimalBits>
EZ_FORCE_INLINE ezFixedPoint
< DecimalBits > 
Log2 (ezFixedPoint< DecimalBits > f)
 
template<ezUInt8 DecimalBits>
EZ_FORCE_INLINE ezFixedPoint
< DecimalBits > 
Log10 (ezFixedPoint< DecimalBits > f)
 
template<ezUInt8 DecimalBits>
EZ_FORCE_INLINE ezFixedPoint
< DecimalBits > 
Log (ezFixedPoint< DecimalBits > fBase, ezFixedPoint< DecimalBits > f)
 
template<ezUInt8 DecimalBits>
EZ_FORCE_INLINE ezFixedPoint
< DecimalBits > 
Pow2 (ezFixedPoint< DecimalBits > f)
 
template<ezUInt8 DecimalBits>
EZ_FORCE_INLINE ezFixedPoint
< DecimalBits > 
Pow (ezFixedPoint< DecimalBits > base, ezFixedPoint< DecimalBits > exp)
 
template<ezUInt8 DecimalBits>
EZ_FORCE_INLINE ezFixedPoint
< DecimalBits > 
Root (ezFixedPoint< DecimalBits > f, ezFixedPoint< DecimalBits > NthRoot)
 
template<ezUInt8 DecimalBits>
ezFixedPoint< DecimalBits > Sqrt (ezFixedPoint< DecimalBits > a)
 
template<ezUInt8 DecimalBits>
EZ_FORCE_INLINE ezFixedPoint
< DecimalBits > 
Mod (ezFixedPoint< DecimalBits > f, ezFixedPoint< DecimalBits > div)
 
EZ_FORCE_INLINE bool IsFinite (float value)
 
EZ_FORCE_INLINE bool IsNaN (float value)
 
EZ_FORCE_INLINE float Floor (float f)
 Returns the next smaller integer, closest to f. Also the SMALLER value, if f is negative.
 
EZ_FORCE_INLINE float Ceil (float f)
 Returns the next higher integer, closest to f. Also the HIGHER value, if f is negative.
 
float Floor (float f, float fMultiple)
 Returns a multiple of fMultiple that is smaller than f.
 
float Ceil (float f, float fMultiple)
 Returns a multiple of fMultiple that is larger than f.
 
EZ_FORCE_INLINE float Sin (ezAngle a)
 ***** Trigonometric Functions ***** More...
 
EZ_FORCE_INLINE float Cos (ezAngle a)
 Takes an angle, returns its cosine.
 
EZ_FORCE_INLINE float Tan (ezAngle a)
 Takes an angle, returns its tangent.
 
EZ_FORCE_INLINE ezAngle ASin (float f)
 Returns the arcus sinus of f.
 
EZ_FORCE_INLINE ezAngle ACos (float f)
 Returns the arcus cosinus of f.
 
EZ_FORCE_INLINE ezAngle ATan (float f)
 Returns the arcus tangent of f.
 
EZ_FORCE_INLINE ezAngle ATan2 (float x, float y)
 Returns the atan2 of x and y.
 
EZ_FORCE_INLINE float Exp (float f)
 Returns e^f.
 
EZ_FORCE_INLINE float Ln (float f)
 Returns the logarithmus naturalis of f.
 
EZ_FORCE_INLINE float Log2 (float f)
 Returns log (f), to the base 2.
 
EZ_FORCE_INLINE float Log10 (float f)
 Returns log (f), to the base 10.
 
EZ_FORCE_INLINE float Log (float fBase, float f)
 Returns log (f), to the base fBase.
 
EZ_FORCE_INLINE float Pow2 (float f)
 Returns 2^f.
 
EZ_FORCE_INLINE float Pow (float base, float exp)
 Returns base^exp.
 
EZ_FORCE_INLINE float Root (float f, float NthRoot)
 Returns the n-th root of f.
 
EZ_FORCE_INLINE float Sqrt (float f)
 Returns the square root of f.
 
EZ_FORCE_INLINE float Mod (float value, float div)
 Returns "value mod div" for floats. This also works with negative numbers, both for value and for div.
 
template<typename T >
Square (T f)
 Returns f * f.
 
template<typename T >
Sign (T f)
 Returns the sign of f (i.e: -1, 1 or 0)
 
template<typename T >
Abs (T f)
 Returns the absolute value of f.
 
template<typename T >
Min (T f1, T f2)
 Returns the smaller value, f1 or f2.
 
template<typename T >
Min (T f1, T f2, T f3)
 Returns the smaller value, f1 or f2 or f3.
 
template<typename T >
Min (T f1, T f2, T f3, T f4)
 Returns the smaller value, f1 or f2 or f3 or f4.
 
template<typename T >
Max (T f1, T f2)
 Returns the greater value, f1 or f2.
 
template<typename T >
Max (T f1, T f2, T f3)
 Returns the smaller value, f1 or f2 or f3.
 
template<typename T >
Max (T f1, T f2, T f3, T f4)
 Returns the smaller value, f1 or f2 or f3 or f4.
 
template<typename T >
Clamp (T value, T min_val, T max_val)
 Clamps "value" to the range [min; max]. Returns "value", if it is inside the range already.
 
template<typename Type >
Type Trunc (Type f)
 Returns the integer-part of f (removes the fraction).
 
template<typename Type >
Type Round (Type f)
 Rounds f to the next integer. If f is positive 0.5 is rounded UP (i.e. to 1), if f is negative, -0.5 is rounded DOWN (i.e. to -1).
 
template<typename Type >
Type Round (Type f, Type fRoundTo)
 Rounds f to the closest multiple of fRoundTo.
 
template<typename Type >
Type Fraction (Type f)
 Returns the fraction-part of f.
 
template<typename T >
void Swap (T &f1, T &f2)
 Swaps the values in the two variables f1 and f2.
 
template<typename T >
Lerp (T f1, T f2, float factor)
 Returns the linear interpolation of f1 and f2. factor is a value between 0 and 1.
 
template<typename T >
Step (T value, T edge)
 Returns 0, if value < edge, and 1, if value >= edge.
 
EZ_FOUNDATION_DLL bool IsPowerOf (ezInt32 value, ezInt32 base)
 Returns true, if there exists some x with base^x == value.
 
EZ_FOUNDATION_DLL ezInt32 PowerOfTwo_Floor (ezUInt32 value)
 Returns the next power-of-two that is <= value.
 
EZ_FOUNDATION_DLL ezInt32 PowerOfTwo_Ceil (ezUInt32 value)
 Returns the next power-of-two that is >= value.
 

Detailed Description

This namespace provides common math-functionality as functions.

It is a namespace, instead of a static class, because that allows it to be extended at other locations, which is especially useful when adding custom types.

Function Documentation

float ezMath::Sin ( ezAngle  a)

***** Trigonometric Functions *****

Takes an angle, returns its sine