2017-09-12 20:42:36 +00:00
<?xml version="1.0" encoding="UTF-8" ?>
2021-01-20 07:02:02 +00:00
<class name= "Quaternion" version= "4.0" >
2017-09-12 20:42:36 +00:00
<brief_description >
Quaternion.
</brief_description>
<description >
2020-07-21 18:07:00 +00:00
A unit quaternion used for representing 3D rotations. Quaternions need to be normalized to be used for rotation.
2021-01-20 07:02:02 +00:00
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.
2020-07-21 18:07:00 +00:00
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.
2017-09-12 20:42:36 +00:00
</description>
<tutorials >
2020-08-05 12:43:40 +00:00
<link title= "Using 3D transforms" > https://docs.godotengine.org/en/latest/tutorials/3d/using_transforms.html#interpolating-with-quaternions</link>
2020-10-01 08:34:47 +00:00
<link title= "Third Person Shooter Demo" > https://godotengine.org/asset-library/asset/678</link>
2017-09-12 20:42:36 +00:00
</tutorials>
<methods >
2021-01-20 07:02:02 +00:00
<method name= "Quaternion" qualifiers= "constructor" >
<return type= "Quaternion" >
2017-09-12 20:42:36 +00:00
</return>
2020-11-09 16:46:03 +00:00
<description >
Constructs a default-initialized quaternion with all components set to [code]0[/code].
</description>
</method>
2021-01-20 07:02:02 +00:00
<method name= "Quaternion" qualifiers= "constructor" >
<return type= "Quaternion" >
2020-11-09 16:46:03 +00:00
</return>
2021-01-20 07:02:02 +00:00
<argument index= "0" name= "from" type= "Quaternion" >
2020-11-04 14:38:26 +00:00
</argument>
2020-11-09 16:46:03 +00:00
<description >
2021-01-20 07:02:02 +00:00
Constructs a [Quaternion] as a copy of the given [Quaternion].
2020-11-09 16:46:03 +00:00
</description>
</method>
2021-01-20 07:02:02 +00:00
<method name= "Quaternion" qualifiers= "constructor" >
<return type= "Quaternion" >
2020-11-09 16:46:03 +00:00
</return>
<argument index= "0" name= "arc_from" type= "Vector3" >
2020-11-04 14:38:26 +00:00
</argument>
2020-11-09 16:46:03 +00:00
<argument index= "1" name= "arc_to" type= "Vector3" >
2017-09-12 20:42:36 +00:00
</argument>
<description >
</description>
</method>
2021-01-20 07:02:02 +00:00
<method name= "Quaternion" qualifiers= "constructor" >
<return type= "Quaternion" >
2017-09-12 20:42:36 +00:00
</return>
2020-11-04 14:38:26 +00:00
<argument index= "0" name= "axis" type= "Vector3" >
</argument>
<argument index= "1" name= "angle" type= "float" >
2017-09-12 20:42:36 +00:00
</argument>
<description >
2020-11-04 14:38:26 +00:00
Constructs a quaternion that will rotate around the given axis by the specified angle. The axis must be a normalized vector.
2017-09-12 20:42:36 +00:00
</description>
</method>
2021-01-20 07:02:02 +00:00
<method name= "Quaternion" qualifiers= "constructor" >
<return type= "Quaternion" >
2018-05-12 00:14:39 +00:00
</return>
2020-11-04 14:38:26 +00:00
<argument index= "0" name= "euler" type= "Vector3" >
2018-05-12 00:14:39 +00:00
</argument>
<description >
2020-11-04 14:38:26 +00:00
Constructs a quaternion that will perform a rotation specified by Euler angles (in the YXZ convention: when decomposing, first Z, then X, and Y last), given in the vector format as (X angle, Y angle, Z angle).
2018-05-12 00:14:39 +00:00
</description>
</method>
2021-01-20 07:02:02 +00:00
<method name= "Quaternion" qualifiers= "constructor" >
<return type= "Quaternion" >
2017-09-12 20:42:36 +00:00
</return>
2020-11-04 14:38:26 +00:00
<argument index= "0" name= "from" type= "Basis" >
2017-09-12 20:42:36 +00:00
</argument>
<description >
2020-11-04 14:38:26 +00:00
Constructs a quaternion from the given [Basis].
2017-09-12 20:42:36 +00:00
</description>
</method>
2021-01-20 07:02:02 +00:00
<method name= "Quaternion" qualifiers= "constructor" >
<return type= "Quaternion" >
2020-11-09 16:46:03 +00:00
</return>
<argument index= "0" name= "x" type= "float" >
</argument>
<argument index= "1" name= "y" type= "float" >
</argument>
<argument index= "2" name= "z" type= "float" >
</argument>
<argument index= "3" name= "w" type= "float" >
</argument>
<description >
Constructs a quaternion defined by the given values.
</description>
</method>
2020-12-07 06:40:46 +00:00
<method name= "angle_to" qualifiers= "const" >
<return type= "float" >
</return>
<argument index= "0" name= "to" type= "Quaternion" >
</argument>
<description >
Returns the angle between this quaternion and [code]to[/code]. 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 amount of floating-point error, so methods such as [code]is_zero_approx[/code] will not work reliably.
</description>
</method>
2021-03-18 13:44:42 +00:00
<method name= "cubic_slerp" qualifiers= "const" >
2021-01-20 07:02:02 +00:00
<return type= "Quaternion" >
2017-09-12 20:42:36 +00:00
</return>
2021-01-20 07:02:02 +00:00
<argument index= "0" name= "b" type= "Quaternion" >
2017-09-12 20:42:36 +00:00
</argument>
2021-01-20 07:02:02 +00:00
<argument index= "1" name= "pre_a" type= "Quaternion" >
2017-09-12 20:42:36 +00:00
</argument>
2021-01-20 07:02:02 +00:00
<argument index= "2" name= "post_b" type= "Quaternion" >
2017-09-12 20:42:36 +00:00
</argument>
2020-12-07 08:16:31 +00:00
<argument index= "3" name= "weight" type= "float" >
2017-09-12 20:42:36 +00:00
</argument>
<description >
2020-12-07 08:16:31 +00:00
Performs a cubic spherical interpolation between quaternions [code]pre_a[/code], this vector, [code]b[/code], and [code]post_b[/code], by the given amount [code]weight[/code].
2017-09-12 20:42:36 +00:00
</description>
</method>
2021-03-18 13:44:42 +00:00
<method name= "dot" qualifiers= "const" >
2017-09-12 20:42:36 +00:00
<return type= "float" >
</return>
2021-01-20 07:02:02 +00:00
<argument index= "0" name= "with" type= "Quaternion" >
2017-09-12 20:42:36 +00:00
</argument>
<description >
Returns the dot product of two quaternions.
</description>
</method>
2021-03-18 13:44:42 +00:00
<method name= "get_euler" qualifiers= "const" >
2018-05-12 00:14:39 +00:00
<return type= "Vector3" >
</return>
<description >
2020-07-21 18:07:00 +00:00
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).
2018-05-12 00:14:39 +00:00
</description>
</method>
2021-03-18 13:44:42 +00:00
<method name= "inverse" qualifiers= "const" >
2021-01-20 07:02:02 +00:00
<return type= "Quaternion" >
2017-09-12 20:42:36 +00:00
</return>
<description >
Returns the inverse of the quaternion.
</description>
</method>
2021-03-18 13:44:42 +00:00
<method name= "is_equal_approx" qualifiers= "const" >
2019-11-08 07:33:48 +00:00
<return type= "bool" >
</return>
2021-01-20 07:02:02 +00:00
<argument index= "0" name= "to" type= "Quaternion" >
2019-11-08 07:33:48 +00:00
</argument>
<description >
2021-03-18 11:04:28 +00:00
Returns [code]true[/code] if this quaternion and [code]quat[/code] are approximately equal, by running [method @GlobalScope.is_equal_approx] on each component.
2019-11-08 07:33:48 +00:00
</description>
</method>
2021-03-18 13:44:42 +00:00
<method name= "is_normalized" qualifiers= "const" >
2017-09-12 20:42:36 +00:00
<return type= "bool" >
</return>
<description >
Returns whether the quaternion is normalized or not.
</description>
</method>
2021-03-18 13:44:42 +00:00
<method name= "length" qualifiers= "const" >
2017-09-12 20:42:36 +00:00
<return type= "float" >
</return>
<description >
Returns the length of the quaternion.
</description>
</method>
2021-03-18 13:44:42 +00:00
<method name= "length_squared" qualifiers= "const" >
2017-09-12 20:42:36 +00:00
<return type= "float" >
</return>
<description >
Returns the length of the quaternion, squared.
</description>
</method>
2021-03-18 13:44:42 +00:00
<method name= "normalized" qualifiers= "const" >
2021-01-20 07:02:02 +00:00
<return type= "Quaternion" >
2017-09-12 20:42:36 +00:00
</return>
<description >
Returns a copy of the quaternion, normalized to unit length.
</description>
2020-11-10 13:16:20 +00:00
</method>
<method name= "operator !=" qualifiers= "operator" >
<return type= "bool" >
</return>
2021-01-20 07:02:02 +00:00
<argument index= "0" name= "right" type= "Quaternion" >
2020-11-10 13:16:20 +00:00
</argument>
<description >
</description>
</method>
<method name= "operator *" qualifiers= "operator" >
2021-06-19 15:58:49 +00:00
<return type= "Vector3" >
2020-11-10 13:16:20 +00:00
</return>
2021-06-19 15:58:49 +00:00
<argument index= "0" name= "right" type= "Vector3" >
2020-11-10 13:16:20 +00:00
</argument>
<description >
</description>
</method>
<method name= "operator *" qualifiers= "operator" >
2021-06-19 15:58:49 +00:00
<return type= "Quaternion" >
2020-11-10 13:16:20 +00:00
</return>
2021-06-19 15:58:49 +00:00
<argument index= "0" name= "right" type= "Quaternion" >
2020-11-10 13:16:20 +00:00
</argument>
<description >
</description>
</method>
<method name= "operator *" qualifiers= "operator" >
2021-01-20 07:02:02 +00:00
<return type= "Quaternion" >
2020-11-10 13:16:20 +00:00
</return>
<argument index= "0" name= "right" type= "float" >
</argument>
<description >
</description>
</method>
<method name= "operator *" qualifiers= "operator" >
2021-01-20 07:02:02 +00:00
<return type= "Quaternion" >
2020-11-10 13:16:20 +00:00
</return>
<argument index= "0" name= "right" type= "int" >
</argument>
<description >
</description>
</method>
<method name= "operator +" qualifiers= "operator" >
2021-01-20 07:02:02 +00:00
<return type= "Quaternion" >
2020-11-10 13:16:20 +00:00
</return>
2021-01-20 07:02:02 +00:00
<argument index= "0" name= "right" type= "Quaternion" >
2020-11-10 13:16:20 +00:00
</argument>
<description >
</description>
</method>
2020-12-04 14:54:48 +00:00
<method name= "operator -" qualifiers= "operator" >
2021-01-20 07:02:02 +00:00
<return type= "Quaternion" >
2020-12-04 14:54:48 +00:00
</return>
2021-01-20 07:02:02 +00:00
<argument index= "0" name= "right" type= "Quaternion" >
2020-12-04 14:54:48 +00:00
</argument>
<description >
</description>
</method>
2020-11-10 13:16:20 +00:00
<method name= "operator /" qualifiers= "operator" >
2021-01-20 07:02:02 +00:00
<return type= "Quaternion" >
2020-11-10 13:16:20 +00:00
</return>
<argument index= "0" name= "right" type= "float" >
</argument>
<description >
</description>
</method>
<method name= "operator /" qualifiers= "operator" >
2021-01-20 07:02:02 +00:00
<return type= "Quaternion" >
2020-11-10 13:16:20 +00:00
</return>
<argument index= "0" name= "right" type= "int" >
</argument>
<description >
</description>
</method>
<method name= "operator ==" qualifiers= "operator" >
<return type= "bool" >
</return>
2021-01-20 07:02:02 +00:00
<argument index= "0" name= "right" type= "Quaternion" >
2020-11-10 13:16:20 +00:00
</argument>
<description >
</description>
</method>
<method name= "operator []" qualifiers= "operator" >
<return type= "float" >
</return>
<argument index= "0" name= "index" type= "int" >
</argument>
<description >
</description>
2017-09-12 20:42:36 +00:00
</method>
2021-06-19 15:58:49 +00:00
<method name= "operator unary+" qualifiers= "operator" >
<return type= "Quaternion" >
</return>
<description >
</description>
</method>
<method name= "operator unary-" qualifiers= "operator" >
<return type= "Quaternion" >
</return>
<description >
</description>
</method>
2021-03-18 13:44:42 +00:00
<method name= "slerp" qualifiers= "const" >
2021-01-20 07:02:02 +00:00
<return type= "Quaternion" >
2017-09-12 20:42:36 +00:00
</return>
2021-01-20 07:02:02 +00:00
<argument index= "0" name= "to" type= "Quaternion" >
2017-09-12 20:42:36 +00:00
</argument>
2020-12-07 08:16:31 +00:00
<argument index= "1" name= "weight" type= "float" >
2017-09-12 20:42:36 +00:00
</argument>
<description >
2020-07-21 18:07:00 +00:00
Returns the result of the spherical linear interpolation between this quaternion and [code]to[/code] by amount [code]weight[/code].
[b]Note:[/b] Both quaternions must be normalized.
2017-09-12 20:42:36 +00:00
</description>
</method>
2021-03-18 13:44:42 +00:00
<method name= "slerpni" qualifiers= "const" >
2021-01-20 07:02:02 +00:00
<return type= "Quaternion" >
2017-09-12 20:42:36 +00:00
</return>
2021-01-20 07:02:02 +00:00
<argument index= "0" name= "to" type= "Quaternion" >
2017-09-12 20:42:36 +00:00
</argument>
2020-12-07 08:16:31 +00:00
<argument index= "1" name= "weight" type= "float" >
2017-09-12 20:42:36 +00:00
</argument>
<description >
2020-07-21 18:07:00 +00:00
Returns the result of the spherical linear interpolation between this quaternion and [code]to[/code] by amount [code]weight[/code], but without checking if the rotation path is not bigger than 90 degrees.
2017-09-12 20:42:36 +00:00
</description>
</method>
</methods>
<members >
2019-06-29 10:38:01 +00:00
<member name= "w" type= "float" setter= "" getter= "" default= "1.0" >
2020-07-21 18:07:00 +00:00
W component of the quaternion (real part).
Quaternion components should usually not be manipulated directly.
2017-09-12 20:42:36 +00:00
</member>
2019-06-29 10:38:01 +00:00
<member name= "x" type= "float" setter= "" getter= "" default= "0.0" >
2020-07-21 18:07:00 +00:00
X component of the quaternion (imaginary [code]i[/code] axis part).
Quaternion components should usually not be manipulated directly.
2017-09-12 20:42:36 +00:00
</member>
2019-06-29 10:38:01 +00:00
<member name= "y" type= "float" setter= "" getter= "" default= "0.0" >
2020-07-21 18:07:00 +00:00
Y component of the quaternion (imaginary [code]j[/code] axis part).
Quaternion components should usually not be manipulated directly.
2017-09-12 20:42:36 +00:00
</member>
2019-06-29 10:38:01 +00:00
<member name= "z" type= "float" setter= "" getter= "" default= "0.0" >
2020-07-21 18:07:00 +00:00
Z component of the quaternion (imaginary [code]k[/code] axis part).
Quaternion components should usually not be manipulated directly.
2017-09-12 20:42:36 +00:00
</member>
</members>
<constants >
2019-09-24 17:45:03 +00:00
<constant name= "IDENTITY" value= "Quaternion(0, 0, 0, 1)" >
2020-07-21 18:07:00 +00:00
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.
2018-08-20 22:35:30 +00:00
</constant>
2017-09-12 20:42:36 +00:00
</constants>
</class>