🧭 旋转体
旋转信息(俯仰角、偏航角、横滚角)的容器。所有旋转值均以度为单位存储。
👐Open Source
This library implementation is Open Sourced on GitHub!
🧑💻API Source
This page is auto-generated! The Functions, Properties and Events described here are defined in our GitHub's API Repository! Feel free to commit suggestions and changes to the source .json API files!
信息
旋转体在内部进行自动压缩,这可以将其在网络中的大小减少高达 90%。 它们的组件通常每个都被压缩成 1 字节(某些例外情况需要更高的精度)。
🎒 示例
local new_rotator = Rotator(-90, 153, 24.5)
🛠 构造函数
Default Constructor
No description provided
local my_rotator = Rotator(pitch?, yaw?, roll?)
🧽 属性
| Type | Name | Description |
|---|---|---|
| number | Pitch | 绕右轴(绕 Y 轴)旋转,即抬头和低头(0=直视前方,正值为抬头,负值为低头) |
| number | Yaw | 绕上轴(绕 Z 轴)旋转,即绕圈转动,0=东,正值为北,负值为南。 |
| number | Roll | 绕前轴(绕 X 轴)旋转,即歪头,0=端正,正值为顺时针,负值为逆时针。 |
🦠 函数
信息
此结构支持 +、-、* 和 tostring 运算。
| Returns | Name | Description | |
|---|---|---|---|
| Vector | GetForwardVector | 在世界空间中,获取此组件的前向(X)单位方向向量。 | |
| Vector | GetRightVector | 在世界空间中,获取此组件的右向(Y)单位方向向量。 | |
| Vector | GetUpVector | 在世界空间中,获取此组件的上向(Z)单位方向向量。 | |
| Vector | RotateVector | 通过该旋转体旋转一个向量。 | |
Normalize | 就地归一化,移除所有绕圈圈数并计算出“最短路径”的旋转。 | ||
| Vector | UnrotateVector | 返回通过该旋转体的逆矩阵旋转后的向量。 | |
| Quat | Quaternion | 将旋转作为四元数获取。 | |
| Rotator | GetNormalized | 返回一个归一化后的新旋转体。 | |
| boolean | IsNearlyZero | 检查旋转体在指定的容差范围内是否接近于零 | |
| boolean | IsZero | 检查旋转体的所有组件是否严格为零 |
GetForwardVector
在世界空间中,获取此组件的前向(X)单位方向向量。
— Returns Vector (前向方向).
local ret = my_rotator:GetForwardVector()
GetRightVector
在世界空间中,获取此组件的右向(Y)单位方向向量。
— Returns Vector (右向方向).
local ret = my_rotator:GetRightVector()
GetUpVector
在世界空间中,获取此组件的上向(Z)单位方向向量。
— Returns Vector (上向方向).
local ret = my_rotator:GetUpVector()
RotateVector
通过该旋转体旋转一个向量。
— Returns Vector (旋转后的向量).
local ret = my_rotator:RotateVector(vector)
| Type | Parameter | Default | Description |
|---|---|---|---|
| Vector | vector | Required parameter | 要被该旋转体旋转的向量 |
Normalize
就地归一化,移除所有绕圈圈数并计算出“最短路径”的旋转。
my_rotator:Normalize()
UnrotateVector
返回通过该旋转体的逆矩阵旋转后的向量。
— Returns Vector (逆旋转后的向量).
local ret = my_rotator:UnrotateVector(vector)
| Type | Parameter | Default | Description |
|---|---|---|---|
| Vector | vector | Required parameter | 要被该旋转体逆矩阵旋转的向量 |
Quaternion
将旋转作为四元数获取。
— Returns Quat (作为四元数的旋转).
local ret = my_rotator:Quaternion()
GetNormalized
返回一个归一化后的新旋转体。
— Returns Rotator (归一化后的旋转体).
local ret = my_rotator:GetNormalized()
IsNearlyZero
检查旋转体在指定的容差范围内是否接近于零
— Returns boolean (旋转体是否接近于零).
local ret = my_rotator:IsNearlyZero(tolerance?)
| Type | Parameter | Default | Description |
|---|---|---|---|
| number | tolerance? | 0.000001 | 要检查的容差 |
IsZero
检查旋转体的所有组件是否严格为零
— Returns boolean (旋转体是否严格为零).
local ret = my_rotator:IsZero()
🗿 静态函数
Random
生成一个随机旋转,可选择是否包含随机横滚角
— Returns Rotator (随机旋转结果).
local ret = Rotator.Random(roll?, min?, max?)