Skip to content

KBE3D / KBCore / Cesium / Quaternion

类: Quaternion

A set of 4-dimensional coordinates used to represent rotation in 3-dimensional space.

参数

The X component.

参数

The Y component.

参数

The Z component.

参数

The W component.

属性

packedLength

static packedLength: number

The number of elements used to pack the object into an array.


packedInterpolationLength

static packedInterpolationLength: number

The number of elements used to store the object into an array in its interpolatable form.


ZERO

readonly static ZERO: Quaternion

An immutable Quaternion instance initialized to (0.0, 0.0, 0.0, 0.0).


IDENTITY

readonly static IDENTITY: Quaternion

An immutable Quaternion instance initialized to (0.0, 0.0, 0.0, 1.0).


x

x: number

The X component.


y

y: number

The Y component.


z

z: number

The Z component.


w

w: number

The W component.

方法

fromAxisAngle()

static fromAxisAngle(axis: Cartesian3, angle: number, result?: Quaternion): Quaternion

Computes a quaternion representing a rotation around an axis.

参数

axis

Cartesian3

The axis of rotation.

angle

number

The angle in radians to rotate around the axis.

result?

Quaternion

The object onto which to store the result.

返回

Quaternion

The modified result parameter or a new Quaternion instance if one was not provided.


fromRotationMatrix()

static fromRotationMatrix(matrix: Matrix3, result?: Quaternion): Quaternion

Computes a Quaternion from the provided Matrix3 instance.

参数

matrix

Matrix3

The rotation matrix.

result?

Quaternion

The object onto which to store the result.

返回

Quaternion

The modified result parameter or a new Quaternion instance if one was not provided.


fromHeadingPitchRoll()

static fromHeadingPitchRoll(headingPitchRoll: HeadingPitchRoll, result?: Quaternion): Quaternion

Computes a rotation from the given heading, pitch and roll angles. Heading is the rotation about the negative z axis. Pitch is the rotation about the negative y axis. Roll is the rotation about the positive x axis.

参数

headingPitchRoll

HeadingPitchRoll

The rotation expressed as a heading, pitch and roll.

result?

Quaternion

The object onto which to store the result.

返回

Quaternion

The modified result parameter or a new Quaternion instance if none was provided.


pack()

static pack(value: Quaternion, array: number[], startingIndex?: number): number[]

Stores the provided instance into the provided array.

参数

value

Quaternion

The value to pack.

array

number[]

The array to pack into.

startingIndex?

number

The index into the array at which to start packing the elements.

返回

number[]

The array that was packed into


unpack()

static unpack(array: number[], startingIndex?: number, result?: Quaternion): Quaternion

Retrieves an instance from a packed array.

参数

array

number[]

The packed array.

startingIndex?

number

The starting index of the element to be unpacked.

result?

Quaternion

The object into which to store the result.

返回

Quaternion

The modified result parameter or a new Quaternion instance if one was not provided.


convertPackedArrayForInterpolation()

static convertPackedArrayForInterpolation(packedArray: number[], startingIndex?: number, lastIndex?: number, result?: number[]): void

Converts a packed array into a form suitable for interpolation.

参数

packedArray

number[]

The packed array.

startingIndex?

number

The index of the first element to be converted.

lastIndex?

number

The index of the last element to be converted.

result?

number[]

The object into which to store the result.

返回

void


unpackInterpolationResult()

static unpackInterpolationResult(array: number[], sourceArray: number[], firstIndex?: number, lastIndex?: number, result?: Quaternion): Quaternion

Retrieves an instance from a packed array converted with convertPackedArrayForInterpolation.

参数

array

number[]

The array previously packed for interpolation.

sourceArray

number[]

The original packed array.

firstIndex?

number

The firstIndex used to convert the array.

lastIndex?

number

The lastIndex used to convert the array.

result?

Quaternion

The object into which to store the result.

返回

Quaternion

The modified result parameter or a new Quaternion instance if one was not provided.


clone()

static clone(quaternion: Quaternion, result?: Quaternion): Quaternion

Duplicates a Quaternion instance.

参数

quaternion

Quaternion

The quaternion to duplicate.

result?

Quaternion

The object onto which to store the result.

返回

Quaternion

The modified result parameter or a new Quaternion instance if one was not provided. (Returns undefined if quaternion is undefined)


conjugate()

static conjugate(quaternion: Quaternion, result: Quaternion): Quaternion

Computes the conjugate of the provided quaternion.

参数

quaternion

Quaternion

The quaternion to conjugate.

result

Quaternion

The object onto which to store the result.

返回

Quaternion

The modified result parameter.


magnitudeSquared()

static magnitudeSquared(quaternion: Quaternion): number

Computes magnitude squared for the provided quaternion.

参数

quaternion

Quaternion

The quaternion to conjugate.

返回

number

The magnitude squared.


magnitude()

static magnitude(quaternion: Quaternion): number

Computes magnitude for the provided quaternion.

参数

quaternion

Quaternion

The quaternion to conjugate.

返回

number

The magnitude.


