ezEngine  Release 25.03
ezAngle Class Reference

Float wrapper struct for a safe usage and conversions of angles. More...

#include <Angle.h>

Public Member Functions

 EZ_DECLARE_POD_TYPE ()
 
constexpr ezAngle ()
 Standard constructor, initializing with 0.
 
constexpr float GetDegree () const
 Returns the degree value. (Performs a conversion)
 
constexpr float GetRadian () const
 Returns the radian value. (No need for any conversion)
 
EZ_ALWAYS_INLINE void SetRadian (float fRad)
 Sets the radian value. (No need for any conversion)
 
void NormalizeRange ()
 Brings the angle into the range of 0 degree - 360 degree. More...
 
ezAngle GetNormalizedRange () const
 Returns an equivalent angle with range between 0 degree - 360 degree. More...
 
bool IsEqualSimple (ezAngle rhs, ezAngle epsilon) const
 Equality check with epsilon. Simple check without normalization. 360 degree will equal 0 degree, but 720 will not.
 
bool IsEqualNormalized (ezAngle rhs, ezAngle epsilon) const
 Equality check with epsilon that uses normalized angles. Will recognize 720 degree == 0 degree.
 
constexpr ezAngle operator- () const
 
constexpr ezAngle operator+ (ezAngle r) const
 
constexpr ezAngle operator- (ezAngle r) const
 
void operator+= (ezAngle r)
 
void operator-= (ezAngle r)
 
constexpr bool operator== (const ezAngle &r) const
 
constexpr bool operator!= (const ezAngle &r) const
 
constexpr bool operator< (const ezAngle &r) const
 
constexpr bool operator> (const ezAngle &r) const
 
constexpr bool operator<= (const ezAngle &r) const
 
constexpr bool operator>= (const ezAngle &r) const
 
template<typename Type >
constexpr EZ_ALWAYS_INLINE Type Pi ()
 
template<typename Type >
constexpr EZ_ALWAYS_INLINE Type DegToRadMultiplier ()
 
template<typename Type >
constexpr EZ_ALWAYS_INLINE Type RadToDegMultiplier ()
 
template<typename Type >
constexpr Type DegToRad (Type f)
 
template<typename Type >
constexpr Type RadToDeg (Type f)
 

Static Public Member Functions

template<typename Type >
constexpr static EZ_ALWAYS_INLINE Type DegToRadMultiplier ()
 Returns the constant to multiply with an angle in degree to convert it to radians.
 
template<typename Type >
constexpr static EZ_ALWAYS_INLINE Type RadToDegMultiplier ()
 Returns the constant to multiply with an angle in degree to convert it to radians.
 
template<typename Type >
constexpr static Type DegToRad (Type f)
 Converts an angle in degree to radians.
 
template<typename Type >
constexpr static Type RadToDeg (Type f)
 Converts an angle in radians to degree.
 
constexpr static ezAngle MakeZero ()
 Returns a zero initialized angle. Same as a default constructed object.
 
constexpr static ezAngle MakeFromDegree (float fDegree)
 Creates an instance of ezAngle that was initialized from degree. (Performs a conversion)
 
constexpr static ezAngle MakeFromRadian (float fRadian)
 Creates an instance of ezAngle that was initialized from radian. (No need for any conversion)
 
constexpr static ezAngle AngleBetween (ezAngle a, ezAngle b)
 Computes the smallest angle between the two given angles. The angle will always be a positive value. More...
 

Detailed Description

Float wrapper struct for a safe usage and conversions of angles.

Uses radian internally. Will not automatically keep its range between 0 degree - 360 degree (0 - 2PI) but you can call NormalizeRange to do so.

Member Function Documentation

◆ AngleBetween()

constexpr EZ_FORCE_INLINE ezAngle ezAngle::AngleBetween ( ezAngle  a,
ezAngle  b 
)
staticconstexpr

Computes the smallest angle between the two given angles. The angle will always be a positive value.

Note
The two angles must be in the same range. E.g. they should be either normalized or at least the absolute angle between them should not be more than 180 degree.

◆ GetNormalizedRange()

ezAngle ezAngle::GetNormalizedRange ( ) const
inline

Returns an equivalent angle with range between 0 degree - 360 degree.

See also
NormalizeRange()

◆ NormalizeRange()

void ezAngle::NormalizeRange ( )

Brings the angle into the range of 0 degree - 360 degree.

See also
GetNormalizedRange()

The documentation for this class was generated from the following files: