License Public Domain
Lines 41
Keywords
angle (3) degree (3) radian (3)
Included in this Library
Permissions
Viewable by Everyone
Editable by All Siafoo Users
Hide
Know what you're getting – Unlike many sites, all our code is clearly licensed. Join Siafoo Now or Learn More

angle.cpp Atom Feed -1

In Brief Functions that implement the Angle class in angle.h
# 's
 1#include "angle.h"
2
3/// Untwists an angle (in radians) to range [0, 2*Pi)
4double Angle::Clamp0To2Pi() const
5{
6 double angle = m_radians;
7 while(angle >= TWOPI)
8 angle -= TWOPI;
9
10 while(angle < 0)
11 angle += TWOPI;
12
13 return angle;
14}
15
16/// Untwists an angle (in radians) to range [-Pi, Pi]
17double Angle::ClampNegPiToPi() const
18{
19 double angle = m_radians;
20 while(angle > PI)
21 angle -= TWOPI;
22
23 while(angle < -PI)
24 angle += TWOPI;
25
26 return angle;
27}
28
29/// Untwists an angle (in degrees) to range [0, 360]
30double Angle::Clamp0To360() const
31{
32 double angle = radians2Degrees(m_radians);
33 while(angle >= 360)
34 angle -= 360;
35
36 while(angle < 0)
37 angle += 360;
38
39 return angle;
40}
41
42double Angle::degrees2Radians(double angle_degrees)
43{
44 return angle_degrees * PI / 180;
45}
46
47double Angle::radians2Degrees( double angle_radians )
48{
49 return angle_radians * 180 / PI;
50}

Functions that implement the Angle class in angle.h