Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Quat

四元数

Hierarchy

Index

Constructors

constructor

  • newQuat(other: Quat): Quat
  • newQuat(x?: undefined | number, y?: undefined | number, z?: undefined | number, w?: undefined | number): Quat

Properties

w

w: number

w 分量。

x

x: number

x 分量。

y

y: number

y 分量。

z

z: number

z 分量。

Static IDENTITY

IDENTITY: {} = Object.freeze(new Quat())

Type declaration

Methods

clone

equals

  • equals(other: Quat, epsilon?: number): boolean
  • 判断当前四元数是否在误差范围内与指定向量相等。

    Parameters

    • other: Quat

      Comparative quaternion

    • Default value epsilon: number = EPSILON

      The error allowed. It`s should be a non-negative number.

    Returns boolean

    Returns true' when the components of the two quaternions are equal within the specified error range; otherwise, returnsfalse'.

getEulerAngles

length

  • length(): number

lengthSqr

  • lengthSqr(): number

lerp

  • lerp(to: Quat, ratio: number): this
  • 根据指定的插值比率,从当前四元数到目标四元数之间做线性插值。

    Parameters

    • to: Quat

      The target quaternion

    • ratio: number

      The interpolation coefficient. The range is [0,1].

    Returns this

set

  • set(other: Quat): Quat
  • set(x?: undefined | number, y?: undefined | number, z?: undefined | number, w?: undefined | number): Quat

slerp

  • slerp(to: Quat, ratio: number): this
  • 根据指定的插值比率,从当前四元数到目标四元数之间做球面插值。

    Parameters

    • to: Quat

      The target quaternion

    • ratio: number

      The interpolation coefficient. The range is [0,1].

    Returns this

strictEquals

  • strictEquals(other: Quat): boolean
  • 判断当前四元数是否与指定四元数相等。

    Parameters

    • other: Quat

      Comparative quaternion

    Returns boolean

    Returns true' when the components of the two quaternions are equal within the specified error range; otherwise, returnsfalse'.

toString

  • toString(): string

Static calculateW

  • calculateW<Out>(out: Out, a: Out): Out

Static clone

  • clone<Out>(a: Out): Quat

Static conjugate

  • conjugate<Out>(out: Out, a: Out): Out
  • 求共轭四元数,对单位四元数与求逆等价,但更高效

    Type parameters

    Parameters

    • out: Out
    • a: Out

    Returns Out

Static copy

  • copy<Out, QuatLike>(out: Out, a: QuatLike): Out

Static dot

  • dot<Out>(a: Out, b: Out): number

Static equals

Static fromArray

Static fromAxes

  • fromAxes<Out, VecLike>(out: Out, xAxis: VecLike, yAxis: VecLike, zAxis: VecLike): Out
  • 根据本地坐标轴朝向计算四元数,默认三向量都已归一化且相互垂直

    Type parameters

    Parameters

    • out: Out
    • xAxis: VecLike
    • yAxis: VecLike
    • zAxis: VecLike

    Returns Out

Static fromAxisAngle

  • fromAxisAngle<Out, VecLike>(out: Out, axis: VecLike, rad: number): Out

Static fromEuler

  • fromEuler<Out>(out: Out, x: number, y: number, z: number): Out
  • 根据欧拉角信息计算四元数,旋转顺序为 YZX

    Type parameters

    Parameters

    • out: Out
    • x: number
    • y: number
    • z: number

    Returns Out

Static fromMat3

  • fromMat3<Out>(out: Out, m: Mat3): Out

Static fromViewUp

  • fromViewUp<Out, VecLike>(out: Out, view: VecLike, up?: Vec3): Out
  • 根据视口的前方向和上方向计算四元数

    Type parameters

    Parameters

    • out: Out
    • view: VecLike

      The view direction, it`s must be normalized.

    • Optional up: Vec3

      The view up direction, it`s must be normalized, default value is (0, 1, 0).

    Returns Out

Static getAxisAngle

  • getAxisAngle<Out, VecLike>(outAxis: VecLike, q: Out): number
  • 获取四元数的旋转轴和旋转弧度

    Type parameters

    Parameters

    • outAxis: VecLike

      output axis

    • q: Out

      input quaternion

    Returns number

    radius of rotation

Static identity

  • identity<Out>(out: Out): Out

Static invert

  • invert<Out, QuatLike>(out: Out, a: QuatLike): Out

Static len

  • len<Out>(a: Out): number

Static lengthSqr

  • lengthSqr<Out>(a: Out): number

Static lerp

  • lerp<Out>(out: Out, a: Out, b: Out, t: number): Out

Static multiply

  • multiply<Out, QuatLike_1, QuatLike_2>(out: Out, a: QuatLike_1, b: QuatLike_2): Out

Static multiplyScalar

  • multiplyScalar<Out>(out: Out, a: Out, b: number): Out

Static normalize

  • normalize<Out>(out: Out, a: Out): Out

Static rotateAround

  • rotateAround<Out, VecLike>(out: Out, rot: Out, axis: VecLike, rad: number): Out
  • 绕世界空间下指定轴旋转四元数

    Type parameters

    Parameters

    • out: Out
    • rot: Out
    • axis: VecLike

      axis of rotation, normalized by default

    • rad: number

      radius of rotation

    Returns Out

Static rotateAroundLocal

  • rotateAroundLocal<Out, VecLike>(out: Out, rot: Out, axis: VecLike, rad: number): Out
  • 绕本地空间下指定轴旋转四元数

    Type parameters

    Parameters

    • out: Out
    • rot: Out
    • axis: VecLike

      axis of rotation

    • rad: number

      radius of rotation

    Returns Out

Static rotateX

  • rotateX<Out>(out: Out, a: Out, rad: number): Out

Static rotateY

  • rotateY<Out>(out: Out, a: Out, rad: number): Out

Static rotateZ

  • rotateZ<Out>(out: Out, a: Out, rad: number): Out

Static rotationTo

  • rotationTo<Out, VecLike>(out: Out, a: VecLike, b: VecLike): Out
  • 设置四元数为两向量间的最短路径旋转,默认两向量都已归一化

    Type parameters

    Parameters

    • out: Out
    • a: VecLike
    • b: VecLike

    Returns Out

Static scaleAndAdd

  • scaleAndAdd<Out>(out: Out, a: Out, b: Out, scale: number): Out

Static set

  • set<Out>(out: Out, x: number, y: number, z: number, w: number): Out

Static slerp

  • slerp<Out, QuatLike_1, QuatLike_2>(out: Out, a: QuatLike_1, b: QuatLike_2, t: number): Out

Static sqlerp

  • sqlerp<Out>(out: Out, a: Out, b: Out, c: Out, d: Out, t: number): Out
  • 带两个控制点的四元数球面插值

    Type parameters

    Parameters

    • out: Out
    • a: Out
    • b: Out
    • c: Out
    • d: Out
    • t: number

    Returns Out

Static strictEquals

Static toArray

  • toArray<Out>(out: Out, q: IQuatLike, ofs?: number): Out
  • 四元数转数组

    Type parameters

    • Out: IWritableArrayLike<number>

    Parameters

    • out: Out
    • q: IQuatLike
    • Default value ofs: number = 0

      Array Start Offset

    Returns Out

Static toAxisX

Static toAxisY

Static toAxisZ

Static toEuler

  • 根据四元数计算欧拉角,返回角度 x, y 在 [-180, 180] 区间内, z 默认在 [-90, 90] 区间内,旋转顺序为 YZX

    Parameters

    • out: IVec3Like
    • q: IQuatLike
    • Optional outerZ: undefined | false | true

      change z value range to [-180, -90] U [90, 180]

    Returns IVec3Like

Generated using TypeDoc