xr-frame / Exports / Quaternion

# Class: Quaternion

# Table of contents

# Constructors

# Properties

# Accessors

# Methods

# Constructors

# constructor

new Quaternion(raw?, offset?)

# Parameters

Name Type
raw? Float32Array
offset? number

# Properties

# DEFAULT

Static Readonly DEFAULT: Quaternion

默认四元数,不要对该对象进行修改

readonly

static

memberof Quaternion


# Phys3D

Static Optional Phys3D: typeof phys3D

# Accessors

# w

get w(): number

w值

memberof Quaternion

# Returns

number

set w(val): void

w值

# Parameters

Name Type
val number

# Returns

void


# x

get x(): number

x值

memberof Quaternion

# Returns

number

set x(val): void

x值

# Parameters

Name Type
val number

# Returns

void


# y

get y(): number

y值

memberof Quaternion

# Returns

number

set y(val): void

y值

# Parameters

Name Type
val number

# Returns

void


# z

get z(): number

z值

memberof Quaternion

# Returns

number

set z(val): void

z值

# Parameters

Name Type
val number

# Returns

void

# Methods

# add

add(quat, dst?): Quaternion

四元数相加

memberof Quaternion

# Parameters

Name Type Description
quat Quaternion 目标四元数
dst? Quaternion -

# Returns

Quaternion

计算结果


# angleTo

angleTo(q): number

相对角度

# Parameters

Name Type
q Quaternion

# Returns

number


# clone

clone(): Quaternion

拷贝四元数

memberof Quaternion

# Returns

Quaternion

拷贝后的对象


# dot

dot(q): number

点乘

# Parameters

Name Type
q Quaternion

# Returns

number


# equal

equal(quat): boolean

判断与目标四元数的值是否相等

memberof Quaternion

# Parameters

Name Type Description
quat Quaternion 目标四元数

# Returns

boolean


# fromPhysics

fromPhysics(v): Quaternion

# Parameters

Name Type
v RawQuaternion

# Returns

Quaternion


# invert

invert(dst?): Quaternion

四元数反转

memberof Quaternion

# Parameters

Name Type
dst? Quaternion

# Returns

Quaternion

计算结果


# isDefault

isDefault(): boolean

四元数是否为默认四元数(表示零旋转)

memberof Quaternion

# Returns

boolean


# length

length(): number

# Returns

number


# multiply

multiply(quat, dst?): Quaternion

四元数相乘

memberof Quaternion

# Parameters

Name Type Description
quat Quaternion 目标四元数
dst? Quaternion -

# Returns

Quaternion

计算结果


# normalize

normalize(): Quaternion

# Returns

Quaternion


# premultiply

premultiply(q): Quaternion

# Parameters

Name Type
q Quaternion

# Returns

Quaternion


# rotateTowards

rotateTowards(q, step): Quaternion

转向对应的角度

# Parameters

Name Type
q any
step any

# Returns

Quaternion


# set

set(quat): Quaternion

拷贝目标四元数的值到自身

memberof Quaternion

# Parameters

Name Type Description
quat Quaternion 目标四元数

# Returns

Quaternion

自身


# setArray

setArray(value, offset?): Quaternion

# Parameters

Name Type
value ArrayLike<number>
offset? number

# Returns

Quaternion


# setFromEulerAngles

setFromEulerAngles(euler): void

# Parameters

Name Type
euler Vector3

# Returns

void


# setFromUnitVectors

setFromUnitVectors(vFrom, vTo): Quaternion

# Parameters

Name Type
vFrom any
vTo any

# Returns

Quaternion


# setFromYawRollPitch

setFromYawRollPitch(yaw, roll, pitch): void

# Parameters

Name Type
yaw number
roll number
pitch number

# Returns

void


# setValue

setValue(x, y, z, w): Quaternion

设置四元数的值

memberof Quaternion

# Parameters

Name Type
x number
y number
z number
w number

# Returns

Quaternion

自身


# slerp

slerp(right, t, dst?): Quaternion

球面插值

memberof Quaternion

# Parameters

Name Type Description
right Quaternion 目标四元数
t number 插值系数,越接近 1 则结果越接近目标
dst? Quaternion -

# Returns

Quaternion

计算结果


# sub

sub(quat, dst?): Quaternion

四元数相减

memberof Quaternion

# Parameters

Name Type Description
quat Quaternion 目标四元数
dst? Quaternion -

# Returns

Quaternion

计算结果


# toAxisUnit

toAxisUnit(): Vector3

对[1,1,1]向量进行转换。

# Returns

Vector3


# toEulerAngles

toEulerAngles(dst?): Vector3

将该四元数转换成欧拉角,x代表Pitch,y代表Yaw,z代表Roll 旋转的顺序为YXZ

memberof Quaternion

# Parameters

Name Type
dst? Vector3

# Returns

Vector3

计算结果


# toPhysics

toPhysics(): RawQuaternion

created by shanexyzhou 生成物理引擎内的RawQuaternion

# Returns

RawQuaternion


# transformVector3

transformVector3(vec): Vector3

# Parameters

Name Type
vec Vector3

# Returns

Vector3


# clearPhysicsPool

Static clearPhysicsPool(): void

# Returns

void


# createFromArray

Static createFromArray(array): Quaternion

使用一个数组创建 此操作会拷贝一份数组

static

memberof Quaternion

# Parameters

Name Type Description
array number[] 数据源,长度必须为4,否则会抛出异常

# Returns

Quaternion


# createFromAxisAngle

Static createFromAxisAngle(axis, rad, dst?): Quaternion

从轴向旋转创建

static

memberof Quaternion

# Parameters

Name Type Description
axis Vector3 旋转轴
rad number 旋转幅度
dst? Quaternion -

# Returns

Quaternion

计算结果


# createFromMatrix4

Static createFromMatrix4(mat, dst?): Quaternion

从旋转矩阵创建

static

memberof Quaternion

# Parameters

Name Type
mat Matrix4
dst? Quaternion

# Returns

Quaternion


# createFromNumber

Static createFromNumber(x, y, z, w): Quaternion

使用数值创建

static

memberof Quaternion

# Parameters

Name Type Description
x number x
y number y
z number z
w number w

# Returns

Quaternion

创建出来的四元数


# createFromTypedArray

Static createFromTypedArray(array, offset?): Quaternion

使用某个已有的typedArray创建 此操作不会拷贝数据,而是在原来的内存区域上操作

static

memberof Quaternion

# Parameters

Name Type Default value Description
array Float32Array undefined 数据源
offset number 0 -

# Returns

Quaternion


# createFromUnitVectors

Static createFromUnitVectors(vFrom, vTo): Quaternion

通过俩个向量创建四元数

# Parameters

Name Type
vFrom Vector3
vTo Vector3

# Returns

Quaternion


# fromEulerAngles

Static fromEulerAngles(euler, dst?): Quaternion

从欧拉角创建四元数

static

memberof Quaternion

# Parameters

Name Type Description
euler Vector3 欧拉角,x代表pitch,y代表yaw,z代表roll
dst? Quaternion -

# Returns

Quaternion


# fromPhysics

Static fromPhysics(v): Quaternion

created by shanexyzhou 从物理引擎内的RawQuaternion生成Quaternion

# Parameters

Name Type
v RawQuaternion

# Returns

Quaternion


# lookRotation

Static lookRotation(forward, up, dst?): Quaternion

由视角方向创建四元数

static

memberof Quaternion

# Parameters

Name Type Description
forward Vector3 前方向
up Vector3 上方向
dst? Quaternion -

# Returns

Quaternion

计算结果