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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
|
<?xml version="1.0" encoding="UTF-8" ?>
<class name="Quaternion" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
Quaternion.
</brief_description>
<description>
A unit quaternion used for representing 3D rotations. Quaternions need to be normalized to be used for rotation.
It is similar to Basis, which implements matrix representation of rotations, and can be parametrized using both an axis-angle pair or Euler angles. Basis stores rotation, scale, and shearing, while Quaternion only stores rotation.
Due to its compactness and the way it is stored in memory, certain operations (obtaining axis-angle and performing SLERP, in particular) are more efficient and robust against floating-point errors.
</description>
<tutorials>
<link title="Using 3D transforms">$DOCS_URL/tutorials/3d/using_transforms.html#interpolating-with-quaternions</link>
<link title="Third Person Shooter Demo">https://godotengine.org/asset-library/asset/678</link>
</tutorials>
<constructors>
<constructor name="Quaternion">
<return type="Quaternion" />
<description>
Constructs a default-initialized quaternion with all components set to [code]0[/code].
</description>
</constructor>
<constructor name="Quaternion">
<return type="Quaternion" />
<param index="0" name="from" type="Quaternion" />
<description>
Constructs a [Quaternion] as a copy of the given [Quaternion].
</description>
</constructor>
<constructor name="Quaternion">
<return type="Quaternion" />
<param index="0" name="arc_from" type="Vector3" />
<param index="1" name="arc_to" type="Vector3" />
<description>
</description>
</constructor>
<constructor name="Quaternion">
<return type="Quaternion" />
<param index="0" name="axis" type="Vector3" />
<param index="1" name="angle" type="float" />
<description>
Constructs a quaternion that will rotate around the given axis by the specified angle. The axis must be a normalized vector.
</description>
</constructor>
<constructor name="Quaternion">
<return type="Quaternion" />
<param index="0" name="euler_yxz" type="Vector3" />
<description>
</description>
</constructor>
<constructor name="Quaternion">
<return type="Quaternion" />
<param index="0" name="from" type="Basis" />
<description>
Constructs a quaternion from the given [Basis].
</description>
</constructor>
<constructor name="Quaternion">
<return type="Quaternion" />
<param index="0" name="x" type="float" />
<param index="1" name="y" type="float" />
<param index="2" name="z" type="float" />
<param index="3" name="w" type="float" />
<description>
Constructs a quaternion defined by the given values.
</description>
</constructor>
</constructors>
<methods>
<method name="angle_to" qualifiers="const">
<return type="float" />
<param index="0" name="to" type="Quaternion" />
<description>
Returns the angle between this quaternion and [param to]. This is the magnitude of the angle you would need to rotate by to get from one to the other.
[b]Note:[/b] This method has an abnormally high number of floating-point errors, so methods such as [code]is_zero_approx[/code] will not work reliably.
</description>
</method>
<method name="dot" qualifiers="const">
<return type="float" />
<param index="0" name="with" type="Quaternion" />
<description>
Returns the dot product of two quaternions.
</description>
</method>
<method name="exp" qualifiers="const">
<return type="Quaternion" />
<description>
</description>
</method>
<method name="get_angle" qualifiers="const">
<return type="float" />
<description>
</description>
</method>
<method name="get_axis" qualifiers="const">
<return type="Vector3" />
<description>
</description>
</method>
<method name="get_euler" qualifiers="const">
<return type="Vector3" />
<description>
Returns Euler angles (in the YXZ convention: when decomposing, first Z, then X, and Y last) corresponding to the rotation represented by the unit quaternion. Returned vector contains the rotation angles in the format (X angle, Y angle, Z angle).
</description>
</method>
<method name="inverse" qualifiers="const">
<return type="Quaternion" />
<description>
Returns the inverse of the quaternion.
</description>
</method>
<method name="is_equal_approx" qualifiers="const">
<return type="bool" />
<param index="0" name="to" type="Quaternion" />
<description>
Returns [code]true[/code] if this quaternion and [param to] are approximately equal, by running [method @GlobalScope.is_equal_approx] on each component.
</description>
</method>
<method name="is_normalized" qualifiers="const">
<return type="bool" />
<description>
Returns whether the quaternion is normalized or not.
</description>
</method>
<method name="length" qualifiers="const">
<return type="float" />
<description>
Returns the length of the quaternion.
</description>
</method>
<method name="length_squared" qualifiers="const">
<return type="float" />
<description>
Returns the length of the quaternion, squared.
</description>
</method>
<method name="log" qualifiers="const">
<return type="Quaternion" />
<description>
</description>
</method>
<method name="normalized" qualifiers="const">
<return type="Quaternion" />
<description>
Returns a copy of the quaternion, normalized to unit length.
</description>
</method>
<method name="slerp" qualifiers="const">
<return type="Quaternion" />
<param index="0" name="to" type="Quaternion" />
<param index="1" name="weight" type="float" />
<description>
Returns the result of the spherical linear interpolation between this quaternion and [param to] by amount [param weight].
[b]Note:[/b] Both quaternions must be normalized.
</description>
</method>
<method name="slerpni" qualifiers="const">
<return type="Quaternion" />
<param index="0" name="to" type="Quaternion" />
<param index="1" name="weight" type="float" />
<description>
Returns the result of the spherical linear interpolation between this quaternion and [param to] by amount [param weight], but without checking if the rotation path is not bigger than 90 degrees.
</description>
</method>
<method name="spherical_cubic_interpolate" qualifiers="const">
<return type="Quaternion" />
<param index="0" name="b" type="Quaternion" />
<param index="1" name="pre_a" type="Quaternion" />
<param index="2" name="post_b" type="Quaternion" />
<param index="3" name="weight" type="float" />
<description>
Performs a spherical cubic interpolation between quaternions [param pre_a], this vector, [param b], and [param post_b], by the given amount [param weight].
</description>
</method>
</methods>
<members>
<member name="w" type="float" setter="" getter="" default="1.0">
W component of the quaternion (real part).
Quaternion components should usually not be manipulated directly.
</member>
<member name="x" type="float" setter="" getter="" default="0.0">
X component of the quaternion (imaginary [code]i[/code] axis part).
Quaternion components should usually not be manipulated directly.
</member>
<member name="y" type="float" setter="" getter="" default="0.0">
Y component of the quaternion (imaginary [code]j[/code] axis part).
Quaternion components should usually not be manipulated directly.
</member>
<member name="z" type="float" setter="" getter="" default="0.0">
Z component of the quaternion (imaginary [code]k[/code] axis part).
Quaternion components should usually not be manipulated directly.
</member>
</members>
<constants>
<constant name="IDENTITY" value="Quaternion(0, 0, 0, 1)">
The identity quaternion, representing no rotation. Equivalent to an identity [Basis] matrix. If a vector is transformed by an identity quaternion, it will not change.
</constant>
</constants>
<operators>
<operator name="operator !=">
<return type="bool" />
<param index="0" name="right" type="Quaternion" />
<description>
Returns [code]true[/code] if the quaternions are not equal.
[b]Note:[/b] Due to floating-point precision errors, consider using [method is_equal_approx] instead, which is more reliable.
</description>
</operator>
<operator name="operator *">
<return type="Quaternion" />
<param index="0" name="right" type="Quaternion" />
<description>
Composes these two quaternions by multiplying them together. This has the effect of rotating the second quaternion (the child) by the first quaternion (the parent).
</description>
</operator>
<operator name="operator *">
<return type="Vector3" />
<param index="0" name="right" type="Vector3" />
<description>
Rotates (multiplies) the [Vector3] by the given [Quaternion].
</description>
</operator>
<operator name="operator *">
<return type="Quaternion" />
<param index="0" name="right" type="float" />
<description>
Multiplies each component of the [Quaternion] by the given value. This operation is not meaningful on its own, but it can be used as a part of a larger expression.
</description>
</operator>
<operator name="operator *">
<return type="Quaternion" />
<param index="0" name="right" type="int" />
<description>
Multiplies each component of the [Quaternion] by the given value. This operation is not meaningful on its own, but it can be used as a part of a larger expression.
</description>
</operator>
<operator name="operator +">
<return type="Quaternion" />
<param index="0" name="right" type="Quaternion" />
<description>
Adds each component of the left [Quaternion] to the right [Quaternion]. This operation is not meaningful on its own, but it can be used as a part of a larger expression, such as approximating an intermediate rotation between two nearby rotations.
</description>
</operator>
<operator name="operator -">
<return type="Quaternion" />
<param index="0" name="right" type="Quaternion" />
<description>
Subtracts each component of the left [Quaternion] by the right [Quaternion]. This operation is not meaningful on its own, but it can be used as a part of a larger expression.
</description>
</operator>
<operator name="operator /">
<return type="Quaternion" />
<param index="0" name="right" type="float" />
<description>
Divides each component of the [Quaternion] by the given value. This operation is not meaningful on its own, but it can be used as a part of a larger expression.
</description>
</operator>
<operator name="operator /">
<return type="Quaternion" />
<param index="0" name="right" type="int" />
<description>
Divides each component of the [Quaternion] by the given value. This operation is not meaningful on its own, but it can be used as a part of a larger expression.
</description>
</operator>
<operator name="operator ==">
<return type="bool" />
<param index="0" name="right" type="Quaternion" />
<description>
Returns [code]true[/code] if the quaternions are exactly equal.
[b]Note:[/b] Due to floating-point precision errors, consider using [method is_equal_approx] instead, which is more reliable.
</description>
</operator>
<operator name="operator []">
<return type="float" />
<param index="0" name="index" type="int" />
<description>
Access quaternion components using their index. [code]q[0][/code] is equivalent to [code]q.x[/code], [code]q[1][/code] is equivalent to [code]q.y[/code], [code]q[2][/code] is equivalent to [code]q.z[/code], and [code]q[3][/code] is equivalent to [code]q.w[/code].
</description>
</operator>
<operator name="operator unary+">
<return type="Quaternion" />
<description>
Returns the same value as if the [code]+[/code] was not there. Unary [code]+[/code] does nothing, but sometimes it can make your code more readable.
</description>
</operator>
<operator name="operator unary-">
<return type="Quaternion" />
<description>
Returns the negative value of the [Quaternion]. This is the same as writing [code]Quaternion(-q.x, -q.y, -q.z, -q.w)[/code]. This operation results in a quaternion that represents the same rotation.
</description>
</operator>
</operators>
</class>
|