基础类型 / Rotation
Rotation Class
欧拉角
由分量 (x,y,z) 组成的三维空间中的旋转量。
Rotation 是三个欧拉角Pitch、Yaw、Roll的封装 绕三个轴的旋转值:Pitch,Yaw,Roll翻译为俯仰角,偏航角,翻滚角。分别代表绕X轴,Y轴,Z轴的旋转值。
Precautions
所有旋转值均以度为单位存储
Table of contents
Properties
x: number |
|---|
| 旋转的 x 分量 |
y: number |
| 旋转的 y 分量 |
z: number |
| 旋转的 z 分量 |
Accessors
zero(): Rotation |
|---|
| 获取一个空旋转的角度 (0, 0, 0) |
Methods
add(a: Rotation, b: Rotation, outer?: Rotation): Rotation |
|---|
| 旋转量a加上旋转量b |
clone(): Rotation |
| 克隆当前旋转量 |
equals(other: Rotation, epsilon?: number): boolean |
| 判断当前角度是否在误差范围内与指定向量相等。 |
equalsAuthentic(other: Rotation, epsilon?: number): boolean |
| 判断当前真实角度是否在误差范围内与指定向量相等。 |
fromQuaternion(v: Quaternion, outer?: Rotation): Rotation |
| 转换Quaternion为Rotation |
fromString(v: string, outer?: Rotation): Rotation |
| 转换字符串数据为Rotation |
fromVector(v: Vector, outer?: Rotation): Rotation |
| 转换Vector为Rotation |
getForce(outer?): Vector |
| 获取此旋转后的方向向量 |
getInverse(outer?: Rotation): Rotation |
| 返回一个新的反向旋转。 |
multiply(a: Rotation, b: Rotation, outer?: Rotation): Rotation |
| 当前旋转量乘以一个旋转量 |
rotateVector(v): Vector |
| 当前角度旋转一个向量 |
set(v: Rotation): Rotation |
| 当前旋转量设置为新的旋转量 |
strictEquals(other: Rotation): boolean |
| 判断当前角度是否与指定向量相等。 |
subtract(a: Rotation, b: Rotation, outer?: Rotation): Rotation |
| 当前旋转量减去一个旋转量 |
toQuaternion(): Quaternion |
| 当前Rotation输出为四元数 |
toString(): string |
| 当前Rotation输出为字符串 |
add(a: Rotation, b: Rotation, outer?: Rotation): Rotation |
| 旋转量a加上旋转量b |
copy(a: Rotation, outer: Rotation): Rotation |
| 复制目标旋转 |
fromQuaternion(v: Quaternion, outer?: Rotation): Rotation |
| 转换Quaternion为Rotation |
fromString(v: string, outer?: Rotation): Rotation |
| 转换字符串数据为Rotation |
fromVector(v: Vector, outer?: Rotation): Rotation |
| 转换Vector为Rotation |
lerp(a: Rotation, b: Rotation, alpha: number): Rotation |
| 对两个旋转量进行插值 |
multiply(a: Rotation, b: Rotation, outer?: Rotation): Rotation |
| 当前旋转量乘以一个旋转量 |
subtract(a: Rotation, b: Rotation, outer?: Rotation): Rotation |
| 当前旋转量减去一个旋转量 |
构建一个新的 Rotation。值为(0, 0, 0)
• new Rotation(vector)
用给定的 vector 中的x, y, z值设定给 x, y, z 。
Parameters
vector Vector | 给定的 vector |
|---|
• new Rotation(forward, up)
构造一个旋转,将旋转 Vector.FORWARD 以指向给定的前向矢量的方向,向上矢量作为参考。
Precautions
如果向前和向上指向完全相同 (或相反)的方向,或者其中之一的长度为 0,则返回 (0, 0, 0)。
Parameters
forward Vector | 前向矢量 |
|---|---|
up Vector | 向上矢量 |
• new Rotation(rotation)
复制rotation,并返回一个新的。
Parameters
rotation Rotation | 复制的 Rotation 对象 |
|---|
• new Rotation(v)
通过四元数构造
Parameters
v Quaternion | 四元数 |
|---|
• new Rotation(x, y, z)
通过三个分量构造
Parameters
x number | 旋转的 x 分量 range: 不做限制 type: 浮点数 |
|---|---|
y number | 旋转的 y 分量 range: 不做限制 type: 浮点数 |
z number | 旋转的 z 分量 range: 不做限制 type: 浮点数 |
Properties
x
• x: number
旋转的 x 分量
y
• y: number
旋转的 y 分量
z
• z: number
旋转的 z 分量
Accessors
zero
• |
|---|
获取一个空旋转的角度 (0, 0, 0) Returns |
Rotation | Rotation (0, 0, 0) |
|---|
Methods
add
• add(a): Rotation
当前旋转量加上一个旋转量
Parameters
a Rotation | 旋转量a |
|---|---|
b Rotation | 旋转量b |
outer? Rotation | 接收结果的旋转量,即旋转相加的结果 default:null |
Returns
Rotation | 相加的结果 |
|---|
Parameters
a Rotation | 旋转量 |
|---|
clone
• clone(): Rotation
克隆当前旋转量
Returns
Rotation | 返回一个新的旋转量 |
|---|
equals
• equals(other, epsilon?): boolean
判断当前角度是否在误差范围内与指定向量相等。
Parameters
other Rotation | 比对的旋转量 |
|---|---|
epsilon? number | 误差值 default:1.e-7 range: 建议传入小于 1 的值。 type:浮点数 |
Returns
boolean | 比对的结果 |
|---|
equalsAuthentic
• equalsAuthentic(other, epsilon?): boolean
判断当前真实角度是否在误差范围内与指定向量相等。
Parameters
other Rotation | 比对的旋转量 |
|---|---|
epsilon? number | 误差值 default:1.e-7 range: 建议传入小于 1 的值。 type:浮点数 |
Returns
boolean | 比对的结果 |
|---|
fromQuaternion
• fromQuaternion(v): void
当前Rotation读取一个四元数
Parameters
v Quaternion | Quaternion |
|---|---|
outer? Rotation | 传入的Rotation对象 default:null |
Returns
Rotation | Rotation |
|---|
Parameters
v Quaternion | 读取的四元数数据 |
|---|
fromString
• fromString(str): void
当前Rotation读取一个字符串数据
Parameters
v string | 字符串 range:"0.00000,0.00000,0.00000" |
|---|---|
outer? Rotation | 传入的Rotation对象 default:null |
Returns
Rotation | Rotation |
|---|
Parameters
str string | 字符串数据 range:"P=-431602080.000000 Y=-431602080.000000 R=-431602080.000000" |
|---|
fromVector
• fromVector(v): void
当前Rotation读取一个Vector
Parameters
v Vector | Vector |
|---|---|
outer? Rotation | 传入的Rotation对象 default:null |
Returns
Rotation | Rotation |
|---|
Parameters
v Vector | 读取的向量数据 |
|---|
getForce
• getForce(outer?): Vector
获取此旋转后的方向向量
Parameters
outer? Vector | 被写入数据的向量, 传入的 outer 不能为null/undefined default:null |
|---|
Returns
Vector | 旋转的方向向量 |
|---|
Precautions
如果 outer 不为空, 返回 outer,否则返回一个新的 Rotation 对象, 建议传入 outer 来减少 new 对象且 outer 不能为 null/undefined
getInverse
• getInverse(outer?): Rotation
返回一个新的反向旋转。
Parameters
outer? Rotation | 被写入数据的旋转量 default:null |
|---|
Returns
Rotation | 反方向的旋转 |
|---|
Precautions
如果 outer 不为空, 返回 outer,否则返回一个新的 Rotation 对象, 建议传入 outer 来减少 new 对象且 outer 不能为 null/undefined
multiply
• multiply(v): Rotation
当前旋转量乘以一个旋转量 (相当于四元数叉乘)
Parameters
a Rotation | 旋转量a |
|---|---|
b Rotation | 旋转量b |
outer? Rotation | 接收结果的旋转量变量 default:null |
Returns
Rotation | 相乘的结果 |
|---|
Parameters
v Rotation | 旋转量 |
|---|
rotateVector
• rotateVector(v): Vector
当前角度旋转一个向量
Parameters
v Vector | 被旋转的向量 |
|---|
Returns
Vector | 旋转后的向量 |
|---|
set
• set(v): Rotation
当前旋转量设置为新的旋转量
Parameters
v Rotation | 旋转量 |
|---|
Returns
Rotation | 旋转量 |
|---|
• set(x, y, z): Rotation
为当前旋转量设置每个分量
Parameters
x number | 旋转的 x 分量 range:不做限制 type: 浮点数 |
|---|---|
y number | 旋转的 y 分量 range:不做限制 type: 浮点数 |
z number | 旋转的 z 分量 range:不做限制 type: 浮点数 |
Returns
Rotation | 旋转量 |
|---|
strictEquals
• strictEquals(other): boolean
判断当前角度是否与指定向量相等。
Parameters
other Rotation | 比对的旋转量 |
|---|
Returns
boolean | 比对的结果 |
|---|
subtract
• subtract(a): Rotation
当前旋转量减去一个旋转量
Parameters
a Rotation | 旋转量a |
|---|---|
b Rotation | 旋转量b |
outer? Rotation | 接收结果的旋转量变量 default:null |
Returns
Rotation | 相减的结果 |
|---|
Parameters
a Rotation | 旋转量 |
|---|
toQuaternion
• toQuaternion(): Quaternion
当前Rotation输出为四元数
Returns
Quaternion | 输出的四元数 |
|---|
toString
• toString(): string
当前Rotation输出为字符串
Returns
string | 输出的字符串数据 |
|---|
add
• Static add(a, b, outer?): Rotation
旋转量a加上旋转量b
Precautions
outer 不能为 null/undefined
Parameters
a Rotation | 旋转量a |
|---|---|
b Rotation | 旋转量b |
outer? Rotation | 接收结果的旋转量,即旋转相加的结果 default:null |
Returns
Rotation | 相加的结果 |
|---|
copy
• Static copy(a, outer): Rotation
复制目标旋转
Parameters
a Rotation | 目标旋转 |
|---|---|
outer Rotation | 接收结果的旋转 |
Returns
Rotation | 拷贝得到的新旋转对象 |
|---|
Precautions
outer 不能为 null/undefined
fromQuaternion
• Static fromQuaternion(v, outer?): Rotation
转换Quaternion为Rotation
Precautions
如果 outer 不为空, 返回 outer,否则返回一个新的 Rotation 对象, 建议传入 outer 来减少 new 对象且 outer 不能为 null/undefined
Parameters
v Quaternion | Quaternion |
|---|---|
outer? Rotation | 传入的Rotation对象 default:null |
Returns
Rotation | Rotation |
|---|
fromString
• Static fromString(v, outer?): Rotation
转换字符串数据为Rotation
Precautions
如果 outer 不为空, 返回 outer,否则返回一个新的 Rotation 对象, 建议传入 outer 来减少 new 对象且 outer 不能为 null/undefined
Parameters
v string | 字符串 range:"0.00000,0.00000,0.00000" |
|---|---|
outer? Rotation | 传入的Rotation对象 default:null |
Returns
Rotation | Rotation |
|---|
fromVector
• Static fromVector(v, outer?): Rotation
转换Vector为Rotation
Precautions
如果 outer 不为空, 返回 outer,否则返回一个新的 Rotation 对象, 建议传入 outer 来减少 new 对象且 outer 不能为 null/undefined
Parameters
v Vector | Vector |
|---|---|
outer? Rotation | 传入的Rotation对象 default:null |
Returns
Rotation | Rotation |
|---|
lerp
• Static lerp(a, b, alpha): Rotation
对两个旋转量进行插值
Parameters
a Rotation | 旋转量 a |
|---|---|
b Rotation | 旋转量 b |
alpha number | 插值 range: [0, 1] type:浮点数 |
Returns
Rotation | Rotation |
|---|
multiply
• Static multiply(a, b, outer?): Rotation
当前旋转量乘以一个旋转量
Precautions
outer 不能为 null/undefined
Parameters
a Rotation | 旋转量a |
|---|---|
b Rotation | 旋转量b |
outer? Rotation | 接收结果的旋转量变量 default:null |
Returns
Rotation | 相乘的结果 |
|---|
subtract
• Static subtract(a, b, outer?): Rotation
当前旋转量减去一个旋转量
Precautions
outer 不能为 null/undefined
Parameters
a Rotation | 旋转量a |
|---|---|
b Rotation | 旋转量b |
outer? Rotation | 接收结果的旋转量变量 default:null |
Returns
Rotation | 相减的结果 |
|---|