1.0.2 API documentation: type_quat.hpp Source File

| 1.0.2 API documentation

type_quat.hpp
Go to the documentation of this file.
1
4 #pragma once
5
6 // Dependency:
7 #include "../detail/type_mat3x3.hpp"
8 #include "../detail/type_mat4x4.hpp"
9 #include "../detail/type_vec3.hpp"
10 #include "../detail/type_vec4.hpp"
11 #include "../ext/vector_relational.hpp"
12 #include "../ext/quaternion_relational.hpp"
13 #include "../gtc/constants.hpp"
14 #include "../gtc/matrix_transform.hpp"
15
16 namespace glm
17 {
18 # if GLM_SILENT_WARNINGS == GLM_ENABLE
19 # if GLM_COMPILER & GLM_COMPILER_GCC
20 # pragma GCC diagnostic push
21 # pragma GCC diagnostic ignored "-Wpedantic"
22 # elif GLM_COMPILER & GLM_COMPILER_CLANG
23 # pragma clang diagnostic push
24 # pragma clang diagnostic ignored "-Wgnu-anonymous-struct"
25 # pragma clang diagnostic ignored "-Wnested-anon-types"
26 # elif GLM_COMPILER & GLM_COMPILER_VC
27 # pragma warning(push)
28 # pragma warning(disable: 4201) // nonstandard extension used : nameless struct/union
29 # endif
30 # endif
31
32 template<typename T, qualifier Q>
33 struct qua
34 {
35 // -- Implementation detail --
36
37 typedef qua<T, Q> type;
38 typedef T value_type;
39
40 // -- Data --
41
42 # if GLM_LANG & GLM_LANG_CXXMS_FLAG
43 union
44 {
45 # ifdef GLM_FORCE_QUAT_DATA_WXYZ
46 struct { T w, x, y, z; };
47 # else
48 struct { T x, y, z, w; };
49 # endif
50
51 typename detail::storage<4, T, detail::is_aligned<Q>::value>::type data;
52 };
53 # else
54 # ifdef GLM_FORCE_QUAT_DATA_WXYZ
55 T w, x, y, z;
56 # else
57 T x, y, z, w;
58 # endif
59 # endif
60
61 // -- Component accesses --
62
63 typedef length_t length_type;
64
66 GLM_FUNC_DECL static GLM_CONSTEXPR length_type length(){return 4;}
67
68 GLM_FUNC_DECL GLM_CONSTEXPR T & operator[](length_type i);
69 GLM_FUNC_DECL GLM_CONSTEXPR T const& operator[](length_type i) const;
70
71 // -- Implicit basic constructors --
72
73 GLM_DEFAULTED_DEFAULT_CTOR_DECL GLM_CONSTEXPR qua() GLM_DEFAULT_CTOR;
74 GLM_DEFAULTED_FUNC_DECL GLM_CONSTEXPR qua(qua<T, Q> const& q) GLM_DEFAULT;
75 template<qualifier P>
76 GLM_CTOR_DECL qua(qua<T, P> const& q);
77
78 // -- Explicit basic constructors --
79
80 GLM_CTOR_DECL qua(T s, vec<3, T, Q> const& v);
81
82 # ifdef GLM_FORCE_QUAT_DATA_XYZW
83 GLM_CTOR_DECL qua(T x, T y, T z, T w);
84 # else
85 GLM_CTOR_DECL qua(T w, T x, T y, T z);
86 # endif
87
88 GLM_FUNC_DECL static GLM_CONSTEXPR qua<T, Q> wxyz(T w, T x, T y, T z);
89
90 // -- Conversion constructors --
91
92 template<typename U, qualifier P>
93 GLM_CTOR_DECL GLM_EXPLICIT qua(qua<U, P> const& q);
94
96 # if GLM_HAS_EXPLICIT_CONVERSION_OPERATORS
97 GLM_FUNC_DECL explicit operator mat<3, 3, T, Q>() const;
98 GLM_FUNC_DECL explicit operator mat<4, 4, T, Q>() const;
99 # endif
100
107 GLM_FUNC_DISCARD_DECL qua(vec<3, T, Q> const& u, vec<3, T, Q> const& v);
108
110 GLM_CTOR_DECL GLM_EXPLICIT qua(vec<3, T, Q> const& eulerAngles);
111 GLM_CTOR_DECL GLM_EXPLICIT qua(mat<3, 3, T, Q> const& q);
112 GLM_CTOR_DECL GLM_EXPLICIT qua(mat<4, 4, T, Q> const& q);
113
114 // -- Unary arithmetic operators --
115
116 GLM_DEFAULTED_FUNC_DECL GLM_CONSTEXPR qua<T, Q>& operator=(qua<T, Q> const& q) GLM_DEFAULT;
117
118 template<typename U>
119 GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR qua<T, Q>& operator=(qua<U, Q> const& q);
120 template<typename U>
121 GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR qua<T, Q>& operator+=(qua<U, Q> const& q);
122 template<typename U>
123 GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR qua<T, Q>& operator-=(qua<U, Q> const& q);
124 template<typename U>
125 GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR qua<T, Q>& operator*=(qua<U, Q> const& q);
126 template<typename U>
127 GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR qua<T, Q>& operator*=(U s);
128 template<typename U>
129 GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR qua<T, Q>& operator/=(U s);
130 };
131
132 # if GLM_SILENT_WARNINGS == GLM_ENABLE
133 # if GLM_COMPILER & GLM_COMPILER_CLANG
134 # pragma clang diagnostic pop
135 # elif GLM_COMPILER & GLM_COMPILER_GCC
136 # pragma GCC diagnostic pop
137 # elif GLM_COMPILER & GLM_COMPILER_VC
138 # pragma warning(pop)
139 # endif
140 # endif
141
142 // -- Unary bit operators --
143
144 template<typename T, qualifier Q>
145 GLM_FUNC_DECL GLM_CONSTEXPR qua<T, Q> operator+(qua<T, Q> const& q);
146
147 template<typename T, qualifier Q>
148 GLM_FUNC_DECL GLM_CONSTEXPR qua<T, Q> operator-(qua<T, Q> const& q);
149
150 // -- Binary operators --
151
152 template<typename T, qualifier Q>
153 GLM_FUNC_DECL GLM_CONSTEXPR qua<T, Q> operator+(qua<T, Q> const& q, qua<T, Q> const& p);
154
155 template<typename T, qualifier Q>
156 GLM_FUNC_DECL GLM_CONSTEXPR qua<T, Q> operator-(qua<T, Q> const& q, qua<T, Q> const& p);
157
158 template<typename T, qualifier Q>
159 GLM_FUNC_DECL GLM_CONSTEXPR qua<T, Q> operator*(qua<T, Q> const& q, qua<T, Q> const& p);
160
161 template<typename T, qualifier Q>
162 GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator*(qua<T, Q> const& q, vec<3, T, Q> const& v);
163
164 template<typename T, qualifier Q>
165 GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator*(vec<3, T, Q> const& v, qua<T, Q> const& q);
166
167 template<typename T, qualifier Q>
168 GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator*(qua<T, Q> const& q, vec<4, T, Q> const& v);
169
170 template<typename T, qualifier Q>
171 GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator*(vec<4, T, Q> const& v, qua<T, Q> const& q);
172
173 template<typename T, qualifier Q>
174 GLM_FUNC_DECL GLM_CONSTEXPR qua<T, Q> operator*(qua<T, Q> const& q, T const& s);
175
176 template<typename T, qualifier Q>
177 GLM_FUNC_DECL GLM_CONSTEXPR qua<T, Q> operator*(T const& s, qua<T, Q> const& q);
178
179 template<typename T, qualifier Q>
180 GLM_FUNC_DECL GLM_CONSTEXPR qua<T, Q> operator/(qua<T, Q> const& q, T const& s);
181
182 // -- Boolean operators --
183
184 template<typename T, qualifier Q>
185 GLM_FUNC_DECL GLM_CONSTEXPR bool operator==(qua<T, Q> const& q1, qua<T, Q> const& q2);
186
187 template<typename T, qualifier Q>
188 GLM_FUNC_DECL GLM_CONSTEXPR bool operator!=(qua<T, Q> const& q1, qua<T, Q> const& q2);
189 } //namespace glm
190
191 #ifndef GLM_EXTERNAL_TEMPLATE
192 #include "type_quat.inl"
193 #endif//GLM_EXTERNAL_TEMPLATE
glm::length
GLM_FUNC_DECL T length(qua< T, Q > const &q)
Returns the norm of a quaternions.
glm::eulerAngles
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.