13 #ifndef OGLPLUS_MATH_ANGLE_1107121519_HPP
14 #define OGLPLUS_MATH_ANGLE_1107121519_HPP
16 #include <oglplus/config/compiler.hpp>
20 #include <type_traits>
56 : _val_rad(
T(val_deg * (math::Pi() /
T(180))))
64 #if !OGLPLUS_NO_DEFAULTED_FUNCTIONS || OGLPLUS_DOCUMENTATION_ONLY
77 : _val_rad(
T(other.
Value()))
83 return Angle(val_rad, Radians_());
89 return Angle(val_deg, Degrees_());
95 assert(-1.0f <= x && x <= 1.0f);
96 return Angle(::std::asin(x), Radians_());
102 assert(-1.0f <= x && x <= 1.0f);
103 return Angle(::std::acos(x), Radians_());
115 return _val_rad *
T(180 / math::Pi());
121 return _val_rad *
T(2.0 / math::Pi());
127 return _val_rad *
T(0.5 / math::Pi());
133 return a._val_rad == b._val_rad;
139 return a._val_rad != b._val_rad;
145 return a._val_rad < b._val_rad;
151 return a._val_rad > b._val_rad;
157 return a._val_rad <= b._val_rad;
163 return a._val_rad >= b._val_rad;
166 #if OGLPLUS_DOCUMENTATION_ONLY
174 return Angle(-this->_val_rad, Radians_());
180 return angle.Negated();
183 #if OGLPLUS_DOCUMENTATION_ONLY
190 return Angle(a._val_rad + b._val_rad, Radians_());
202 *
this =
Add(*
this, b);
206 #if OGLPLUS_DOCUMENTATION_ONLY
213 return Angle(a._val_rad - b._val_rad, Radians_());
219 return Subtracted(a, b);
225 *
this = Subtracted(*
this, b);
229 #if OGLPLUS_DOCUMENTATION_ONLY
236 return Angle(a._val_rad * mult, Radians_());
242 return Multiplied(a, mult);
248 return Multiplied(a, mult);
254 *
this = Multiplied(*
this, mult);
258 #if OGLPLUS_DOCUMENTATION_ONLY
266 return Angle(a._val_rad / div, Radians_());
272 return Divided(a, div);
278 *
this = Divided(*
this, div);
282 #if OGLPLUS_DOCUMENTATION_ONLY
289 assert(b._val_rad !=
T(0));
290 return a._val_rad / b._val_rad;
299 #if OGLPLUS_DOCUMENTATION_ONLY
307 return ::std::sin(this->_val_rad);
310 #if OGLPLUS_DOCUMENTATION_ONLY
318 return ::std::cos(this->_val_rad);
321 #if OGLPLUS_DOCUMENTATION_ONLY
329 return ::std::tan(this->_val_rad);
333 template <
typename T>
339 template <
typename T>
345 template <
typename T>
351 template <
typename T>
357 template <
typename T>
363 template <
typename T>
369 template <
typename T>
375 template <
typename T>
376 inline T Degrees(
const Angle<T>& a)
378 return a.ValueInDegrees();
381 template <
typename T>
387 template <
typename T>
393 template <
typename T>
399 #if OGLPLUS_DOCUMENTATION_ONLY || defined(GL_FLOAT)
403 typedef GLfloat AngleValueType;
404 #elif defined(AL_VERSION_1_1)
405 typedef ALfloat AngleValueType;
407 typedef double AngleValueType;
483 AngleValueType(value * math::TwoPi())
487 inline Angle<AngleValueType> FullCircle(
void)
518 AngleValueType(value * math::HalfPi())
522 inline Angle<AngleValueType> RightAngle(
void)
618 template <
typename T>
621 return ::std::sin(T(math::TwoPi() * t));
645 template <
typename T>
672 template <
typename T>
675 return ::std::cos(T(math::TwoPi() * t));
699 template <
typename T>
707 #endif // include guard
Angle & operator+=(const Angle &b)
Addition operator.
Definition: angle.hpp:200
T Value(void) const
Returns the value of the angle in radians.
Definition: angle.hpp:107
Class implementing planar angle-related functionality.
Definition: fwd.hpp:24
Angle Negated(void) const
Negation.
Definition: angle.hpp:172
T ValueInDegrees(void) const
Returns the value of the angle in degrees.
Definition: angle.hpp:113
Angle & operator-=(const Angle &b)
Subtraction operator.
Definition: angle.hpp:223
friend Angle operator/(const Angle &a, T div)
Division by constant operator.
Definition: angle.hpp:270
friend Angle Multiply(const Angle &a, T mult)
Multiplication by constant.
Definition: angle.hpp:352
T SineWave(T t)
Returns a value on a sine wave at the specified point.
Definition: angle.hpp:619
friend Angle operator+(const Angle &a, const Angle &b)
Addition operator.
Definition: angle.hpp:194
friend Angle Subtract(const Angle &a, const Angle &b)
Subtraction.
Definition: angle.hpp:346
Angle & operator*=(T mult)
Multiplication by constant operator.
Definition: angle.hpp:252
static Angle ArcSin(T x)
Constructs a new angle using arc sine.
Definition: angle.hpp:93
friend Angle Add(const Angle &a, const Angle &b)
Addition.
Definition: angle.hpp:340
friend bool operator>=(const Angle &a, const Angle &b)
Greater than/equal comparison.
Definition: angle.hpp:161
Angle< GLfloat > Anglef
Instantiation of Angle using GL floating-point as underlying type.
Definition: angle.hpp:401
Angle(void)
Constructs a zero angle.
Definition: angle.hpp:60
friend bool operator!=(const Angle &a, const Angle &b)
Inequality comparison.
Definition: angle.hpp:137
friend bool operator<=(const Angle &a, const Angle &b)
Less than/equal comparison.
Definition: angle.hpp:155
T CosineWave01(T t)
Returns a value on a cosine wave transformed to range <0, 1>
Definition: angle.hpp:700
Angle< AngleValueType > ArcCos(AngleValueType x)
Creates a new angle using the arc cosine function.
Definition: angle.hpp:558
T ValueInFullCircles(void) const
Returns the value of the angle in number of full circles.
Definition: angle.hpp:125
Angle & operator/=(T div)
Division by constant operator.
Definition: angle.hpp:276
friend T Ratio(const Angle &a, const Angle &b)
Angle ratio.
Definition: angle.hpp:364
static Angle ArcCos(T x)
Constructs a new angle using arc cosine.
Definition: angle.hpp:100
static Angle Radians(T val_rad)
Constructs a new angle from value in radians.
Definition: angle.hpp:81
friend bool operator>(const Angle &a, const Angle &b)
Greater than comparison.
Definition: angle.hpp:149
friend bool operator<(const Angle &a, const Angle &b)
Less than comparison.
Definition: angle.hpp:143
static Angle Degrees(T val_deg)
Constructs a new angle from value in degrees.
Definition: angle.hpp:87
T Tan(void) const
Returns the tangent of the angle.
Definition: angle.hpp:327
T CosineWave(T t)
Returns a value on a cosine wave at the specified point.
Definition: angle.hpp:673
T SineWave01(T t)
Returns a value on a sine wave transformed to range <0, 1>
Definition: angle.hpp:646
Angle< AngleValueType > RightAngles(AngleValueType value)
Creates a new angle from a value in "right angles" (i.e. 90 deg.)
Definition: angle.hpp:515
T Sin(void) const
Returns the sine of the angle.
Definition: angle.hpp:305
friend Angle Divide(const Angle &a, T div)
Division by constant.
Definition: angle.hpp:358
friend Angle operator*(const Angle &a, T mult)
Multiplication by constant operator.
Definition: angle.hpp:240
friend Angle operator-(const Angle &angle)
Negation operator.
Definition: angle.hpp:178
Angle< AngleValueType > ArcTan(AngleValueType x)
Creates a new angle using the arc tangent function.
Definition: angle.hpp:575
friend Angle Negate(const Angle &angle)
Negation.
Definition: angle.hpp:334
Angle< AngleValueType > ArcSin(AngleValueType x)
Creates a new angle using the arc sine function.
Definition: angle.hpp:540
friend bool operator==(const Angle &a, const Angle &b)
Equality comparison.
Definition: angle.hpp:131
Angle< AngleValueType > FullCircles(AngleValueType value)
Creates a new angle from a value in "full circles" (i.e. 360 degrees)
Definition: angle.hpp:480
T ValueInRightAngles(void) const
Returns the value of the angle in number of right angles.
Definition: angle.hpp:119
T Cos(void) const
Returns the cosine of the angle.
Definition: angle.hpp:316
Angle(const Angle< U > &other)
Copy construction from angles using different underlying type.
Definition: angle.hpp:76