0.9.9 API documentation
type_quat.hpp
1 
14 #pragma once
15 
16 // Dependency:
17 #include "../detail/type_mat3x3.hpp"
18 #include "../detail/type_mat4x4.hpp"
19 #include "../detail/type_vec3.hpp"
20 #include "../detail/type_vec4.hpp"
21 #include "../ext/vector_relational.hpp"
22 #include "../ext/quaternion_relational.hpp"
23 #include "../gtc/constants.hpp"
24 #include "../gtc/matrix_transform.hpp"
25 
26 namespace glm
27 {
30 
31  template<typename T, qualifier Q>
32  struct qua
33  {
34  // -- Implementation detail --
35 
36  typedef qua<T, Q> type;
37  typedef T value_type;
38 
39  // -- Data --
40 
41 # if GLM_LANG & GLM_LANG_CXXMS_FLAG
42  union
43  {
44  struct { T x, y, z, w;};
45 
46  typename detail::storage<4, T, detail::is_aligned<Q>::value>::type data;
47  };
48 # else
49  T x, y, z, w;
50 # endif
51 
52  // -- Component accesses --
53 
54  typedef length_t length_type;
56  GLM_FUNC_DECL static GLM_CONSTEXPR length_type length(){return 4;}
57 
58  GLM_FUNC_DECL GLM_CONSTEXPR T & operator[](length_type i);
59  GLM_FUNC_DECL GLM_CONSTEXPR T const& operator[](length_type i) const;
60 
61  // -- Implicit basic constructors --
62 
63  GLM_FUNC_DECL GLM_CONSTEXPR qua() GLM_DEFAULT;
64  GLM_FUNC_DECL GLM_CONSTEXPR qua(qua<T, Q> const& q) GLM_DEFAULT;
65  template<qualifier P>
66  GLM_FUNC_DECL GLM_CONSTEXPR qua(qua<T, P> const& q);
67 
68  // -- Explicit basic constructors --
69 
70  GLM_FUNC_DECL GLM_CONSTEXPR qua(T s, vec<3, T, Q> const& v);
71  GLM_FUNC_DECL GLM_CONSTEXPR qua(T w, T x, T y, T z);
72 
73  // -- Conversion constructors --
74 
75  template<typename U, qualifier P>
76  GLM_FUNC_DECL GLM_CONSTEXPR GLM_EXPLICIT qua(qua<U, P> const& q);
77 
79 # if GLM_HAS_EXPLICIT_CONVERSION_OPERATORS
80  GLM_FUNC_DECL explicit operator mat<3, 3, T, Q>();
81  GLM_FUNC_DECL explicit operator mat<4, 4, T, Q>();
82 # endif
83 
90  GLM_FUNC_DECL qua(vec<3, T, Q> const& u, vec<3, T, Q> const& v);
91 
93  GLM_FUNC_DECL GLM_EXPLICIT qua(vec<3, T, Q> const& eulerAngles);
94  GLM_FUNC_DECL GLM_EXPLICIT qua(mat<3, 3, T, Q> const& q);
95  GLM_FUNC_DECL GLM_EXPLICIT qua(mat<4, 4, T, Q> const& q);
96 
97  // -- Unary arithmetic operators --
98 
99  GLM_FUNC_DECL qua<T, Q>& operator=(qua<T, Q> const& q) GLM_DEFAULT;
100 
101  template<typename U>
102  GLM_FUNC_DECL qua<T, Q>& operator=(qua<U, Q> const& q);
103  template<typename U>
104  GLM_FUNC_DECL qua<T, Q>& operator+=(qua<U, Q> const& q);
105  template<typename U>
106  GLM_FUNC_DECL qua<T, Q>& operator-=(qua<U, Q> const& q);
107  template<typename U>
108  GLM_FUNC_DECL qua<T, Q>& operator*=(qua<U, Q> const& q);
109  template<typename U>
110  GLM_FUNC_DECL qua<T, Q>& operator*=(U s);
111  template<typename U>
112  GLM_FUNC_DECL qua<T, Q>& operator/=(U s);
113  };
114 
115  // -- Unary bit operators --
116 
117  template<typename T, qualifier Q>
118  GLM_FUNC_DECL qua<T, Q> operator+(qua<T, Q> const& q);
119 
120  template<typename T, qualifier Q>
121  GLM_FUNC_DECL qua<T, Q> operator-(qua<T, Q> const& q);
122 
123  // -- Binary operators --
124 
125  template<typename T, qualifier Q>
126  GLM_FUNC_DECL qua<T, Q> operator+(qua<T, Q> const& q, qua<T, Q> const& p);
127 
128  template<typename T, qualifier Q>
129  GLM_FUNC_DECL qua<T, Q> operator-(qua<T, Q> const& q, qua<T, Q> const& p);
130 
131  template<typename T, qualifier Q>
132  GLM_FUNC_DECL qua<T, Q> operator*(qua<T, Q> const& q, qua<T, Q> const& p);
133 
134  template<typename T, qualifier Q>
135  GLM_FUNC_DECL vec<3, T, Q> operator*(qua<T, Q> const& q, vec<3, T, Q> const& v);
136 
137  template<typename T, qualifier Q>
138  GLM_FUNC_DECL vec<3, T, Q> operator*(vec<3, T, Q> const& v, qua<T, Q> const& q);
139 
140  template<typename T, qualifier Q>
141  GLM_FUNC_DECL vec<4, T, Q> operator*(qua<T, Q> const& q, vec<4, T, Q> const& v);
142 
143  template<typename T, qualifier Q>
144  GLM_FUNC_DECL vec<4, T, Q> operator*(vec<4, T, Q> const& v, qua<T, Q> const& q);
145 
146  template<typename T, qualifier Q>
147  GLM_FUNC_DECL qua<T, Q> operator*(qua<T, Q> const& q, T const& s);
148 
149  template<typename T, qualifier Q>
150  GLM_FUNC_DECL qua<T, Q> operator*(T const& s, qua<T, Q> const& q);
151 
152  template<typename T, qualifier Q>
153  GLM_FUNC_DECL qua<T, Q> operator/(qua<T, Q> const& q, T const& s);
154 
155  // -- Boolean operators --
156 
157  template<typename T, qualifier Q>
158  GLM_FUNC_DECL GLM_CONSTEXPR bool operator==(qua<T, Q> const& q1, qua<T, Q> const& q2);
159 
160  template<typename T, qualifier Q>
161  GLM_FUNC_DECL GLM_CONSTEXPR bool operator!=(qua<T, Q> const& q1, qua<T, Q> const& q2);
162 
164 } //namespace glm
165 
166 #include "type_quat.inl"
GLM_FUNC_DECL vec< 3, T, Q > eulerAngles(qua< T, Q > const &x)
Returns euler angles, pitch as x, yaw as y, roll as z.
Definition: common.hpp:20
GLM_FUNC_DECL T length(qua< T, Q > const &q)
Returns the norm of a quaternions.