Angles

In cerlib, angles are expressed by concrete types cer::Radians and cer::Degrees. Compared to using float for angles, these provide a layer of type-safety and show intent.

A Radians value can be converted to a Degrees and vice versa.

Example
auto r1 = Radians();      // 0 radians
auto r2 = Radians(pi);    // PI radians, i.e. 180 degrees

auto d1 = Degrees();      // 0 degrees
auto d2 = Degrees(45.0f); // 45 degrees

auto degPi = Degrees(r2); // 180 degrees
auto rad45 = Radians(d2); // PI/4

User-defined literals

cerlib provides an alternative, simpler way to create Radians and Degrees by using user-defined literals.

auto v1 = 0.0_rad;          // Same as Radians(0.0f)
auto v2 = 1.5_rad;          // Same as Radians(1.5f)
auto v3 = 45.0_deg;         // Same as Degrees(45.0f)
auto v4 = Degrees(2.0_rad); // Same as Degrees(Radians(2.0f))