Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
Quaternion¶
A unit quaternion used for representing 3D rotations.
描述¶
Quaternions are similar to Basis, which implements the matrix representation of rotations. Unlike 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.
备注
There are notable differences when using this API with C#. See C# API 与 GDScript 的差异 for more information.
教程¶
属性¶
|
||
|
||
|
||
|
构造函数¶
Quaternion ( ) |
|
Quaternion ( Quaternion from ) |
|
Quaternion ( Vector3 arc_from, Vector3 arc_to ) |
|
Quaternion ( Vector3 axis, float angle ) |
|
Quaternion ( Basis from ) |
|
Quaternion ( float x, float y, float z, float w ) |
Methods¶
angle_to ( Quaternion to ) const |
|
dot ( Quaternion with ) const |
|
exp ( ) const |
|
from_euler ( Vector3 euler ) static |
|
get_angle ( ) const |
|
get_axis ( ) const |
|
inverse ( ) const |
|
is_equal_approx ( Quaternion to ) const |
|
is_finite ( ) const |
|
is_normalized ( ) const |
|
length ( ) const |
|
length_squared ( ) const |
|
log ( ) const |
|
normalized ( ) const |
|
slerp ( Quaternion to, float weight ) const |
|
slerpni ( Quaternion to, float weight ) const |
|
spherical_cubic_interpolate ( Quaternion b, Quaternion pre_a, Quaternion post_b, float weight ) const |
|
spherical_cubic_interpolate_in_time ( Quaternion b, Quaternion pre_a, Quaternion post_b, float weight, float b_t, float pre_a_t, float post_b_t ) const |
运算符¶
operator != ( Quaternion right ) |
|
operator * ( Quaternion right ) |
|
operator * ( Vector3 right ) |
|
operator * ( float right ) |
|
operator * ( int right ) |
|
operator + ( Quaternion right ) |
|
operator - ( Quaternion right ) |
|
operator / ( float right ) |
|
operator / ( int right ) |
|
operator == ( Quaternion right ) |
|
operator [] ( int index ) |
|
operator unary+ ( ) |
|
operator unary- ( ) |
常量¶
IDENTITY = 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.
Property Descriptions¶
float w = 1.0
W component of the quaternion (real part).
Quaternion components should usually not be manipulated directly.
float x = 0.0
X component of the quaternion (imaginary i
axis part).
Quaternion components should usually not be manipulated directly.
float y = 0.0
Y component of the quaternion (imaginary j
axis part).
Quaternion components should usually not be manipulated directly.
float z = 0.0
Z component of the quaternion (imaginary k
axis part).
Quaternion components should usually not be manipulated directly.
Constructor Descriptions¶
Quaternion Quaternion ( )
Constructs a default-initialized quaternion with all components set to 0
.
Quaternion Quaternion ( Quaternion from )
Constructs a Quaternion as a copy of the given Quaternion.
Quaternion Quaternion ( Vector3 arc_from, 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
.
Quaternion Quaternion ( Vector3 axis, float angle )
Constructs a quaternion that will rotate around the given axis by the specified angle. The axis must be a normalized vector.
Quaternion Quaternion ( Basis from )
Constructs a quaternion from the given Basis.
Quaternion Quaternion ( float x, float y, float z, float w )
Constructs a quaternion defined by the given values.
Method Descriptions¶
float angle_to ( Quaternion to ) const
Returns the angle between this quaternion and to
. This is the magnitude of the angle