Game Development Reference
In-Depth Information
1.3R OTATION
When talking about rotations, we usually think about angles in degrees, it's intuitive to say
that we'll rotate an object by 45 degrees, we can visualize this. In reality, most angular op-
erations are performed in radians, you should only use degrees as user input, this is simpler
for the person that is entering the data, but internally you should always perform angular
calculationsinradians.Ifyoudecidetoignorethisadviceandworkindegrees,youwillfind
that you will end up with many unnecessary calls to functions that convert from degrees to
radians and vice-versa.
constexpr float DegreesToRadians(float degrees)
{
return degrees * ( 180.f / Pi );
}
constexpr float RadiansToDegrees(float radians)
{
return radians * ( Pi / 180.f );
}
We can use C++11's constexpr keyword to perform the evaluation of the calculation to
compile-time, at least for the calls in which the compiler receives a constant value as input.
Otherwise, it will perform the calculation at runtime as expected.
Search WWH ::




Custom Search