Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
Math.h File Reference

Go to the source code of this file.

Functions

JPH_INLINE constexpr float DegreesToRadians (float inV)
 Convert a value from degrees to radians. More...
 
JPH_INLINE constexpr float RadiansToDegrees (float inV)
 Convert a value from radians to degrees. More...
 
float CenterAngleAroundZero (float inV)
 Convert angle in radians to the range \([-\pi, \pi]\). More...
 
template<typename T >
JPH_INLINE constexpr T Clamp (T inV, T inMin, T inMax)
 Clamp a value between two values. More...
 
template<typename T >
JPH_INLINE constexpr T Square (T inV)
 Square a value. More...
 
template<typename T >
JPH_INLINE constexpr T Cubed (T inV)
 Returns \(inV^3\). More...
 
template<typename T >
JPH_INLINE constexpr T Sign (T inV)
 Get the sign of a value. More...
 
template<typename T >
constexpr bool IsPowerOf2 (T inV)
 Check if inV is a power of 2. More...
 
template<typename T >
AlignUp (T inV, uint64 inAlignment)
 Align inV up to the next inAlignment bytes. More...
 
template<typename T >
bool IsAligned (T inV, uint64 inAlignment)
 Check if inV is inAlignment aligned. More...
 
uint CountTrailingZeros (uint32 inValue)
 Compute number of trailing zero bits (how many low bits are zero) More...
 
uint CountLeadingZeros (uint32 inValue)
 Compute the number of leading zero bits (how many high bits are zero) More...
 
uint CountBits (uint32 inValue)
 Count the number of 1 bits in a value. More...
 
uint32 GetNextPowerOf2 (uint32 inValue)
 Get the next higher power of 2 of a value, or the value itself if the value is already a power of 2. More...
 
template<class To , class From >
JPH_INLINE To BitCast (const From &inValue)
 

Function Documentation

◆ AlignUp()

template<typename T >
T AlignUp ( inV,
uint64  inAlignment 
)
inline

Align inV up to the next inAlignment bytes.

◆ BitCast()

template<class To , class From >
JPH_INLINE To BitCast ( const From &  inValue)

◆ CenterAngleAroundZero()

float CenterAngleAroundZero ( float  inV)
inline

Convert angle in radians to the range \([-\pi, \pi]\).

◆ Clamp()

template<typename T >
JPH_INLINE constexpr T Clamp ( inV,
inMin,
inMax 
)
constexpr

Clamp a value between two values.

◆ CountBits()

uint CountBits ( uint32  inValue)
inline

Count the number of 1 bits in a value.

◆ CountLeadingZeros()

uint CountLeadingZeros ( uint32  inValue)
inline

Compute the number of leading zero bits (how many high bits are zero)

◆ CountTrailingZeros()

uint CountTrailingZeros ( uint32  inValue)
inline

Compute number of trailing zero bits (how many low bits are zero)

◆ Cubed()

template<typename T >
JPH_INLINE constexpr T Cubed ( inV)
constexpr

Returns \(inV^3\).

◆ DegreesToRadians()

JPH_INLINE constexpr float DegreesToRadians ( float  inV)
constexpr

Convert a value from degrees to radians.

◆ GetNextPowerOf2()

uint32 GetNextPowerOf2 ( uint32  inValue)
inline

Get the next higher power of 2 of a value, or the value itself if the value is already a power of 2.

◆ IsAligned()

template<typename T >
bool IsAligned ( inV,
uint64  inAlignment 
)
inline

Check if inV is inAlignment aligned.

◆ IsPowerOf2()

template<typename T >
constexpr bool IsPowerOf2 ( inV)
constexpr

Check if inV is a power of 2.

◆ RadiansToDegrees()

JPH_INLINE constexpr float RadiansToDegrees ( float  inV)
constexpr

Convert a value from radians to degrees.

◆ Sign()

template<typename T >
JPH_INLINE constexpr T Sign ( inV)
constexpr

Get the sign of a value.

◆ Square()

template<typename T >
JPH_INLINE constexpr T Square ( inV)
constexpr

Square a value.