1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
=encoding UTF-8
=head1 NAME
BH_Quat - Quaternion
=head1 SYNTAX
#include <BH/Math/Quat.h>
cc prog.c -o prog -lbh
=head1 DESCRIPTION
This module provides a set of functions for working with quaternions.
Quaternions are used to represent rotations in three-dimensional space and have
advantages over other methods, such as rotation matrices or Euler angles, in
terms of stability against error accumulation during multiple rotation
operations.
=head1 API CALLS
=head2 BH_Quat4fAdd
#define BH_Quat4fAdd(a, b, out) \
BH_Vec4fAdd(a, b, out)
Calculates the sum of two quaternions I<a> and I<b>.
The parameter I<out> describes the resulting quaternion.
=head2 BH_Quat4fSub
#define BH_Quat4fSub(a, b, out) \
BH_Vec4fSub(a, b, out)
Calculates the difference between two quaternions I<a> and I<b>.
The parameter I<out> describes the resulting quaternion.
=head2 BH_Quat4fScale
#define BH_Quat4fScale(a, b, out) \
BH_Vec4fScale(a, b, out)
Calculates the result of multiplying quaternion I<a> by value I<b>.
The parameter I<out> describes the resulting quaternion.
=head2 BH_Quat4fNegate
#define BH_Quat4fNegate(in, out) \
BH_Vec4fNegate(in, out)
Calculates the opposite quaternion from quaternion I<in>.
The parameter I<out> describes the resulting quaternion.
=head2 BH_Quat4fDot
#define BH_Quat4fDot(a, b) \
BH_Vec4fDot(a, b)
Calculates the dot product of quaternions I<a> and I<b>.
=head2 BH_Quat4fLength
#define BH_Quat4fLength(in) \
BH_Vec4fLength(in)
float BH_Vec4fLength(const float in[4]);
Calculates the length of quaternion I<in>.
=head2 BH_Quat4fNormal
#define BH_Quat4fNormal(in, out) \
BH_Vec4fNormal(in, out)
Calculates the normalized form of quaternion I<in>.
The parameter I<out> describes the resulting quaternion.
=head2 BH_Quat4fLerp
#define BH_Quat4fLerp(a, b, t, out) \
BH_Vec4fLerp(a, b, t, out)
Performs linear interpolation between two quaternions I<a> and I<b> with
parameter I<t>.
The parameter I<out> describes the resulting quaternion.
=head2 BH_Quat4fIdentity
void BH_Quat4fIdentity(float out[4]);
Writes the identity quaternion to I<out>.
=head2 BH_Quat4fConjugate
void BH_Quat4fConjugate(const float in[4],
float out[4]);
Calculates the conjugate quaternion from I<in>.
The parameter I<out> describes the resulting quaternion.
=head2 BH_Quat4fInverse
void BH_Quat4fInverse(const float in[4],
float out[4]);
Calculates the inverse quaternion from I<in>.
The parameter I<out> describes the resulting quaternion.
=head2 BH_Quat4fMul
void BH_Quat4fMul(const float a[4],
const float b[4],
float out[4]);
Calculates the result of multiplying two quaternions I<a> and I<b>.
The parameter I<out> describes the resulting quaternion.
=head2 BH_Quat4fSlerp
void BH_Quat4fSlerp(const float a[4],
const float b[4],
float t,
float out[4]);
Performs spherical linear interpolation between two quaternions I<a> and I<b>
with parameter I<t>.
The parameter I<out> describes the resulting quaternion.
=head2 BH_Quat4fFromEuler
void BH_Quat4fFromEuler(float roll,
float pitch,
float yaw,
float out[4]);
Calculates the quaternion from the angles of the associated coordinate system
I<roll>, I<pitch>, and I<yaw>.
The order of rotation application is ZYX (yaw, pitch, roll).
The parameter I<out> describes the resulting quaternion.
=head2 BH_Quat4fFromAxis
void BH_Quat4fFromAxis(const float axis[3],
float angle,
float out[4]);
Calculates the quaternion from rotation around the I<axis> with the given
I<angle>.
The parameter I<out> describes the resulting quaternion.
=head2 BH_Quat4fToEuler
void BH_Quat4fToEuler(const float in[4],
float *roll,
float *pitch,
float *yaw);
Calculates the angles of the associated coordinate system I<roll>, I<pitch>,
and I<yaw> from quaternion I<in>.
The order of rotation application is ZYX (yaw, pitch, roll).
=head2 BH_Quat4fToAxis
void BH_Quat4fToAxis(const float in[4],
float axis[3],
float *angle);
Calculates the rotation I<axis> and I<angle> from quaternion I<in>.
=head2 BH_Quat4fToMat4f
void BH_Quat4fToMat4f(const float in[4],
float out[16]);
Calculates the rotation matrix from quaternion I<in>.
The parameter I<out> describes the resulting matrix.
=head1 SEE ALSO
L<BH>
|