master
ブランチ master
VulkanExample / dep / include / glm / gtc / quaternion.hpp
5.6 KB、173行 生 Blame 履歴
1/// @ref gtc_quaternion
2/// @file glm/gtc/quaternion.hpp
3///
4/// @see core (dependence)
5/// @see gtc_constants (dependence)
6///
7/// @defgroup gtc_quaternion GLM_GTC_quaternion
8/// @ingroup gtc
9///
10/// Include <glm/gtc/quaternion.hpp> to use the features of this extension.
11///
12/// Defines a templated quaternion type and several quaternion operations.
13
14#pragma once
15
16// Dependency:
17#include "../gtc/constants.hpp"
18#include "../gtc/matrix_transform.hpp"
19#include "../ext/vector_relational.hpp"
20#include "../ext/quaternion_common.hpp"
21#include "../ext/quaternion_float.hpp"
22#include "../ext/quaternion_float_precision.hpp"
23#include "../ext/quaternion_double.hpp"
24#include "../ext/quaternion_double_precision.hpp"
25#include "../ext/quaternion_relational.hpp"
26#include "../ext/quaternion_geometric.hpp"
27#include "../ext/quaternion_trigonometric.hpp"
28#include "../ext/quaternion_transform.hpp"
29#include "../detail/type_mat3x3.hpp"
30#include "../detail/type_mat4x4.hpp"
31#include "../detail/type_vec3.hpp"
32#include "../detail/type_vec4.hpp"
33
34#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
35# pragma message("GLM: GLM_GTC_quaternion extension included")
36#endif
37
38namespace glm
39{
40 /// @addtogroup gtc_quaternion
41 /// @{
42
43 /// Returns euler angles, pitch as x, yaw as y, roll as z.
44 /// The result is expressed in radians.
45 ///
46 /// @tparam T Floating-point scalar types.
47 ///
48 /// @see gtc_quaternion
49 template<typename T, qualifier Q>
50 GLM_FUNC_DECL vec<3, T, Q> eulerAngles(qua<T, Q> const& x);
51
52 /// Returns roll value of euler angles expressed in radians.
53 ///
54 /// @tparam T Floating-point scalar types.
55 ///
56 /// @see gtc_quaternion
57 template<typename T, qualifier Q>
58 GLM_FUNC_DECL T roll(qua<T, Q> const& x);
59
60 /// Returns pitch value of euler angles expressed in radians.
61 ///
62 /// @tparam T Floating-point scalar types.
63 ///
64 /// @see gtc_quaternion
65 template<typename T, qualifier Q>
66 GLM_FUNC_DECL T pitch(qua<T, Q> const& x);
67
68 /// Returns yaw value of euler angles expressed in radians.
69 ///
70 /// @tparam T Floating-point scalar types.
71 ///
72 /// @see gtc_quaternion
73 template<typename T, qualifier Q>
74 GLM_FUNC_DECL T yaw(qua<T, Q> const& x);
75
76 /// Converts a quaternion to a 3 * 3 matrix.
77 ///
78 /// @tparam T Floating-point scalar types.
79 ///
80 /// @see gtc_quaternion
81 template<typename T, qualifier Q>
82 GLM_FUNC_DECL mat<3, 3, T, Q> mat3_cast(qua<T, Q> const& x);
83
84 /// Converts a quaternion to a 4 * 4 matrix.
85 ///
86 /// @tparam T Floating-point scalar types.
87 ///
88 /// @see gtc_quaternion
89 template<typename T, qualifier Q>
90 GLM_FUNC_DECL mat<4, 4, T, Q> mat4_cast(qua<T, Q> const& x);
91
92 /// Converts a pure rotation 3 * 3 matrix to a quaternion.
93 ///
94 /// @tparam T Floating-point scalar types.
95 ///
96 /// @see gtc_quaternion
97 template<typename T, qualifier Q>
98 GLM_FUNC_DECL qua<T, Q> quat_cast(mat<3, 3, T, Q> const& x);
99
100 /// Converts a pure rotation 4 * 4 matrix to a quaternion.
101 ///
102 /// @tparam T Floating-point scalar types.
103 ///
104 /// @see gtc_quaternion
105 template<typename T, qualifier Q>
106 GLM_FUNC_DECL qua<T, Q> quat_cast(mat<4, 4, T, Q> const& x);
107
108 /// Returns the component-wise comparison result of x < y.
109 ///
110 /// @tparam T Floating-point scalar types
111 /// @tparam Q Value from qualifier enum
112 ///
113 /// @see ext_quaternion_relational
114 template<typename T, qualifier Q>
115 GLM_FUNC_DECL GLM_CONSTEXPR vec<4, bool, Q> lessThan(qua<T, Q> const& x, qua<T, Q> const& y);
116
117 /// Returns the component-wise comparison of result x <= y.
118 ///
119 /// @tparam T Floating-point scalar types
120 /// @tparam Q Value from qualifier enum
121 ///
122 /// @see ext_quaternion_relational
123 template<typename T, qualifier Q>
124 GLM_FUNC_DECL GLM_CONSTEXPR vec<4, bool, Q> lessThanEqual(qua<T, Q> const& x, qua<T, Q> const& y);
125
126 /// Returns the component-wise comparison of result x > y.
127 ///
128 /// @tparam T Floating-point scalar types
129 /// @tparam Q Value from qualifier enum
130 ///
131 /// @see ext_quaternion_relational
132 template<typename T, qualifier Q>
133 GLM_FUNC_DECL GLM_CONSTEXPR vec<4, bool, Q> greaterThan(qua<T, Q> const& x, qua<T, Q> const& y);
134
135 /// Returns the component-wise comparison of result x >= y.
136 ///
137 /// @tparam T Floating-point scalar types
138 /// @tparam Q Value from qualifier enum
139 ///
140 /// @see ext_quaternion_relational
141 template<typename T, qualifier Q>
142 GLM_FUNC_DECL GLM_CONSTEXPR vec<4, bool, Q> greaterThanEqual(qua<T, Q> const& x, qua<T, Q> const& y);
143
144 /// Build a look at quaternion based on the default handedness.
145 ///
146 /// @param direction Desired forward direction. Needs to be normalized.
147 /// @param up Up vector, how the camera is oriented. Typically (0, 1, 0).
148 template<typename T, qualifier Q>
149 GLM_FUNC_DECL qua<T, Q> quatLookAt(
150 vec<3, T, Q> const& direction,
151 vec<3, T, Q> const& up);
152
153 /// Build a right-handed look at quaternion.
154 ///
155 /// @param direction Desired forward direction onto which the -z-axis gets mapped. Needs to be normalized.
156 /// @param up Up vector, how the camera is oriented. Typically (0, 1, 0).
157 template<typename T, qualifier Q>
158 GLM_FUNC_DECL qua<T, Q> quatLookAtRH(
159 vec<3, T, Q> const& direction,
160 vec<3, T, Q> const& up);
161
162 /// Build a left-handed look at quaternion.
163 ///
164 /// @param direction Desired forward direction onto which the +z-axis gets mapped. Needs to be normalized.
165 /// @param up Up vector, how the camera is oriented. Typically (0, 1, 0).
166 template<typename T, qualifier Q>
167 GLM_FUNC_DECL qua<T, Q> quatLookAtLH(
168 vec<3, T, Q> const& direction,
169 vec<3, T, Q> const& up);
170 /// @}
171} //namespace glm
172
173#include "quaternion.inl"