kAngle
A kAngle is simply a float that stays within ±π
. Values outside the range aren't simply clamped, but rather converted to an equivalent angle within the range.
This saves you from having to worry about things like equivalent angles offset by multiples of 2π, and the difference between two angles will always be the shorter offset. For example, -0.75π - 0.75π
will return 0.5π
, not -1.5π
.
Constructors
void kAngle( float radians )
initialize to radians
, converted to an equivalent angle within ±π
void kAngle( kAngle& angle )
copy constructor
Methods
float Diff( float angle )
float Diff( kAngle& angle )
returns angle - this
, with the result converted to the range ±π
float Interpolate( float dest, float pct )
linear interpolation – returns an angle a fraction of the way to dest
uses kAngles, so the shortest offset will be used, and the result will be within ±π
Operators
float( kAngle )
cast to float (can be done implicitly)
kAngle + float
kAngle + kAngle
kAngle += float
kAngle += kAngle
kAngle - float
kAngle - kAngle
kAngle -= float
kAngle -= kAngle
ordinary float addition and subtraction, but with the result converted to the range ±π
-kAngle
negation
kAngle = float
kAngle = kAngle
assignment