Urho3D
Enumerations | Functions | Variables
MathDefs.h File Reference
#include "../Math/Random.h"
#include <cstdlib>
#include <cmath>
#include <limits>
#include <type_traits>

Enumerations

enum  Urho3D::Intersection { OUTSIDE , INTERSECTS , INSIDE }
 Intersection test result.
 

Functions

template<class T >
bool Urho3D::Equals (T lhs, T rhs)
 Check whether two floating point values are equal within accuracy.
 
template<class T , class U >
Urho3D::Lerp (T lhs, T rhs, U t)
 Linear interpolation between two values.
 
template<class T >
Urho3D::InverseLerp (T lhs, T rhs, T x)
 Inverse linear interpolation between two values.
 
template<class T , class U >
Urho3D::Min (T lhs, U rhs)
 Return the smaller of two values.
 
template<class T , class U >
Urho3D::Max (T lhs, U rhs)
 Return the larger of two values.
 
template<class T >
Urho3D::Abs (T value)
 Return absolute value of a value.
 
template<class T >
Urho3D::Sign (T value)
 Return the sign of a float (-1, 0 or 1).
 
template<class T >
Urho3D::ToRadians (const T degrees)
 Convert degrees to radians.
 
template<class T >
Urho3D::ToDegrees (const T radians)
 Convert radians to degrees.
 
unsigned Urho3D::FloatToRawIntBits (float value)
 Return a representation of the specified floating-point value as a single format bit layout.
 
template<class T >
bool Urho3D::IsNaN (T value)
 Check whether a floating point value is NaN.
 
template<class T >
bool Urho3D::IsInf (T value)
 Check whether a floating point value is positive or negative infinity.
 
template<class T >
Urho3D::Clamp (T value, T min, T max)
 Clamp a number to a range.
 
template<class T >
Urho3D::SmoothStep (T lhs, T rhs, T t)
 Smoothly damp between values.
 
template<class T >
Urho3D::Sin (T angle)
 Return sine of an angle in degrees.
 
template<class T >
Urho3D::Cos (T angle)
 Return cosine of an angle in degrees.
 
template<class T >
Urho3D::Tan (T angle)
 Return tangent of an angle in degrees.
 
template<class T >
Urho3D::Asin (T x)
 Return arc sine in degrees.
 
template<class T >
Urho3D::Acos (T x)
 Return arc cosine in degrees.
 
template<class T >
Urho3D::Atan (T x)
 Return arc tangent in degrees.
 
template<class T >
Urho3D::Atan2 (T y, T x)
 Return arc tangent of y/x in degrees.
 
template<class T >
Urho3D::Pow (T x, T y)
 Return X in power Y.
 
template<class T >
Urho3D::Ln (T x)
 Return natural logarithm of X.
 
template<class T >
Urho3D::Sqrt (T x)
 Return square root of X.
 
template<class T , typename std::enable_if< std::is_floating_point< T >::value >::type * = nullptr>
Urho3D::Mod (T x, T y)
 Return remainder of X/Y for float values. More...
 
template<class T >
Urho3D::AbsMod (T x, T y)
 Return always positive remainder of X/Y.
 
template<class T >
Urho3D::Fract (T value)
 Return fractional part of passed value in range [0, 1).
 
template<class T >
Urho3D::Floor (T x)
 Round value down.
 
template<class T >
int Urho3D::FloorToInt (T x)
 Round value down. Returns integer value.
 
template<class T >
Urho3D::Round (T x)
 Round value to nearest integer.
 
template<class Iterator >
auto Urho3D::Average (Iterator begin, Iterator end) -> typename std::decay< decltype(*begin)>::type
 Compute average value of the range.
 
template<class T >
int Urho3D::RoundToInt (T x)
 Round value to nearest integer.
 
template<class T >
Urho3D::RoundToNearestMultiple (T x, T multiple)
 Round value to nearest multiple.
 
template<class T >
Urho3D::Ceil (T x)
 Round value up.
 
template<class T >
int Urho3D::CeilToInt (T x)
 Round value up.
 
bool Urho3D::IsPowerOfTwo (unsigned value)
 Check whether an unsigned integer is a power of two.
 
unsigned Urho3D::NextPowerOfTwo (unsigned value)
 Round up to next power of two.
 
unsigned Urho3D::ClosestPowerOfTwo (unsigned value)
 Round up or down to the closest power of two.
 
unsigned Urho3D::LogBaseTwo (unsigned value)
 Return log base two or the MSB position of the given value.
 
i32 Urho3D::CountSetBits (u32 value)
 Count the number of set bits in a mask.
 
constexpr hash32 Urho3D::SDBMHash (hash32 hash, u8 c)
 Update a hash with the given 8-bit value using the SDBM algorithm.
 
constexpr hash32 Urho3D::SDBMHash (hash32 hash, byte b)
 Update a hash with the given byte value using the SDBM algorithm.
 
float Urho3D::Random ()
 Return a random float between 0.0 (inclusive) and 1.0 (exclusive).
 
float Urho3D::Random (float range)
 Return a random float between 0.0 and range, inclusive from both ends.
 
float Urho3D::Random (float min, float max)
 Return a random float between min and max, inclusive from both ends.
 
int Urho3D::Random (int range)
 Return a random integer between 0 and range - 1.
 
int Urho3D::Random (int min, int max)
 Return a random integer between min and max - 1.
 
float Urho3D::RandomNormal (float meanValue, float variance)
 Return a random normal distributed number with the given mean value and variance.
 
unsigned short Urho3D::FloatToHalf (float value)
 Convert float to half float. From https://gist.github.com/martinkallman/5049614.
 
float Urho3D::HalfToFloat (unsigned short value)
 Convert half float to float. From https://gist.github.com/martinkallman/5049614.
 
void Urho3D::SinCos (float angle, float &sin, float &cos)
 Calculate both sine and cosine, with angle in degrees.
 

Variables

constexpr float Urho3D::M_PI = 3.14159265358979323846264338327950288f
 
constexpr float Urho3D::M_HALF_PI = M_PI * 0.5f
 
constexpr i32 Urho3D::M_MIN_INT = 0x80000000
 
constexpr i32 Urho3D::M_MAX_INT = 0x7FFFFFFF
 
constexpr u32 Urho3D::M_MIN_UNSIGNED = 0x00000000
 
constexpr u32 Urho3D::M_MAX_UNSIGNED = 0xFFFFFFFF
 
constexpr i8 Urho3D::M_MIN_I8 = (i8)0x80
 
constexpr i8 Urho3D::M_MAX_I8 = 0x7F
 
constexpr u8 Urho3D::M_MIN_U8 = 0x00
 
constexpr u8 Urho3D::M_MAX_U8 = 0xFF
 
constexpr i16 Urho3D::M_MIN_I16 = (i16)0x8000
 
constexpr i16 Urho3D::M_MAX_I16 = 0x7FFF
 
constexpr u16 Urho3D::M_MIN_U16 = 0x0000
 
constexpr u16 Urho3D::M_MAX_U16 = 0xFFFF
 
constexpr i32 Urho3D::M_MIN_I32 = (i32)0x80000000
 
constexpr i32 Urho3D::M_MAX_I32 = 0x7FFFFFFF
 
constexpr u32 Urho3D::M_MIN_U32 = 0x00000000
 
constexpr u32 Urho3D::M_MAX_U32 = 0xFFFFFFFF
 
constexpr i64 Urho3D::M_MIN_I64 = (i64)0x8000000000000000
 
constexpr i64 Urho3D::M_MAX_I64 = 0x7FFFFFFFFFFFFFFF
 
constexpr u64 Urho3D::M_MIN_U64 = 0x0000000000000000
 
constexpr u64 Urho3D::M_MAX_U64 = 0xFFFFFFFFFFFFFFFF
 
constexpr i16 Urho3D::M_I16_MASK_ALL_BITS = (i16)0xFFFF
 
constexpr u16 Urho3D::M_U16_MASK_ALL_BITS = 0xFFFF
 
constexpr i32 Urho3D::M_I32_MASK_ALL_BITS = (i32)0xFFFFFFFF
 
constexpr u32 Urho3D::M_U32_MASK_ALL_BITS = 0xFFFFFFFF
 
constexpr float Urho3D::M_EPSILON = 0.000001f
 
constexpr float Urho3D::M_LARGE_EPSILON = 0.00005f
 
constexpr float Urho3D::M_MIN_NEARCLIP = 0.01f
 
constexpr float Urho3D::M_MAX_FOV = 160.0f
 
constexpr float Urho3D::M_LARGE_VALUE = 100000000.0f
 
constexpr float Urho3D::M_INFINITY = std::numeric_limits<float>::infinity()
 
constexpr float Urho3D::M_DEGTORAD = M_PI / 180.0f
 
constexpr float Urho3D::M_DEGTORAD_2 = M_PI / 360.0f
 
constexpr float Urho3D::M_RADTODEG = 1.0f / M_DEGTORAD
 

Function Documentation

◆ Mod()

template<class T , typename std::enable_if< std::is_floating_point< T >::value >::type * = nullptr>
T Urho3D::Mod ( x,
y 
)
inline

Return remainder of X/Y for float values.

Return remainder of X/Y for integer values.