Plasma Engine  2.0
Loading...
Searching...
No Matches
plAngle Class Reference

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

#include <Angle.h>

Public Member Functions

 PL_DECLARE_POD_TYPE ()
 
constexpr plAngle ()
 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)
 
PL_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.
 
plAngle GetNormalizedRange () const
 Returns an equivalent angle with range between 0 degree - 360 degree.
 
bool IsEqualSimple (plAngle rhs, plAngle epsilon) const
 Equality check with epsilon. Simple check without normalization. 360 degree will equal 0 degree, but 720 will not.
 
bool IsEqualNormalized (plAngle rhs, plAngle epsilon) const
 Equality check with epsilon that uses normalized angles. Will recognize 720 degree == 0 degree.
 
constexpr plAngle operator- () const
 
constexpr plAngle operator+ (plAngle r) const
 
constexpr plAngle operator- (plAngle r) const
 
void operator+= (plAngle r)
 
void operator-= (plAngle r)
 
constexpr bool operator== (const plAngle &r) const
 
constexpr bool operator!= (const plAngle &r) const
 
constexpr bool operator< (const plAngle &r) const
 
constexpr bool operator> (const plAngle &r) const
 
constexpr bool operator<= (const plAngle &r) const
 
constexpr bool operator>= (const plAngle &r) const
 
template<typename Type >
constexpr PL_ALWAYS_INLINE Type Pi ()
 

Static Public Member Functions

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

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

PL_FORCE_INLINE plAngle plAngle::AngleBetween ( plAngle a,
plAngle 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()

plAngle plAngle::GetNormalizedRange ( ) const
inline

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

See also
NormalizeRange()

◆ NormalizeRange()

void plAngle::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: