ezEngine Release 26.3
Loading...
Searching...
No Matches
ezAngleTemplate< Type > Class Template Reference

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

#include <Angle.h>

Public Member Functions

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

Static Public Member Functions

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

Detailed Description

template<typename Type>
class ezAngleTemplate< Type >

Float/double 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()

template<typename Type >
constexpr ezAngleTemplate< Type > ezAngleTemplate< Type >::AngleBetween ( ezAngleTemplate< Type >  a,
ezAngleTemplate< Type >  b 
)
inlinestaticconstexpr

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()

template<typename Type >
ezAngleTemplate< Type > ezAngleTemplate< Type >::GetNormalizedRange ( ) const
inline

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

See also
NormalizeRange()

◆ NormalizeRange()

template<typename Type >
void ezAngleTemplate< Type >::NormalizeRange ( )
inline

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: