Files
godot-docs/classes/class_quaternion.rst
2023-05-19 13:35:34 +00:00

722 lines
42 KiB
ReStructuredText

:github_url: hide
.. DO NOT EDIT THIS FILE!!!
.. Generated automatically from Godot engine sources.
.. Generator: https://github.com/godotengine/godot/tree/4.0/doc/tools/make_rst.py.
.. XML source: https://github.com/godotengine/godot/tree/4.0/doc/classes/Quaternion.xml.
.. _class_Quaternion:
Quaternion
==========
A unit quaternion used for representing 3D rotations.
.. rst-class:: classref-introduction-group
Description
-----------
Quaternions are similar to :ref:`Basis<class_Basis>`, which implements the matrix representation of rotations. Unlike :ref:`Basis<class_Basis>`, which stores rotation, scale, and shearing, quaternions only store rotation.
Quaternions can be parametrized using both an axis-angle pair or Euler angles. Due to their compactness and the way they are stored in memory, certain operations (obtaining axis-angle and performing SLERP, in particular) are more efficient and robust against floating-point errors.
\ **Note:** Quaternions need to be normalized before being used for rotation.
.. rst-class:: classref-introduction-group
Tutorials
---------
- `Using 3D transforms <../tutorials/3d/using_transforms.html#interpolating-with-quaternions>`__
- `Third Person Shooter Demo <https://godotengine.org/asset-library/asset/678>`__
.. rst-class:: classref-reftable-group
Properties
----------
.. table::
:widths: auto
+---------------------------+---------------------------------------+---------+
| :ref:`float<class_float>` | :ref:`w<class_Quaternion_property_w>` | ``1.0`` |
+---------------------------+---------------------------------------+---------+
| :ref:`float<class_float>` | :ref:`x<class_Quaternion_property_x>` | ``0.0`` |
+---------------------------+---------------------------------------+---------+
| :ref:`float<class_float>` | :ref:`y<class_Quaternion_property_y>` | ``0.0`` |
+---------------------------+---------------------------------------+---------+
| :ref:`float<class_float>` | :ref:`z<class_Quaternion_property_z>` | ``0.0`` |
+---------------------------+---------------------------------------+---------+
.. rst-class:: classref-reftable-group
Constructors
------------
.. table::
:widths: auto
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Quaternion<class_Quaternion>` | :ref:`Quaternion<class_Quaternion_constructor_Quaternion>` **(** **)** |
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Quaternion<class_Quaternion>` | :ref:`Quaternion<class_Quaternion_constructor_Quaternion>` **(** :ref:`Quaternion<class_Quaternion>` from **)** |
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Quaternion<class_Quaternion>` | :ref:`Quaternion<class_Quaternion_constructor_Quaternion>` **(** :ref:`Vector3<class_Vector3>` arc_from, :ref:`Vector3<class_Vector3>` arc_to **)** |
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Quaternion<class_Quaternion>` | :ref:`Quaternion<class_Quaternion_constructor_Quaternion>` **(** :ref:`Vector3<class_Vector3>` axis, :ref:`float<class_float>` angle **)** |
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Quaternion<class_Quaternion>` | :ref:`Quaternion<class_Quaternion_constructor_Quaternion>` **(** :ref:`Basis<class_Basis>` from **)** |
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Quaternion<class_Quaternion>` | :ref:`Quaternion<class_Quaternion_constructor_Quaternion>` **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y, :ref:`float<class_float>` z, :ref:`float<class_float>` w **)** |
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
.. rst-class:: classref-reftable-group
Methods
-------
.. table::
:widths: auto
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`float<class_float>` | :ref:`angle_to<class_Quaternion_method_angle_to>` **(** :ref:`Quaternion<class_Quaternion>` to **)** |const| |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`float<class_float>` | :ref:`dot<class_Quaternion_method_dot>` **(** :ref:`Quaternion<class_Quaternion>` with **)** |const| |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Quaternion<class_Quaternion>` | :ref:`exp<class_Quaternion_method_exp>` **(** **)** |const| |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Quaternion<class_Quaternion>` | :ref:`from_euler<class_Quaternion_method_from_euler>` **(** :ref:`Vector3<class_Vector3>` euler **)** |static| |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`float<class_float>` | :ref:`get_angle<class_Quaternion_method_get_angle>` **(** **)** |const| |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Vector3<class_Vector3>` | :ref:`get_axis<class_Quaternion_method_get_axis>` **(** **)** |const| |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Vector3<class_Vector3>` | :ref:`get_euler<class_Quaternion_method_get_euler>` **(** :ref:`int<class_int>` order=2 **)** |const| |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Quaternion<class_Quaternion>` | :ref:`inverse<class_Quaternion_method_inverse>` **(** **)** |const| |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`is_equal_approx<class_Quaternion_method_is_equal_approx>` **(** :ref:`Quaternion<class_Quaternion>` to **)** |const| |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`is_finite<class_Quaternion_method_is_finite>` **(** **)** |const| |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`is_normalized<class_Quaternion_method_is_normalized>` **(** **)** |const| |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`float<class_float>` | :ref:`length<class_Quaternion_method_length>` **(** **)** |const| |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`float<class_float>` | :ref:`length_squared<class_Quaternion_method_length_squared>` **(** **)** |const| |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Quaternion<class_Quaternion>` | :ref:`log<class_Quaternion_method_log>` **(** **)** |const| |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Quaternion<class_Quaternion>` | :ref:`normalized<class_Quaternion_method_normalized>` **(** **)** |const| |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Quaternion<class_Quaternion>` | :ref:`slerp<class_Quaternion_method_slerp>` **(** :ref:`Quaternion<class_Quaternion>` to, :ref:`float<class_float>` weight **)** |const| |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Quaternion<class_Quaternion>` | :ref:`slerpni<class_Quaternion_method_slerpni>` **(** :ref:`Quaternion<class_Quaternion>` to, :ref:`float<class_float>` weight **)** |const| |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Quaternion<class_Quaternion>` | :ref:`spherical_cubic_interpolate<class_Quaternion_method_spherical_cubic_interpolate>` **(** :ref:`Quaternion<class_Quaternion>` b, :ref:`Quaternion<class_Quaternion>` pre_a, :ref:`Quaternion<class_Quaternion>` post_b, :ref:`float<class_float>` weight **)** |const| |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Quaternion<class_Quaternion>` | :ref:`spherical_cubic_interpolate_in_time<class_Quaternion_method_spherical_cubic_interpolate_in_time>` **(** :ref:`Quaternion<class_Quaternion>` b, :ref:`Quaternion<class_Quaternion>` pre_a, :ref:`Quaternion<class_Quaternion>` post_b, :ref:`float<class_float>` weight, :ref:`float<class_float>` b_t, :ref:`float<class_float>` pre_a_t, :ref:`float<class_float>` post_b_t **)** |const| |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
.. rst-class:: classref-reftable-group
Operators
---------
.. table::
:widths: auto
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`operator !=<class_Quaternion_operator_neq_Quaternion>` **(** :ref:`Quaternion<class_Quaternion>` right **)** |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------+
| :ref:`Quaternion<class_Quaternion>` | :ref:`operator *<class_Quaternion_operator_mul_Quaternion>` **(** :ref:`Quaternion<class_Quaternion>` right **)** |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------+
| :ref:`Vector3<class_Vector3>` | :ref:`operator *<class_Quaternion_operator_mul_Vector3>` **(** :ref:`Vector3<class_Vector3>` right **)** |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------+
| :ref:`Quaternion<class_Quaternion>` | :ref:`operator *<class_Quaternion_operator_mul_float>` **(** :ref:`float<class_float>` right **)** |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------+
| :ref:`Quaternion<class_Quaternion>` | :ref:`operator *<class_Quaternion_operator_mul_int>` **(** :ref:`int<class_int>` right **)** |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------+
| :ref:`Quaternion<class_Quaternion>` | :ref:`operator +<class_Quaternion_operator_sum_Quaternion>` **(** :ref:`Quaternion<class_Quaternion>` right **)** |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------+
| :ref:`Quaternion<class_Quaternion>` | :ref:`operator -<class_Quaternion_operator_dif_Quaternion>` **(** :ref:`Quaternion<class_Quaternion>` right **)** |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------+
| :ref:`Quaternion<class_Quaternion>` | :ref:`operator /<class_Quaternion_operator_div_float>` **(** :ref:`float<class_float>` right **)** |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------+
| :ref:`Quaternion<class_Quaternion>` | :ref:`operator /<class_Quaternion_operator_div_int>` **(** :ref:`int<class_int>` right **)** |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`operator ==<class_Quaternion_operator_eq_Quaternion>` **(** :ref:`Quaternion<class_Quaternion>` right **)** |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------+
| :ref:`float<class_float>` | :ref:`operator []<class_Quaternion_operator_idx_int>` **(** :ref:`int<class_int>` index **)** |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------+
| :ref:`Quaternion<class_Quaternion>` | :ref:`operator unary+<class_Quaternion_operator_unplus>` **(** **)** |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------+
| :ref:`Quaternion<class_Quaternion>` | :ref:`operator unary-<class_Quaternion_operator_unminus>` **(** **)** |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------+
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Constants
---------
.. _class_Quaternion_constant_IDENTITY:
.. rst-class:: classref-constant
**IDENTITY** = ``Quaternion(0, 0, 0, 1)``
The identity quaternion, representing no rotation. Equivalent to an identity :ref:`Basis<class_Basis>` matrix. If a vector is transformed by an identity quaternion, it will not change.
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Property Descriptions
---------------------
.. _class_Quaternion_property_w:
.. rst-class:: classref-property
:ref:`float<class_float>` **w** = ``1.0``
W component of the quaternion (real part).
Quaternion components should usually not be manipulated directly.
.. rst-class:: classref-item-separator
----
.. _class_Quaternion_property_x:
.. rst-class:: classref-property
:ref:`float<class_float>` **x** = ``0.0``
X component of the quaternion (imaginary ``i`` axis part).
Quaternion components should usually not be manipulated directly.
.. rst-class:: classref-item-separator
----
.. _class_Quaternion_property_y:
.. rst-class:: classref-property
:ref:`float<class_float>` **y** = ``0.0``
Y component of the quaternion (imaginary ``j`` axis part).
Quaternion components should usually not be manipulated directly.
.. rst-class:: classref-item-separator
----
.. _class_Quaternion_property_z:
.. rst-class:: classref-property
:ref:`float<class_float>` **z** = ``0.0``
Z component of the quaternion (imaginary ``k`` axis part).
Quaternion components should usually not be manipulated directly.
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Constructor Descriptions
------------------------
.. _class_Quaternion_constructor_Quaternion:
.. rst-class:: classref-constructor
:ref:`Quaternion<class_Quaternion>` **Quaternion** **(** **)**
Constructs a default-initialized quaternion with all components set to ``0``.
.. rst-class:: classref-item-separator
----
.. rst-class:: classref-constructor
:ref:`Quaternion<class_Quaternion>` **Quaternion** **(** :ref:`Quaternion<class_Quaternion>` from **)**
Constructs a **Quaternion** as a copy of the given **Quaternion**.
.. rst-class:: classref-item-separator
----
.. rst-class:: classref-constructor
:ref:`Quaternion<class_Quaternion>` **Quaternion** **(** :ref:`Vector3<class_Vector3>` arc_from, :ref:`Vector3<class_Vector3>` arc_to **)**
Constructs a quaternion representing the shortest arc between two points on the surface of a sphere with a radius of ``1.0``.
.. rst-class:: classref-item-separator
----
.. rst-class:: classref-constructor
:ref:`Quaternion<class_Quaternion>` **Quaternion** **(** :ref:`Vector3<class_Vector3>` axis, :ref:`float<class_float>` angle **)**
Constructs a quaternion that will rotate around the given axis by the specified angle. The axis must be a normalized vector.
.. rst-class:: classref-item-separator
----
.. rst-class:: classref-constructor
:ref:`Quaternion<class_Quaternion>` **Quaternion** **(** :ref:`Basis<class_Basis>` from **)**
Constructs a quaternion from the given :ref:`Basis<class_Basis>`.
.. rst-class:: classref-item-separator
----
.. rst-class:: classref-constructor
:ref:`Quaternion<class_Quaternion>` **Quaternion** **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y, :ref:`float<class_float>` z, :ref:`float<class_float>` w **)**
Constructs a quaternion defined by the given values.
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Method Descriptions
-------------------
.. _class_Quaternion_method_angle_to:
.. rst-class:: classref-method
:ref:`float<class_float>` **angle_to** **(** :ref:`Quaternion<class_Quaternion>` to **)** |const|
Returns the angle between this quaternion and ``to``. This is the magnitude of the angle you would need to rotate by to get from one to the other.
\ **Note:** The magnitude of the floating-point error for this method is abnormally high, so methods such as ``is_zero_approx`` will not work reliably.
.. rst-class:: classref-item-separator
----
.. _class_Quaternion_method_dot:
.. rst-class:: classref-method
:ref:`float<class_float>` **dot** **(** :ref:`Quaternion<class_Quaternion>` with **)** |const|
Returns the dot product of two quaternions.
.. rst-class:: classref-item-separator
----
.. _class_Quaternion_method_exp:
.. rst-class:: classref-method
:ref:`Quaternion<class_Quaternion>` **exp** **(** **)** |const|
.. container:: contribute
There is currently no description for this method. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
.. rst-class:: classref-item-separator
----
.. _class_Quaternion_method_from_euler:
.. rst-class:: classref-method
:ref:`Quaternion<class_Quaternion>` **from_euler** **(** :ref:`Vector3<class_Vector3>` euler **)** |static|
Constructs a Quaternion from Euler angles in YXZ rotation order.
.. rst-class:: classref-item-separator
----
.. _class_Quaternion_method_get_angle:
.. rst-class:: classref-method
:ref:`float<class_float>` **get_angle** **(** **)** |const|
.. container:: contribute
There is currently no description for this method. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
.. rst-class:: classref-item-separator
----
.. _class_Quaternion_method_get_axis:
.. rst-class:: classref-method
:ref:`Vector3<class_Vector3>` **get_axis** **(** **)** |const|
.. container:: contribute
There is currently no description for this method. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
.. rst-class:: classref-item-separator
----
.. _class_Quaternion_method_get_euler:
.. rst-class:: classref-method
:ref:`Vector3<class_Vector3>` **get_euler** **(** :ref:`int<class_int>` order=2 **)** |const|
Returns the quaternion's rotation in the form of Euler angles. The Euler order depends on the ``order`` parameter, for example using the YXZ convention: since this method decomposes, first Z, then X, and Y last. See the :ref:`EulerOrder<enum_@GlobalScope_EulerOrder>` enum for possible values. The returned vector contains the rotation angles in the format (X angle, Y angle, Z angle).
.. rst-class:: classref-item-separator
----
.. _class_Quaternion_method_inverse:
.. rst-class:: classref-method
:ref:`Quaternion<class_Quaternion>` **inverse** **(** **)** |const|
Returns the inverse of the quaternion.
.. rst-class:: classref-item-separator
----
.. _class_Quaternion_method_is_equal_approx:
.. rst-class:: classref-method
:ref:`bool<class_bool>` **is_equal_approx** **(** :ref:`Quaternion<class_Quaternion>` to **)** |const|
Returns ``true`` if this quaternion and ``to`` are approximately equal, by running :ref:`@GlobalScope.is_equal_approx<class_@GlobalScope_method_is_equal_approx>` on each component.
.. rst-class:: classref-item-separator
----
.. _class_Quaternion_method_is_finite:
.. rst-class:: classref-method
:ref:`bool<class_bool>` **is_finite** **(** **)** |const|
Returns ``true`` if this quaternion is finite, by calling :ref:`@GlobalScope.is_finite<class_@GlobalScope_method_is_finite>` on each component.
.. rst-class:: classref-item-separator
----
.. _class_Quaternion_method_is_normalized:
.. rst-class:: classref-method
:ref:`bool<class_bool>` **is_normalized** **(** **)** |const|
Returns whether the quaternion is normalized or not.
.. rst-class:: classref-item-separator
----
.. _class_Quaternion_method_length:
.. rst-class:: classref-method
:ref:`float<class_float>` **length** **(** **)** |const|
Returns the length of the quaternion.
.. rst-class:: classref-item-separator
----
.. _class_Quaternion_method_length_squared:
.. rst-class:: classref-method
:ref:`float<class_float>` **length_squared** **(** **)** |const|
Returns the length of the quaternion, squared.
.. rst-class:: classref-item-separator
----
.. _class_Quaternion_method_log:
.. rst-class:: classref-method
:ref:`Quaternion<class_Quaternion>` **log** **(** **)** |const|
.. container:: contribute
There is currently no description for this method. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
.. rst-class:: classref-item-separator
----
.. _class_Quaternion_method_normalized:
.. rst-class:: classref-method
:ref:`Quaternion<class_Quaternion>` **normalized** **(** **)** |const|
Returns a copy of the quaternion, normalized to unit length.
.. rst-class:: classref-item-separator
----
.. _class_Quaternion_method_slerp:
.. rst-class:: classref-method
:ref:`Quaternion<class_Quaternion>` **slerp** **(** :ref:`Quaternion<class_Quaternion>` to, :ref:`float<class_float>` weight **)** |const|
Returns the result of the spherical linear interpolation between this quaternion and ``to`` by amount ``weight``.
\ **Note:** Both quaternions must be normalized.
.. rst-class:: classref-item-separator
----
.. _class_Quaternion_method_slerpni:
.. rst-class:: classref-method
:ref:`Quaternion<class_Quaternion>` **slerpni** **(** :ref:`Quaternion<class_Quaternion>` to, :ref:`float<class_float>` weight **)** |const|
Returns the result of the spherical linear interpolation between this quaternion and ``to`` by amount ``weight``, but without checking if the rotation path is not bigger than 90 degrees.
.. rst-class:: classref-item-separator
----
.. _class_Quaternion_method_spherical_cubic_interpolate:
.. rst-class:: classref-method
:ref:`Quaternion<class_Quaternion>` **spherical_cubic_interpolate** **(** :ref:`Quaternion<class_Quaternion>` b, :ref:`Quaternion<class_Quaternion>` pre_a, :ref:`Quaternion<class_Quaternion>` post_b, :ref:`float<class_float>` weight **)** |const|
Performs a spherical cubic interpolation between quaternions ``pre_a``, this vector, ``b``, and ``post_b``, by the given amount ``weight``.
.. rst-class:: classref-item-separator
----
.. _class_Quaternion_method_spherical_cubic_interpolate_in_time:
.. rst-class:: classref-method
:ref:`Quaternion<class_Quaternion>` **spherical_cubic_interpolate_in_time** **(** :ref:`Quaternion<class_Quaternion>` b, :ref:`Quaternion<class_Quaternion>` pre_a, :ref:`Quaternion<class_Quaternion>` post_b, :ref:`float<class_float>` weight, :ref:`float<class_float>` b_t, :ref:`float<class_float>` pre_a_t, :ref:`float<class_float>` post_b_t **)** |const|
Performs a spherical cubic interpolation between quaternions ``pre_a``, this vector, ``b``, and ``post_b``, by the given amount ``weight``.
It can perform smoother interpolation than ``spherical_cubic_interpolate()`` by the time values.
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Operator Descriptions
---------------------
.. _class_Quaternion_operator_neq_Quaternion:
.. rst-class:: classref-operator
:ref:`bool<class_bool>` **operator !=** **(** :ref:`Quaternion<class_Quaternion>` right **)**
Returns ``true`` if the quaternions are not equal.
\ **Note:** Due to floating-point precision errors, consider using :ref:`is_equal_approx<class_Quaternion_method_is_equal_approx>` instead, which is more reliable.
.. rst-class:: classref-item-separator
----
.. _class_Quaternion_operator_mul_Quaternion:
.. rst-class:: classref-operator
:ref:`Quaternion<class_Quaternion>` **operator *** **(** :ref:`Quaternion<class_Quaternion>` right **)**
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).
.. rst-class:: classref-item-separator
----
.. _class_Quaternion_operator_mul_Vector3:
.. rst-class:: classref-operator
:ref:`Vector3<class_Vector3>` **operator *** **(** :ref:`Vector3<class_Vector3>` right **)**
Rotates (multiplies) the :ref:`Vector3<class_Vector3>` by the given **Quaternion**.
.. rst-class:: classref-item-separator
----
.. _class_Quaternion_operator_mul_float:
.. rst-class:: classref-operator
:ref:`Quaternion<class_Quaternion>` **operator *** **(** :ref:`float<class_float>` right **)**
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.
.. rst-class:: classref-item-separator
----
.. _class_Quaternion_operator_mul_int:
.. rst-class:: classref-operator
:ref:`Quaternion<class_Quaternion>` **operator *** **(** :ref:`int<class_int>` right **)**
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.
.. rst-class:: classref-item-separator
----
.. _class_Quaternion_operator_sum_Quaternion:
.. rst-class:: classref-operator
:ref:`Quaternion<class_Quaternion>` **operator +** **(** :ref:`Quaternion<class_Quaternion>` right **)**
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.
.. rst-class:: classref-item-separator
----
.. _class_Quaternion_operator_dif_Quaternion:
.. rst-class:: classref-operator
:ref:`Quaternion<class_Quaternion>` **operator -** **(** :ref:`Quaternion<class_Quaternion>` right **)**
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.
.. rst-class:: classref-item-separator
----
.. _class_Quaternion_operator_div_float:
.. rst-class:: classref-operator
:ref:`Quaternion<class_Quaternion>` **operator /** **(** :ref:`float<class_float>` right **)**
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.
.. rst-class:: classref-item-separator
----
.. _class_Quaternion_operator_div_int:
.. rst-class:: classref-operator
:ref:`Quaternion<class_Quaternion>` **operator /** **(** :ref:`int<class_int>` right **)**
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.
.. rst-class:: classref-item-separator
----
.. _class_Quaternion_operator_eq_Quaternion:
.. rst-class:: classref-operator
:ref:`bool<class_bool>` **operator ==** **(** :ref:`Quaternion<class_Quaternion>` right **)**
Returns ``true`` if the quaternions are exactly equal.
\ **Note:** Due to floating-point precision errors, consider using :ref:`is_equal_approx<class_Quaternion_method_is_equal_approx>` instead, which is more reliable.
.. rst-class:: classref-item-separator
----
.. _class_Quaternion_operator_idx_int:
.. rst-class:: classref-operator
:ref:`float<class_float>` **operator []** **(** :ref:`int<class_int>` index **)**
Access quaternion components using their index. ``q[0]`` is equivalent to ``q.x``, ``q[1]`` is equivalent to ``q.y``, ``q[2]`` is equivalent to ``q.z``, and ``q[3]`` is equivalent to ``q.w``.
.. rst-class:: classref-item-separator
----
.. _class_Quaternion_operator_unplus:
.. rst-class:: classref-operator
:ref:`Quaternion<class_Quaternion>` **operator unary+** **(** **)**
Returns the same value as if the ``+`` was not there. Unary ``+`` does nothing, but sometimes it can make your code more readable.
.. rst-class:: classref-item-separator
----
.. _class_Quaternion_operator_unminus:
.. rst-class:: classref-operator
:ref:`Quaternion<class_Quaternion>` **operator unary-** **(** **)**
Returns the negative value of the **Quaternion**. This is the same as writing ``Quaternion(-q.x, -q.y, -q.z, -q.w)``. This operation results in a quaternion that represents the same rotation.
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
.. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
.. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`