跳至正文
版本:bleeding-edge 🩸

🧭 旋转体

旋转信息(俯仰角、偏航角、横滚角)的容器。所有旋转值均以度为单位存储。

👐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?)
TypeNameDefaultDescription
numberpitch0俯仰角
numberyawpitch偏航角
numberrollpitch横滚角

🧽 属性

TypeNameDescription
numberPitch绕右轴(绕 Y 轴)旋转,即抬头和低头(0=直视前方,正值为抬头,负值为低头)
numberYaw绕上轴(绕 Z 轴)旋转,即绕圈转动,0=东,正值为北,负值为南。
numberRoll绕前轴(绕 X 轴)旋转,即歪头,0=端正,正值为顺时针,负值为逆时针。

🦠 函数

信息

此结构支持 +-*tostring 运算。

ReturnsNameDescription
VectorGetForwardVector在世界空间中,获取此组件的前向(X)单位方向向量。
VectorGetRightVector在世界空间中,获取此组件的右向(Y)单位方向向量。
VectorGetUpVector在世界空间中,获取此组件的上向(Z)单位方向向量。
VectorRotateVector通过该旋转体旋转一个向量。
Normalize就地归一化,移除所有绕圈圈数并计算出“最短路径”的旋转。
VectorUnrotateVector返回通过该旋转体的逆矩阵旋转后的向量。
QuatQuaternion将旋转作为四元数获取。
RotatorGetNormalized返回一个归一化后的新旋转体。
booleanIsNearlyZero检查旋转体在指定的容差范围内是否接近于零
booleanIsZero检查旋转体的所有组件是否严格为零

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)
TypeParameterDefaultDescription
Vectorvector Required parameter 要被该旋转体旋转的向量

Normalize

就地归一化,移除所有绕圈圈数并计算出“最短路径”的旋转。

my_rotator:Normalize()

UnrotateVector

返回通过该旋转体的逆矩阵旋转后的向量。

— Returns Vector (逆旋转后的向量).

local ret = my_rotator:UnrotateVector(vector)
TypeParameterDefaultDescription
Vectorvector 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?)
TypeParameterDefaultDescription
numbertolerance?0.000001要检查的容差

IsZero

检查旋转体的所有组件是否严格为零

— Returns boolean (旋转体是否严格为零).

local ret = my_rotator:IsZero()

🗿 静态函数

ReturnsNameDescription
RotatorRandom生成一个随机旋转,可选择是否包含随机横滚角

Random

生成一个随机旋转,可选择是否包含随机横滚角

— Returns Rotator (随机旋转结果).

local ret = Rotator.Random(roll?, min?, max?)
TypeParameterDefaultDescription
booleanroll?false是否在旋转体中使用随机横滚角,否则横滚角使用 0
floatmin?-180最小值
floatmax?180最大值