Instance Methodmigueldeicaza.swiftgodot 0.45.0SwiftGodot
inverse
Returns the inverse of the quaternion.
Quaternion.swift:229func inverse() -> Quaternion
Other members in extension
Type members
init(
) Constructs a default-initialized quaternion with all components set to
0
.init(arcFrom: Vector3, arcTo: Vector3
) Constructs a quaternion representing the shortest arc between two points on the surface of a sphere with a radius of
1.0
.init(axis: Vector3, angle: Float
) Constructs a quaternion that will rotate around the given axis by the specified angle. The axis must be a normalized vector.
init(from: Quaternion
) Constructs a
Quaternion
as a copy of the givenQuaternion
.init(from: Basis
) Constructs a quaternion from the given
Basis
.init(x: Float, y: Float, z: Float, w: Float
) Constructs a quaternion defined by the given values.
static var godotType: Variant.GType
static let identity: Quaternion
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.static func fromEuler(Vector3
) -> Quaternion Constructs a Quaternion from Euler angles in YXZ rotation order.
static func != (lhs: Quaternion, rhs: Quaternion
) -> Bool Returns
true
if the quaternions are not equal.static func * (lhs: Quaternion, rhs: Quaternion
) -> Quaternion 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.static func * (lhs: Quaternion, rhs: Double
) -> Quaternion 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.static func * (lhs: Quaternion, rhs: Int64
) -> Quaternion 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.static func * (lhs: Quaternion, rhs: Vector3
) -> Vector3 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.static func + (lhs: Quaternion, rhs: Quaternion
) -> Quaternion Adds each component of the left
Quaternion
to the rightQuaternion
. 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.static func - (q: `Self`
) -> Quaternion 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.
static func - (lhs: Quaternion, rhs: Quaternion
) -> Quaternion Subtracts each component of the left
Quaternion
by the rightQuaternion
. This operation is not meaningful on its own, but it can be used as a part of a larger expression.static func / (lhs: Quaternion, rhs: Double
) -> Quaternion 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.static func / (lhs: Quaternion, rhs: Int64
) -> Quaternion 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.static func == (lhs: Quaternion, rhs: Quaternion
) -> Bool Returns
true
if the quaternions are exactly equal.
Instance members
var w: Float
W component of the quaternion (real part).
var x: Float
X component of the quaternion (imaginary
i
axis part).var y: Float
Y component of the quaternion (imaginary
j
axis part).var z: Float
Z component of the quaternion (imaginary
k
axis part).subscript(Int64
) -> Double func angleTo(Quaternion
) -> Double 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.func dot(with: Quaternion
) -> Double Returns the dot product of two quaternions.
func exp(
) -> Quaternion func getAngle(
) -> Double func getAxis(
) -> Vector3 func getEuler(order: Int64
) -> Vector3 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 theEulerOrder
enum for possible values. The returned vector contains the rotation angles in the format (X angle, Y angle, Z angle).func isEqualApprox(to: Quaternion
) -> Bool Returns
true
if this quaternion andto
are approximately equal, by running@GlobalScope.is_equal_approx
on each component.func isFinite(
) -> Bool Returns
true
if this quaternion is finite, by calling@GlobalScope.is_finite
on each component.func isNormalized(
) -> Bool Returns whether the quaternion is normalized or not.
func length(
) -> Double Returns the length of the quaternion.
func lengthSquared(
) -> Double Returns the length of the quaternion, squared.
func log(
) -> Quaternion func normalized(
) -> Quaternion Returns a copy of the quaternion, normalized to unit length.
func slerp(to: Quaternion, weight: Double
) -> Quaternion Returns the result of the spherical linear interpolation between this quaternion and
to
by amountweight
.func slerpni(to: Quaternion, weight: Double
) -> Quaternion Returns the result of the spherical linear interpolation between this quaternion and
to
by amountweight
, but without checking if the rotation path is not bigger than 90 degrees.func sphericalCubicInterpolate(b: Quaternion, preA: Quaternion, postB: Quaternion, weight: Double
) -> Quaternion Performs a spherical cubic interpolation between quaternions
preA
, this vector,b
, andpostB
, by the given amountweight
.func sphericalCubicInterpolateInTime(b: Quaternion, preA: Quaternion, postB: Quaternion, weight: Double, bT: Double, preAT: Double, postBT: Double
) -> Quaternion Performs a spherical cubic interpolation between quaternions
preA
, this vector,b
, andpostB
, by the given amountweight
.