Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
EulerAngles.hpp
1 // Copyright (C) 2017 Jérôme Leclercq
2 // This file is part of the "Nazara Engine - Mathematics module"
3 // For conditions of distribution and use, see copyright notice in Config.hpp
4 
5 #pragma once
6 
7 #ifndef NAZARA_EULERANGLES_HPP
8 #define NAZARA_EULERANGLES_HPP
9 
10 #include <Nazara/Core/String.hpp>
11 #include <Nazara/Math/Quaternion.hpp>
12 #include <Nazara/Math/Vector3.hpp>
13 
14 namespace Nz
15 {
16  struct SerializationContext;
17 
18  template<typename T>
20  {
21  public:
22  EulerAngles() = default;
23  EulerAngles(T P, T Y, T R);
24  EulerAngles(const T angles[3]);
25  //EulerAngles(const Matrix3<T>& mat);
26  EulerAngles(const Quaternion<T>& quat);
27  template<typename U> explicit EulerAngles(const EulerAngles<U>& angles);
28  EulerAngles(const EulerAngles& angles) = default;
29  ~EulerAngles() = default;
30 
31  void MakeZero();
32 
34 
35  EulerAngles& Set(T P, T Y, T R);
36  EulerAngles& Set(const T angles[3]);
37  EulerAngles& Set(const EulerAngles<T>& angles);
38  //EulerAngles& Set(const Matrix3<T>& mat);
39  EulerAngles& Set(const Quaternion<T>& quat);
40  template<typename U> EulerAngles& Set(const EulerAngles<U>& angles);
41 
42  //Matrix3<T> ToRotationMatrix() const;
44  String ToString() const;
45 
46  EulerAngles operator+(const EulerAngles& angles) const;
47  EulerAngles operator-(const EulerAngles& angles) const;
48  /*EulerAngles operator*(const EulerAngles& angles) const;
49  EulerAngles operator/(const EulerAngles& angles) const;*/
50  EulerAngles& operator=(const EulerAngles& other) = default;
51 
52  EulerAngles& operator+=(const EulerAngles& angles);
53  EulerAngles& operator-=(const EulerAngles& angles);
54  /*EulerAngles operator*=(const EulerAngles& angles);
55  EulerAngles operator/=(const EulerAngles& angles);*/
56 
57  bool operator==(const EulerAngles& angles) const;
58  bool operator!=(const EulerAngles& angles) const;
59 
60  static EulerAngles Zero();
61 
62  T pitch, yaw, roll;
63  };
64 
67 
68  template<typename T> bool Serialize(SerializationContext& context, const EulerAngles<T>& eulerAngles);
69  template<typename T> bool Unserialize(SerializationContext& context, EulerAngles<T>* eulerAngles);
70 }
71 
72 template<typename T> std::ostream& operator<<(std::ostream& out, const Nz::EulerAngles<T>& angles);
73 
74 
75 #include <Nazara/Math/EulerAngles.inl>
76 
77 #endif // NAZARA_EULERANGLES_HPP
Quaternion< T > ToQuaternion() const
Converts the euler angle to quaternion.
Definition: EulerAngles.inl:198
TODO: Inherit SoundEmitter from Node.
Definition: Algorithm.hpp:12
bool operator==(const EulerAngles &angles) const
Compares the euler angle to other one.
Definition: EulerAngles.inl:300
bool Unserialize(SerializationContext &context, bool *value)
Unserializes a boolean.
Definition: Algorithm.inl:279
void MakeZero()
Makes the euler angle (0, 0, 0)
Definition: EulerAngles.inl:86
Core class that represents a string.
Definition: String.hpp:22
EulerAngles operator+(const EulerAngles &angles) const
Adds the components of the euler angle with other euler angle.
Definition: EulerAngles.inl:236
String ToString() const
Gives a string representation.
Definition: EulerAngles.inl:221
Structure containing a serialization/unserialization context states.
Definition: SerializationContext.hpp:18
EulerAngles & operator+=(const EulerAngles &angles)
Adds the components of other euler angle to this euler angle.
Definition: EulerAngles.inl:266
EulerAngles & Normalize()
Normalizes the euler angle.
Definition: EulerAngles.inl:101
static EulerAngles Zero()
Shorthand for the euler angle (0, 0, 0)
Definition: EulerAngles.inl:328
bool Serialize(SerializationContext &context, bool value)
Serializes a boolean.
Definition: Algorithm.inl:214
EulerAngles & Set(T P, T Y, T R)
Sets the components of the euler angle.
Definition: EulerAngles.inl:120
EulerAngles operator-(const EulerAngles &angles) const
Substracts the components of the euler angle with other euler angle.
Definition: EulerAngles.inl:251
Math class that represents an Euler angle. Those describe a rotation transformation by rotating an ob...
Definition: EulerAngles.hpp:19
EulerAngles & operator-=(const EulerAngles &angles)
Substracts the components of other euler angle to this euler angle.
Definition: EulerAngles.inl:283
bool operator!=(const EulerAngles &angles) const
Compares the euler angle to other one.
Definition: EulerAngles.inl:315
Math class that represents an element of the quaternions.
Definition: Matrix4.hpp:20