Options
All
• Public
• Public/Protected
• All

# Class Quat

## Constructors

### constructor

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

## Properties

w: number

w 分量。

x: number

x 分量。

y: number

y 分量。

z: number

z 分量。

### Static IDENTITY

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

## Methods

### 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

• 将当前四元数转化为欧拉角（x-y-z）并赋值给出口向量。

#### Parameters

• ##### out: Vec3

the output vector

### 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].

### set

• set(other: Quat): Quat
• set(x?: undefined | number, y?: undefined | number, z?: undefined | number, w?: undefined | number): Quat
• 设置当前四元数使其与指定四元数相等。

#### Parameters

• ##### other: Quat

Specified quaternion

#### Returns Quat

this

• 设置当前四元数指定元素值。

this

### slerp

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

#### Parameters

• ##### to: Quat

The target quaternion

• ##### ratio: number

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

### 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
• 根据 xyz 分量计算 w 分量，默认已归一化

### Static clone

• clone<Out>(a: Out): Quat
• 获得指定四元数的拷贝

### Static conjugate

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

### Static copy

• copy<Out, QuatLike>(out: Out, a: QuatLike): Out
• 复制目标四元数

### Static dot

• dot<Out>(a: Out, b: Out): number
• 四元数点积（数量积）

### Static equals

• 排除浮点数误差的四元数近似等价判断

### Static fromAngleZ

• fromAngleZ<Out>(out: Out, z: number): Out
• 根据 2D 角度（0, 0, z）计算四元数

#### Parameters

• ##### out: Out

Output quaternion

• ##### z: number

Angle to rotate around Z axis in degrees.

### Static fromArray

• 数组转四元数

#### Parameters

• ##### Default value ofs: number = 0

Array Start Offset

### Static fromAxes

• fromAxes<Out, VecLike>(out: Out, xAxis: VecLike, yAxis: VecLike, zAxis: VecLike): 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

### Static fromMat3

• fromMat3<Out>(out: Out, m: Mat3): Out
• 根据三维矩阵信息计算四元数，默认输入矩阵不含有缩放信息

### Static fromViewUp

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

#### Parameters

• ##### 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).

### Static getAxisAngle

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

#### Parameters

• ##### outAxis: VecLike

output axis

• ##### q: Out

input quaternion

### 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
• 逐元素线性插值： A + t * (B - A)

### 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
• 绕世界空间下指定轴旋转四元数

#### Parameters

• ##### axis: VecLike

axis of rotation, normalized by default

### Static rotateAroundLocal

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

#### Parameters

• ##### axis: VecLike

axis of rotation

### Static rotateX

• rotateX<Out>(out: Out, a: Out, rad: number): Out
• 绕 X 轴旋转指定四元数

### Static rotateY

• rotateY<Out>(out: Out, a: Out, rad: number): Out
• 绕 Y 轴旋转指定四元数

### Static rotateZ

• rotateZ<Out>(out: Out, a: Out, rad: number): Out
• 绕 Z 轴旋转指定四元数

### Static rotationTo

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

#### Returns Out

• scaleAndAdd<Out>(out: Out, a: Out, b: Out, scale: number): Out
• 四元数乘加：A + B * scale

### 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
• 带两个控制点的四元数球面插值

• 四元数等价判断

### Static toArray

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

#### Parameters

• ##### Default value ofs: number = 0

Array Start Offset

### Static toAxisX

• 返回定义此四元数的坐标系 X 轴向量

### Static toAxisY

• 返回定义此四元数的坐标系 Y 轴向量

### Static toAxisZ

• 返回定义此四元数的坐标系 Z 轴向量

### Static toEuler

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

#### Parameters

• ##### Optional outerZ: undefined | false | true

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

#### Returns IVec3Like

Generated using TypeDoc