normalize()

static normalize(quaternion: Quaternion, result: Quaternion): Quaternion

Computes the normalized form of the provided quaternion.

参数

quaternion

Quaternion

The quaternion to normalize.

result

Quaternion

The object onto which to store the result.

返回

Quaternion

The modified result parameter.


inverse()

static inverse(quaternion: Quaternion, result: Quaternion): Quaternion

Computes the inverse of the provided quaternion.

参数

quaternion

Quaternion

The quaternion to normalize.

result

Quaternion

The object onto which to store the result.

返回

Quaternion

The modified result parameter.


add()

static add(left: Quaternion, right: Quaternion, result: Quaternion): Quaternion

Computes the componentwise sum of two quaternions.

参数

left

Quaternion

The first quaternion.

Quaternion

The second quaternion.

result

Quaternion

The object onto which to store the result.

返回

Quaternion

The modified result parameter.


subtract()

static subtract(left: Quaternion, right: Quaternion, result: Quaternion): Quaternion

Computes the componentwise difference of two quaternions.

参数

left

Quaternion

The first quaternion.

right

Quaternion

The second quaternion.

result

Quaternion

The object onto which to store the result.

返回

Quaternion

The modified result parameter.


negate()

static negate(quaternion: Quaternion, result: Quaternion): Quaternion

Negates the provided quaternion.

参数

quaternion

Quaternion

The quaternion to be negated.

result

Quaternion

The object onto which to store the result.

返回

Quaternion

The modified result parameter.


dot()

static dot(left: Quaternion, right: Quaternion): number

Computes the dot (scalar) product of two quaternions.

参数

left

Quaternion

The first quaternion.

right

Quaternion

The second quaternion.

返回

number

The dot product.


multiply()

static multiply(left: Quaternion, right: Quaternion, result: Quaternion): Quaternion

Computes the product of two quaternions.

参数

left

Quaternion

The first quaternion.

right

Quaternion

The second quaternion.

result

Quaternion

The object onto which to store the result.

返回

Quaternion

The modified result parameter.


multiplyByScalar()

static multiplyByScalar(quaternion: Quaternion, scalar: number, result: Quaternion): Quaternion

Multiplies the provided quaternion componentwise by the provided scalar.

参数

quaternion

Quaternion

The quaternion to be scaled.

scalar

number

The scalar to multiply with.

result

Quaternion

The object onto which to store the result.

返回

Quaternion

The modified result parameter.


divideByScalar()

static divideByScalar(quaternion: Quaternion, scalar: number, result: Quaternion): Quaternion

Divides the provided quaternion componentwise by the provided scalar.

参数

quaternion

Quaternion

The quaternion to be divided.

scalar

number

The scalar to divide by.

result

Quaternion

The object onto which to store the result.

返回

Quaternion

The modified result parameter.


computeAxis()

static computeAxis(quaternion: Quaternion, result: Cartesian3): Cartesian3

Computes the axis of rotation of the provided quaternion.

参数

quaternion

Quaternion

The quaternion to use.

result

Cartesian3

The object onto which to store the result.

返回

Cartesian3

The modified result parameter.


computeAngle()

static computeAngle(quaternion: Quaternion): number

Computes the angle of rotation of the provided quaternion.

参数

quaternion

Quaternion

The quaternion to use.

返回

number

The angle of rotation.


lerp()

static lerp(start: Quaternion, end: Quaternion, t: number, result: Quaternion): Quaternion

Computes the linear interpolation or extrapolation at t using the provided quaternions.

参数

start

Quaternion

The value corresponding to t at 0.0.

end

Quaternion

The value corresponding to t at 1.0.

t

number

The point along t at which to interpolate.

result

Quaternion

The object onto which to store the result.

返回

Quaternion

The modified result parameter.


slerp()

static slerp(start: Quaternion, end: Quaternion, t: number, result: Quaternion): Quaternion

Computes the spherical linear interpolation or extrapolation at t using the provided quaternions.

参数

start

Quaternion

The value corresponding to t at 0.0.

end

Quaternion

The value corresponding to t at 1.0.

t

number

The point along t at which to interpolate.

result

Quaternion

The object onto which to store the result.

返回

Quaternion

The modified result parameter.


log()

static log(quaternion: Quaternion, result: Cartesian3): Cartesian3

The logarithmic quaternion function.

参数

quaternion

Quaternion

The unit quaternion.

result

Cartesian3

The object onto which to store the result.

返回

Cartesian3

The modified result parameter.


exp()

static exp(cartesian: Cartesian3, result: Quaternion): Quaternion

The exponential quaternion function.

参数

cartesian

Cartesian3

The cartesian.

result

Quaternion

The object onto which to store the result.

返回

Quaternion

The modified result parameter.


computeInnerQuadrangle()

static computeInnerQuadrangle(q0: Quaternion, q1: Quaternion, q2: Quaternion, result: Quaternion): Quaternion

Computes an inner quadrangle point. <p>This will compute quaternions that ensure a squad curve is C<sup>1</sup>.</p>

参数

