Appearance
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
staticpackedLength:number
The number of elements used to pack the object into an array.
packedInterpolationLength
staticpackedInterpolationLength:number
The number of elements used to store the object into an array in its interpolatable form.
ZERO
readonlystaticZERO:Quaternion
An immutable Quaternion instance initialized to (0.0, 0.0, 0.0, 0.0).
IDENTITY
readonlystaticIDENTITY: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()
staticfromAxisAngle(axis:Cartesian3,angle:number,result?:Quaternion):Quaternion
Computes a quaternion representing a rotation around an axis.
参数
axis
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()
staticfromRotationMatrix(matrix:Matrix3,result?:Quaternion):Quaternion
Computes a Quaternion from the provided Matrix3 instance.
参数
matrix
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()
staticfromHeadingPitchRoll(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
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()
staticpack(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()
staticunpack(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()
staticconvertPackedArrayForInterpolation(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()
staticunpackInterpolationResult(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()
staticclone(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()
staticconjugate(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()
staticmagnitudeSquared(quaternion:Quaternion):number
Computes magnitude squared for the provided quaternion.
参数
quaternion
Quaternion
The quaternion to conjugate.
返回
number
The magnitude squared.
magnitude()
staticmagnitude(quaternion:Quaternion):number
Computes magnitude for the provided quaternion.
参数
quaternion
Quaternion
The quaternion to conjugate.
返回
number
The magnitude.
normalize()
staticnormalize(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()
staticinverse(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()
staticadd(left:Quaternion,right:Quaternion,result:Quaternion):Quaternion
Computes the componentwise sum 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.
subtract()
staticsubtract(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()
staticnegate(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()
staticdot(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()
staticmultiply(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()
staticmultiplyByScalar(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()
staticdivideByScalar(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()
staticcomputeAxis(quaternion:Quaternion,result:Cartesian3):Cartesian3
Computes the axis of rotation of the provided quaternion.
参数
quaternion
Quaternion
The quaternion to use.
result
The object onto which to store the result.
返回
The modified result parameter.
computeAngle()
staticcomputeAngle(quaternion:Quaternion):number
Computes the angle of rotation of the provided quaternion.
参数
quaternion
Quaternion
The quaternion to use.
返回
number
The angle of rotation.
lerp()
staticlerp(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()
staticslerp(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()
staticlog(quaternion:Quaternion,result:Cartesian3):Cartesian3
The logarithmic quaternion function.
参数
quaternion
Quaternion
The unit quaternion.
result
The object onto which to store the result.
返回
The modified result parameter.
exp()
staticexp(cartesian:Cartesian3,result:Quaternion):Quaternion
The exponential quaternion function.
参数
cartesian
The cartesian.
result
Quaternion
The object onto which to store the result.
返回
Quaternion
The modified result parameter.
computeInnerQuadrangle()
staticcomputeInnerQuadrangle(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()
staticsquad(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()
staticfastSlerp(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()
staticfastSquad(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()
staticequals(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()
staticequalsEpsilon(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
