Motive Animation System
An open source project by FPL.
 All Classes Functions Variables Typedefs Friends Pages
angle.h
1 // Copyright 2014 Google Inc. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef MOTIVE_MATH_ANGLE_H_
16 #define MOTIVE_MATH_ANGLE_H_
17 
18 #include <assert.h>
19 #include <math.h>
20 
21 #include "mathfu/constants.h"
22 #include "mathfu/matrix.h"
23 #include "mathfu/vector.h"
24 #include "mathfu/glsl_mappings.h"
25 
26 #ifdef FPL_ANGLE_UNIT_TESTS
27 #include "gtest/gtest.h"
28 #endif // FPL_ANGLE_UNIT_TESTS
29 
30 namespace motive {
31 
32 
33 /// Describe a conversion from `Angle` to a 3D vector.
34 /// Sweep from the first axis towards the second axis.
35 /// For example, for kAngleToVectorXY,
36 /// angle = 0 degrees ==> x-axis (1, 0, 0)
37 /// angle = 90 degrees ==> y-axis (0, 1, 0)
38 /// angle = 180 degrees ==> negative x-axis (-1, 0, 0)
39 /// angle = 90 degrees ==> negative y-axis (0, -1, 0)
40 /// Note that we don't have to worry about handedness. No matter the handedness
41 /// of the coordinate system, we always sweep from one axis towards the other.
42 /// That is, the other axis is always at 90 degrees, never -90.
43 enum AngleToVectorSystem {
44  kAngleToVectorXY,
45  kAngleToVectorXZ,
46  kAngleToVectorYZ,
47  kAngleToVectorYX,
48  kAngleToVectorZX,
49  kAngleToVectorZY,
50  kAngleToVectorCount
51 };
52 
53 static const float kPi = static_cast<float>(M_PI);
54 static const float kTwoPi = static_cast<float>(2.0 * M_PI);
55 static const float kThreePi = static_cast<float>(3.0 * M_PI);
56 static const float kHalfPi = static_cast<float>(M_PI_2);
57 static const float kQuarterPi = static_cast<float>(0.5 * M_PI_2);
58 static const float kDegreesToRadians = static_cast<float>(M_PI / 180.0);
59 static const float kRadiansToDegrees = static_cast<float>(180.0 / M_PI);
60 static const float kMaxUniqueAngle = kPi;
61 static const float kDegreesPerCircle = 360.0f;
62 
63 // The biggest floating point number > -pi.
64 // That is, there are no floats x s.t. -pi < x < kMinUniqueAngle.
65 //
66 // Useful for clamping to the valid angle range:
67 // [kMinUniqueAngle,kMaxUniqueAngle] == (-pi, pi]
68 // Note: "[" indicates an inclusive bound; "(" indicates exclusive.
69 //
70 // In general, after modding, we should clamp to the valid range.
71 // Floating point precision errors can generate numbers outside of
72 // (-pi, pi], even when the math is perfect.
73 static const float kMinUniqueAngle = -3.1415925f;
74 
75 /// @class Angle
76 /// @brief Represent an angle in radians, uniquely in the range (-pi, pi].
77 ///
78 /// We include pi in the range, but exclude -pi, because pi and -pi
79 /// are equivalent mod 2pi.
80 ///
81 /// Equivalence is key to this class. We want only one representation
82 /// of every equivalent angle. For example, 0 and 2pi are both represented
83 /// as 0, internally. This unique representation allows for comparison and
84 /// precise arithmetic.
85 ///
86 /// All operators keep the angle values in the valid range.
87 ///
88 /// Why use instead of Quaternions?
89 /// -------------------------------
90 /// Quaternions are great for three dimensional rotations, but for many
91 /// applications you only have two dimensional rotations. Instead of the
92 /// four floats and heavy operations required by quaternions, an angle
93 /// can represent the rotation in one float and reasonably light operations.
94 /// Angles are easier to do trigonometry on. Also, they're conceptually
95 /// simpler.
96 ///
97 class Angle {
98  public:
99  Angle() : angle_(0.0f) {}
100 
101  /// Create from `angle`, which is already in the valid range (-pi,pi].
102  /// If your angle is outside that range, construct the Angle with the
103  /// slower FromRadians function to automatically wrap it.
104  /// @param angle radians in the range (-pi,pi] -- i.e. exclusive of -pi but
105  /// inclusive of +pi.
106  explicit Angle(float angle) : angle_(angle) { assert(IsValid()); }
107 
108  /// Returns the absolute value of an angle.
109  Angle Abs() const { return Angle(fabs(angle_)); }
110 
111  Angle& operator=(const Angle& rhs) {
112  angle_ = rhs.angle_;
113  return *this;
114  }
115 
116  /// Add `rhs` and ensure result is in the range (-pi,pi].
117  Angle& operator+=(const Angle& rhs) {
118  angle_ = ModWithinThreePi(angle_ + rhs.angle_);
119  return *this;
120  }
121 
122  /// Subtract `rhs` and ensure result is in the range (-pi,pi].
123  Angle& operator-=(const Angle& rhs) {
124  angle_ = ModWithinThreePi(angle_ - rhs.angle_);
125  return *this;
126  }
127 
128  /// Multiply `rhs` and ensure result is in the normalized range (-pi,pi].
129  Angle& operator*=(const float rhs) {
130  angle_ = WrapAngle(angle_ * rhs);
131  return *this;
132  }
133 
134  /// Divide `rhs` and ensure result is in the normalized range (-pi,pi].
135  Angle& operator/=(const float rhs) {
136  angle_ = WrapAngle(angle_ / rhs);
137  return *this;
138  }
139 
140  /// Negate the angle and ensure result is in the normalized range (-pi,pi].
141  Angle operator-() const { return Angle(ModIfNegativePi(-angle_)); }
142 
143  /// Return the angle value in radians. Value is in the range (-pi,pi].
144  float ToRadians() const { return angle_; }
145 
146  /// Return the angle value in degrees. Value is in the range (-180,180].
147  float ToDegrees() const { return kRadiansToDegrees * angle_; }
148 
149  /// Returns a point on the unit circle corresponding to a sweep of `angle`
150  /// across the specified vector system.
151  mathfu::vec3 ToVectorSystem(const AngleToVectorSystem system) const {
152  switch(system) {
153  case kAngleToVectorXY: return ToXYVector();
154  case kAngleToVectorXZ: return ToXZVector();
155  case kAngleToVectorYZ: return ToYZVector();
156  case kAngleToVectorYX: return ToYXVector();
157  case kAngleToVectorZX: return ToZXVector();
158  case kAngleToVectorZY: return ToZYVector();
159  default: assert(false);
160  }
161  return mathfu::kZeros3f;
162  }
163 
164  /// Returns a point on unit circle corresponding to a sweep of `angle`
165  /// degrees from the x-axis towards the y-axis.
166  /// 0 ==> ( 1, 0, 0)
167  /// pi/2 ==> ( 0, 1, 0)
168  /// pi ==> (-1, 0, 0)
169  /// 3pi/2 ==> ( 0, -1, 0)
170  mathfu::vec3 ToXYVector() const {
171  float x, y;
172  ToVector(&x, &y);
173  return mathfu::vec3(x, y, 0.0f);
174  }
175 
176  /// Returns a point on unit circle corresponding to a sweep of `angle`
177  /// degrees from the x-axis towards the y-axis.
178  /// 0 ==> ( 1, 0 )
179  /// pi/2 ==> ( 0, 1 )
180  /// pi ==> (-1, 0 )
181  /// 3pi/2 ==> ( 0, -1 )
182  mathfu::vec2 ToXYVector2f() const {
183  mathfu::vec2 r;
184  ToVector(&r.x, &r.y);
185  return r;
186  }
187 
188  /// Returns a point on unit circle corresponding to a sweep of `angle`
189  /// degrees from the x-axis towards the z-axis.
190  /// 0 ==> ( 1, 0, 0)
191  /// pi/2 ==> ( 0, 0, 1)
192  /// pi ==> (-1, 0, 0)
193  /// 3pi/2 ==> ( 0, 0, -1)
194  mathfu::vec3 ToXZVector() const {
195  float x, z;
196  ToVector(&x, &z);
197  return mathfu::vec3(x, 0.0f, z);
198  }
199 
200  /// Returns a point on unit circle corresponding to a sweep of `angle`
201  /// degrees from the y-axis towards the z-axis.
202  /// 0 ==> (0, 1, 0)
203  /// pi/2 ==> (0, 0, 1)
204  /// pi ==> (0, -1, 0)
205  /// 3pi/2 ==> (0, 0, -1)
206  mathfu::vec3 ToYZVector() const {
207  float y, z;
208  ToVector(&y, &z);
209  return mathfu::vec3(0.0f, y, z);
210  }
211 
212  /// Returns a point on unit circle corresponding to a sweep of `angle`
213  /// degrees from the y-axis towards the x-axis.
214  /// 0 ==> ( 0, 1, 0)
215  /// pi/2 ==> ( 1, 0, 0)
216  /// pi ==> ( 0, -1, 0)
217  /// 3pi/2 ==> (-1, 0, 0)
218  mathfu::vec3 ToYXVector() const {
219  float x, y;
220  ToVector(&y, &x);
221  return mathfu::vec3(x, y, 0.0f);
222  }
223 
224  /// Returns a point on unit circle corresponding to a sweep of `angle`
225  /// degrees from the y-axis towards the x-axis.
226  /// 0 ==> ( 0, 1 )
227  /// pi/2 ==> ( 1, 0 )
228  /// pi ==> ( 0, -1 )
229  /// 3pi/2 ==> (-1, 0 )
230  mathfu::vec2 ToYXVector2f() const {
231  mathfu::vec2 r;
232  ToVector(&r.y, &r.x);
233  return r;
234  }
235 
236  /// Returns a point on unit circle corresponding to a sweep of `angle`
237  /// degrees from the z-axis towards the x-axis.
238  /// 0 ==> ( 0, 0, 1)
239  /// pi/2 ==> ( 1, 0, 0)
240  /// pi ==> ( 0, 0, -1)
241  /// 3pi/2 ==> (-1, 0, 0)
242  mathfu::vec3 ToZXVector() const {
243  float x, z;
244  ToVector(&z, &x);
245  return mathfu::vec3(x, 0.0f, z);
246  }
247 
248  /// Returns a point on unit circle corresponding to a sweep of `angle`
249  /// degrees from the z-axis towards the y-axis.
250  /// 0 ==> (0, 0, 1)
251  /// pi/2 ==> (0, 1, 0)
252  /// pi ==> (0, 0, -1)
253  /// 3pi/2 ==> (0, -1, 0)
254  mathfu::vec3 ToZYVector() const {
255  float y, z;
256  ToVector(&z, &y);
257  return mathfu::vec3(0.0f, y, z);
258  }
259 
260  /// Returns a point on the unit circle corresponding to a sweep of `angle`
261  /// across the specified vector system.
262  mathfu::mat3 ToRotationMatrix(const AngleToVectorSystem system) const {
263  switch(system) {
264  case kAngleToVectorXY: return ToXYRotationMatrix();
265  case kAngleToVectorXZ: return ToXZRotationMatrix();
266  case kAngleToVectorYZ: return ToYZRotationMatrix();
267  case kAngleToVectorYX: return ToYXRotationMatrix();
268  case kAngleToVectorZX: return ToZXRotationMatrix();
269  case kAngleToVectorZY: return ToZYRotationMatrix();
270  default: assert(false);
271  }
272  return mathfu::mat3();
273  }
274 
275  /// Returns a matrix that rotates about the Z axis `angle` radians.
276  mathfu::mat3 ToXYRotationMatrix() const {
277  float x, y;
278  ToVector(&x, &y);
279  return mathfu::mat3(x, y, 0.0f, -y, x, 0.0f, 0.0f, 0.0f, 1.0f);
280  }
281 
282  /// Returns a matrix that rotates about the Y axis `angle` radians.
283  mathfu::mat3 ToXZRotationMatrix() const {
284  float x, z;
285  ToVector(&x, &z);
286  return mathfu::mat3(x, 0.0f, z, 0.0f, 1.0f, 0.0f, -z, 0.0f, x);
287  }
288 
289  /// Returns a matrix that rotates about the X axis `angle` radians.
290  mathfu::mat3 ToYZRotationMatrix() const {
291  float y, z;
292  ToVector(&y, &z);
293  return mathfu::mat3(1.0f, 0.0f, 0.0f, 0.0f, y, z, 0.0f, -z, y);
294  }
295 
296  /// Returns a matrix that rotates about the Z axis `-angle` radians.
297  mathfu::mat3 ToYXRotationMatrix() const {
298  return operator-().ToXYRotationMatrix();
299  }
300 
301  /// Returns a matrix that rotates about the Y axis `-angle` radians.
302  mathfu::mat3 ToZXRotationMatrix() const {
303  return operator-().ToXZRotationMatrix();
304  }
305 
306  /// Returns a matrix that rotates about the X axis `-angle` radians.
307  mathfu::mat3 ToZYRotationMatrix() const {
308  return operator-().ToYZRotationMatrix();
309  }
310 
311  /// Check internal consistency. If class is functioning correctly, should
312  /// always return true.
313  bool IsValid() const { return IsAngleInRange(angle_); }
314 
315  /// Clamps the angle to the range [center - max_diff, center + max_diff].
316  /// max_diff must be in the range [0~pi].
317  Angle Clamp(const Angle& center, const Angle& max_diff) const;
318 
319  /// Wraps an angle to the range (-pi, pi].
320  /// This function is slow because it has a division. When possible, use
321  /// FromWithinThreePi instead.
322  static float WrapAngle(float angle) {
323  angle -= (floor(angle / kTwoPi) + 1.0f) * kTwoPi;
324  if (angle <= -kPi) {
325  angle += kTwoPi;
326  }
327  return angle;
328  }
329 
330  /// Create from `angle`, in radians, which is in the range (-3pi,3pi].
331  /// This function is significantly faster than WrapAngle since it avoids
332  /// division. It's also more precise for the same reason. The range may seem
333  /// strange at first glance; it's a consequence of the implementation. Just
334  /// know that any two sums of normalized angles will still be in the range
335  /// (-3pi,3pi].
336  static Angle FromWithinThreePi(const float angle) {
337  return Angle(ModWithinThreePi(angle));
338  }
339 
340  /// Create from `radians`, which is converted to the range (-pi, pi].
341  static Angle FromRadians(const float radians) {
342  return Angle(WrapAngle(radians));
343  }
344 
345  /// Create from `degrees`, which is converted to the range (-pi, pi].
346  static Angle FromDegrees(const float degrees) {
347  return FromRadians(degrees * kDegreesToRadians);
348  }
349 
350  /// Returns a point on the unit circle corresponding to a sweep of `angle`
351  /// across the specified vector system.
352  static Angle FromVectorSystem(const mathfu::vec3& v,
353  const AngleToVectorSystem system) {
354  switch(system) {
355  case kAngleToVectorXY: return FromXYVector(v);
356  case kAngleToVectorXZ: return FromXZVector(v);
357  case kAngleToVectorYZ: return FromYZVector(v);
358  case kAngleToVectorYX: return FromYXVector(v);
359  case kAngleToVectorZX: return FromZXVector(v);
360  case kAngleToVectorZY: return FromZYVector(v);
361  default: assert(false);
362  }
363  return Angle(0.0f);
364  }
365 
366  /// Create from the x,y coordinates of a vector, using the system
367  /// described in ToXYVector().
368  static Angle FromXYVector(const mathfu::vec3& v) {
369  return Angle(ModIfNegativePi(atan2f(v[1], v[0])));
370  }
371 
372  /// Create from the x,z coordinates of a vector, using the system
373  /// described in ToXZVector().
374  static Angle FromXZVector(const mathfu::vec3& v) {
375  return Angle(ModIfNegativePi(atan2f(v[2], v[0])));
376  }
377 
378  /// Create from the y,z coordinates of a vector, using the system
379  /// described in ToYZVector().
380  static Angle FromYZVector(const mathfu::vec3& v) {
381  return Angle(ModIfNegativePi(atan2f(v[2], v[1])));
382  }
383 
384  /// Create from the y,x coordinates of a vector, using the system
385  /// described in ToYXVector().
386  static Angle FromYXVector(const mathfu::vec3& v) {
387  return Angle(ModIfNegativePi(atan2f(v[0], v[1])));
388  }
389 
390  /// Create from the z,x coordinates of a vector, using the system
391  /// described in ToZXVector().
392  static Angle FromZXVector(const mathfu::vec3& v) {
393  return Angle(ModIfNegativePi(atan2f(v[0], v[2])));
394  }
395 
396  /// Create from the z,y coordinates of a vector, using the system
397  /// described in ToZYVector().
398  static Angle FromZYVector(const mathfu::vec3& v) {
399  return Angle(ModIfNegativePi(atan2f(v[1], v[2])));
400  }
401 
402  /// Return true if 'angle' is within the valid range (-pi,pi], that is,
403  /// the range inclusive of +pi but exclusive of -pi.
404  static bool IsAngleInRange(const float angle) {
405  return kMinUniqueAngle <= angle && angle <= kMaxUniqueAngle;
406  }
407 
408  private:
409  friend bool operator==(const Angle& a, const Angle& b);
410  friend bool operator<(const Angle& a, const Angle& b);
411  friend bool operator<=(const Angle& a, const Angle& b);
412 
413 #ifdef FPL_ANGLE_UNIT_TESTS
414  FRIEND_TEST(AngleTests, ModWithinThreePi);
415  FRIEND_TEST(AngleTests, ModIfNegativePi);
416 #endif // FPL_ANGLE_UNIT_TESTS
417 
418  /// Convert the angle into a 2D unit vector of the form
419  /// (`zero_axis`, `ninety_axis`).
420  /// When angle is 0 degrees, returns (1, 0), hence the name `zero_axis`.
421  /// When angle is 90 degrees, returns (0, 1), hence the name `ninety_axis`.
422  /// When angle is 180 degrees, returns (-1, 0).
423  /// When angle is -90 degrees, returns (0, -1).
424  void ToVector(float* const zero_axis, float* const ninety_axis) const {
425  // TODO OPT: Call single function that calculates both cos and sin.
426  *zero_axis = cos(angle_);
427  *ninety_axis = sin(angle_);
428  }
429 
430  // Take 'angle' in the range (-3pi,3pi] and return an equivalent angle in
431  // the range (-pi,pi]. Note that angles are equivalent if they differ by 2pi.
432  static float ModWithinThreePi(const float angle) {
433  assert(-kThreePi < angle && angle < kThreePi);
434  // These ternary operators should be converted into select statements by
435  // the compiler.
436  const float above = angle < kMinUniqueAngle ? angle + kTwoPi : angle;
437  const float below = above > kMaxUniqueAngle ? above - kTwoPi : above;
438  assert(IsAngleInRange(below));
439  return below;
440  }
441 
442  static float ModIfNegativePi(const float angle) {
443  // Pi negates to -pi, which is outside the range so becomes +pi again.
444  return angle < kMinUniqueAngle ? kMaxUniqueAngle : angle;
445  }
446 
447  float angle_; // Angle in radians, in range (-pi, pi]
448 };
449 
450 inline Angle operator+(Angle lhs, const Angle& rhs) {
451  lhs += rhs;
452  return lhs;
453 }
454 
455 inline Angle operator-(Angle lhs, const Angle& rhs) {
456  lhs -= rhs;
457  return lhs;
458 }
459 
460 inline Angle operator*(Angle lhs, float rhs) {
461  lhs *= rhs;
462  return lhs;
463 }
464 
465 inline Angle operator/(Angle lhs, float rhs) {
466  lhs /= rhs;
467  return lhs;
468 }
469 
470 inline bool operator==(const Angle& a, const Angle& b) {
471  return a.angle_ == b.angle_;
472 }
473 
474 inline bool operator!=(const Angle& a, const Angle& b) {
475  return !operator==(a, b);
476 }
477 
478 inline bool operator<(const Angle& a, const Angle& b) {
479  return a.angle_ < b.angle_;
480 }
481 
482 inline bool operator>=(const Angle& a, const Angle& b) {
483  return !operator<(a, b);
484 }
485 
486 inline bool operator<=(const Angle& a, const Angle& b) {
487  return a.angle_ <= b.angle_;
488 }
489 
490 inline bool operator>(const Angle& a, const Angle& b) {
491  return !operator<=(a, b);
492 }
493 
494 inline Angle Angle::Clamp(const Angle& center, const Angle& max_diff) const {
495  assert(0 <= max_diff.angle_ && max_diff.angle_ <= kPi);
496 
497  // Get difference from 'center'. We know this will be a value in the range
498  // (-pi, pi].
499  const Angle diff = (*this) - center;
500 
501  // Clamp the difference to the valid range.
502  const Angle diff_clamped(
503  mathfu::Clamp(diff.angle_, -max_diff.angle_, max_diff.angle_));
504 
505  // Add the difference onto the center. Note that, if no clamping happened,
506  // we're left with *this.
507  return center + diff_clamped;
508 }
509 
510 /// @brief Returns the axis about which the angles are calculated.
511 ///
512 /// For example, for an XY angle-to-vector system, returns the positive Z-axis.
513 /// For the XY system, angle 0 is the X-axis, angle 90 is the Y-axis, so the
514 /// "up" vector is the Z-axis, positive since we use a right-hand system.
515 const mathfu::vec3& VectorSystemUp(const AngleToVectorSystem system);
516 
517 /// @brief Convert from a geographic coordinate system to a point on the unit
518 /// sphere.
519 /// @param latitude angle between -pi/2 to pi/2, where 0 is the equator,
520 /// pi/2 is the north pole, and -pi/2 is the south pole.
521 /// The polar axis is given by `UpVector(system)`
522 /// @param longitude angle about the polar axis. Angle zero coresponds to the
523 /// definition of `system`.
524 /// @param system Define the polar axis, and the zero and 90 longitudinal
525 /// values.
526 mathfu::vec3 LatitudeAndLongitudeToUnitSphere(const Angle& latitude,
527  const Angle& longitude,
528  AngleToVectorSystem system);
529 
530 } // namespace motive
531 
532 #endif // MOTIVE_MATH_ANGLE_H_
mathfu::vec2 ToXYVector2f() const
Definition: angle.h:182
Angle(float angle)
Definition: angle.h:106
Angle & operator*=(const float rhs)
Multiply rhs and ensure result is in the normalized range (-pi,pi].
Definition: angle.h:129
static Angle FromYXVector(const mathfu::vec3 &v)
Definition: angle.h:386
static Angle FromXYVector(const mathfu::vec3 &v)
Definition: angle.h:368
Angle operator-() const
Negate the angle and ensure result is in the normalized range (-pi,pi].
Definition: angle.h:141
float ToDegrees() const
Return the angle value in degrees. Value is in the range (-180,180].
Definition: angle.h:147
mathfu::vec3 ToVectorSystem(const AngleToVectorSystem system) const
Definition: angle.h:151
mathfu::vec3 ToXYVector() const
Definition: angle.h:170
Angle & operator/=(const float rhs)
Divide rhs and ensure result is in the normalized range (-pi,pi].
Definition: angle.h:135
mathfu::vec3 ToZXVector() const
Definition: angle.h:242
static Angle FromZXVector(const mathfu::vec3 &v)
Definition: angle.h:392
Angle Clamp(const Angle &center, const Angle &max_diff) const
Definition: angle.h:494
static Angle FromDegrees(const float degrees)
Create from degrees, which is converted to the range (-pi, pi].
Definition: angle.h:346
Angle & operator+=(const Angle &rhs)
Add rhs and ensure result is in the range (-pi,pi].
Definition: angle.h:117
mathfu::mat3 ToZYRotationMatrix() const
Returns a matrix that rotates about the X axis -angle radians.
Definition: angle.h:307
bool IsValid() const
Definition: angle.h:313
static Angle FromRadians(const float radians)
Create from radians, which is converted to the range (-pi, pi].
Definition: angle.h:341
mathfu::vec2 ToYXVector2f() const
Definition: angle.h:230
static Angle FromXZVector(const mathfu::vec3 &v)
Definition: angle.h:374
Represent an angle in radians, uniquely in the range (-pi, pi].
Definition: angle.h:97
mathfu::mat3 ToRotationMatrix(const AngleToVectorSystem system) const
Definition: angle.h:262
Angle Abs() const
Returns the absolute value of an angle.
Definition: angle.h:109
mathfu::vec3 ToXZVector() const
Definition: angle.h:194
static Angle FromZYVector(const mathfu::vec3 &v)
Definition: angle.h:398
Angle & operator-=(const Angle &rhs)
Subtract rhs and ensure result is in the range (-pi,pi].
Definition: angle.h:123
static Angle FromYZVector(const mathfu::vec3 &v)
Definition: angle.h:380
mathfu::vec3 ToYZVector() const
Definition: angle.h:206
static Angle FromVectorSystem(const mathfu::vec3 &v, const AngleToVectorSystem system)
Definition: angle.h:352
float ToRadians() const
Return the angle value in radians. Value is in the range (-pi,pi].
Definition: angle.h:144
static float WrapAngle(float angle)
Definition: angle.h:322
mathfu::vec3 ToYXVector() const
Definition: angle.h:218
mathfu::mat3 ToYZRotationMatrix() const
Returns a matrix that rotates about the X axis angle radians.
Definition: angle.h:290
static Angle FromWithinThreePi(const float angle)
Definition: angle.h:336
mathfu::mat3 ToZXRotationMatrix() const
Returns a matrix that rotates about the Y axis -angle radians.
Definition: angle.h:302
mathfu::mat3 ToXYRotationMatrix() const
Returns a matrix that rotates about the Z axis angle radians.
Definition: angle.h:276
mathfu::mat3 ToYXRotationMatrix() const
Returns a matrix that rotates about the Z axis -angle radians.
Definition: angle.h:297
mathfu::vec3 ToZYVector() const
Definition: angle.h:254
mathfu::mat3 ToXZRotationMatrix() const
Returns a matrix that rotates about the Y axis angle radians.
Definition: angle.h:283
static bool IsAngleInRange(const float angle)
Definition: angle.h:404