q0

Quaternion

The first quaternion.

q1

Quaternion

The second quaternion.

q2

Quaternion

The third quaternion.

result

Quaternion

The object onto which to store the result.

返回

Quaternion

The modified result parameter.


squad()

static squad(q0: Quaternion, q1: Quaternion, s0: Quaternion, s1: Quaternion, t: number, result: Quaternion): Quaternion

Computes the spherical quadrangle interpolation between quaternions.

参数

q0

Quaternion

The first quaternion.

q1

Quaternion

The second quaternion.

s0

Quaternion

The first inner quadrangle.

s1

Quaternion

The second inner quadrangle.

t

number

The time in [0,1] used to interpolate.

result

Quaternion

The object onto which to store the result.

返回

Quaternion

The modified result parameter.

示例

ts
// 1. compute the squad interpolation between two quaternions on a curve
const s0 = Cesium.Quaternion.computeInnerQuadrangle(quaternions[i - 1], quaternions[i], quaternions[i + 1], new Cesium.Quaternion());
const s1 = Cesium.Quaternion.computeInnerQuadrangle(quaternions[i], quaternions[i + 1], quaternions[i + 2], new Cesium.Quaternion());
const q = Cesium.Quaternion.squad(quaternions[i], quaternions[i + 1], s0, s1, t, new Cesium.Quaternion());

// 2. compute the squad interpolation as above but where the first quaternion is a end point.
const s1 = Cesium.Quaternion.computeInnerQuadrangle(quaternions[0], quaternions[1], quaternions[2], new Cesium.Quaternion());
const q = Cesium.Quaternion.squad(quaternions[0], quaternions[1], quaternions[0], s1, t, new Cesium.Quaternion());

fastSlerp()

static fastSlerp(start: Quaternion, end: Quaternion, t: number, result: Quaternion): Quaternion

Computes the spherical linear interpolation or extrapolation at t using the provided quaternions. This implementation is faster than Quaternion#slerp, but is only accurate up to 10<sup>-6</sup>.

参数

start

Quaternion

The value corresponding to t at 0.0.

end

Quaternion

The value corresponding to t at 1.0.

t

number

The point along t at which to interpolate.

result

Quaternion

The object onto which to store the result.

返回

Quaternion

The modified result parameter.


fastSquad()

static fastSquad(q0: Quaternion, q1: Quaternion, s0: Quaternion, s1: Quaternion, t: number, result: Quaternion): Quaternion

Computes the spherical quadrangle interpolation between quaternions. An implementation that is faster than Quaternion#squad, but less accurate.

参数

q0

Quaternion

The first quaternion.

q1

Quaternion

The second quaternion.

s0

Quaternion

The first inner quadrangle.

s1

Quaternion

The second inner quadrangle.

t

number

The time in [0,1] used to interpolate.

result

Quaternion

The object onto which to store the result.

返回

Quaternion

The modified result parameter or a new instance if none was provided.


equals()

static equals(left?: Quaternion, right?: Quaternion): boolean

Compares the provided quaternions componentwise and returns <code>true</code> if they are equal, <code>false</code> otherwise.

参数

left?

Quaternion

The first quaternion.

right?

Quaternion

The second quaternion.

返回

boolean

true if left and right are equal, false otherwise.


equalsEpsilon()

static equalsEpsilon(left?: Quaternion, right?: Quaternion, epsilon?: number): boolean

Compares the provided quaternions componentwise and returns <code>true</code> if they are within the provided epsilon, <code>false</code> otherwise.

参数

left?

Quaternion

The first quaternion.

right?

Quaternion

The second quaternion.

epsilon?

number

The epsilon to use for equality testing.

返回

boolean

true if left and right are within the provided epsilon, false otherwise.


clone()

clone(result?: Quaternion): Quaternion

Duplicates this Quaternion instance.

参数

result?

Quaternion

The object onto which to store the result.

返回

Quaternion

The modified result parameter or a new Quaternion instance if one was not provided.


equals()

equals(right?: Quaternion): boolean

Compares this and the provided quaternion componentwise and returns <code>true</code> if they are equal, <code>false</code> otherwise.

参数

right?

Quaternion

The right hand side quaternion.

返回

boolean

true if left and right are equal, false otherwise.


equalsEpsilon()

equalsEpsilon(right?: Quaternion, epsilon?: number): boolean

Compares this and the provided quaternion componentwise and returns <code>true</code> if they are within the provided epsilon, <code>false</code> otherwise.

参数

right?

Quaternion

The right hand side quaternion.

epsilon?

number

The epsilon to use for equality testing.

返回

boolean

true if left and right are within the provided epsilon, false otherwise.


toString()

toString(): string

Returns a string representing this quaternion in the format (x, y, z, w).

返回

string

A string representing this Quaternion.

构造函数

构造函数

new Quaternion(x?: number, y?: number, z?: number, w?: number): Quaternion

参数

x?

number

y?

number

z?

number

w?

number

返回

Quaternion

KBE3D @3.0.0 Copyright © 2024-present KBE3D