[Basic Type](../groups/Basic Type.Basic Type.md) / Rotation
Rotation Class
Euler angle
The rotation amount in three-dimensional space composed of components (x, y, z).
Rotation The three Euler angles Pitch, Yaw, and Roll encapsulate the rotation values around three axes: Pitch, Yaw, and Roll are translated as pitch angle, yaw angle, and roll angle. Representing the rotation values around the X, Y, and Z axes respectively.
Precautions
All rotation values are stored in degrees
Table of contents
Properties
x: number |
---|
Rotating x-component |
y: number |
The y-component of rotation |
z: number |
Rotating z-component |
Accessors
zero(): Rotation |
---|
Get an empty rotation angle (0,0,0) |
Methods
add(a : Rotation , b : Rotation , outer? : Rotation ): Rotation other |
---|
Rotation amount a plus rotation amount b |
clone(): Rotation other |
Clone the current rotation amount |
equals(other : Rotation , epsilon? : number ): boolean other |
Determine whether the current angle is equal to the specified vector within the error range. |
fromQuaternion(v : Quaternion , outer? : Rotation ): Rotation other |
Convert Quaternion to Rotation |
fromString(v : string , outer? : Rotation ): Rotation other |
Convert string data to Rotation |
fromVector(v : Vector , outer? : Rotation ): Rotation other |
Convert Vector to Rotation |
getForce(outer? ): Vector other |
Obtain the direction vector after this rotation |
getInverse(outer? : Rotation ): Rotation other |
Return a new reverse rotation. |
multiply(a : Rotation , b : Rotation , outer? : Rotation ): Rotation other |
Multiply the current rotation amount by a rotation amount |
rotateVector(v ): Vector other |
Rotate a vector at the current angle |
set(v : Rotation ): Rotation other |
The current rotation amount is set to the new rotation amount |
strictEquals(other : Rotation ): boolean other |
Determine whether the current angle is equal to the specified vector. |
subtract(a : Rotation , b : Rotation , outer? : Rotation ): Rotation other |
Subtract one rotation from the current rotation amount |
toQuaternion(): Quaternion other |
The current Rotation output is a quaternion |
toString(): string other |
The current rotation is output as a string |
add(a : Rotation , b : Rotation , outer? : Rotation ): Rotation other |
Rotation amount a plus rotation amount b |
copy(a : Rotation , outer : Rotation ): Rotation other |
Copy target Rotation |
fromQuaternion(v : Quaternion , outer? : Rotation ): Rotation other |
Convert Quaternion to Rotation |
fromString(v : string , outer? : Rotation ): Rotation other |
Convert string data to Rotation |
fromVector(v : Vector , outer? : Rotation ): Rotation other |
Convert Vector to Rotation |
lerp(a : Rotation , b : Rotation , alpha : number ): Rotation other |
Interpolate two rotation quantities |
multiply(a : Rotation , b : Rotation , outer? : Rotation ): Rotation other |
Multiply the current rotation amount by a rotation amount |
subtract(a : Rotation , b : Rotation , outer? : Rotation ): Rotation other |
Subtract one rotation from the current rotation amount |
Build a new rotation. The value is (0, 0, 0)
• new Rotation(vector
)
Set the values of x, y, and z in the given vector for x, y, and z.
Parameters
vector Vector | Usage: Given vector |
---|
• new Rotation(forward
, up
)
Construct a rotation to rotate the Vector FORWARD points in the direction of the given forward vector, with the upward vector as a reference.
Precautions
If the forward and upward directions point in exactly the same (or opposite) direction, or if one of their lengths is 0, then return (0,0,0).
Parameters
forward Vector | Usage: Forward vector |
---|---|
up Vector | Usage: upward vector |
• new Rotation(rotation
)
Copy rotation and return a new one.
Parameters
rotation Rotation | Usage: copy Rotation object |
---|
• new Rotation(v
)
Construct through quaternions
Parameters
v Quaternion | Usage: Quaternion |
---|
• new Rotation(x
, y
, z
)
Construct through three components
Parameters
x number | Usage: rotated x-component range: unrestricted type: floating-point number |
---|---|
y number | Usage: rotated y-component range: unrestricted type: floating-point number |
z number | Usage: rotated z-component range: unrestricted type: floating-point number |
Properties
x
• x: number
Rotating x-component
y
• y: number
The y-component of rotation
z
• z: number
Rotating z-component
Accessors
zero
• |
---|
Get an empty rotation angle (0,0,0) Returns |
Rotation | Rotation (0, 0, 0) |
---|
Methods
add
• add(a
): Rotation
other
Current rotation amount plus one rotation amount
Parameters
a Rotation | Usage: Rotation amount a |
---|---|
b Rotation | Usage: Rotation amount b |
outer? Rotation | Usage: The rotation amount of the received result, which is the sum of rotations. default: null |
Returns
Rotation | The result of addition |
---|
Parameters
a Rotation | Usage: Rotation amount |
---|
clone
• clone(): Rotation
other
Clone the current rotation amount
Returns
Rotation | Return a new rotation amount |
---|
equals
• equals(other
, epsilon?
): boolean
other
Determine whether the current angle is equal to the specified vector within the error range.
Parameters
other Rotation | Usage: Rotation amount for comparison |
---|---|
epsilon? number | Usage: Error value default: 1. e-7 range: It is recommended to pass in a value less than 1. Type: Floating point number |
Returns
boolean | Comparison results |
---|
fromQuaternion
• fromQuaternion(v
): void
other
The current rotation reads a quaternion
Parameters
v Quaternion | Quaternion |
---|---|
outer? Rotation | Usage: Rotation object passed in default: null |
Returns
Rotation | Rotation |
---|
Parameters
v Quaternion | Usage: Read quaternion data |
---|
fromString
• fromString(str
): void
other
The current Rotation reads a string of data
Parameters
v string | Usage: string range: "0.00000, 0.00000, 0.00000" |
---|---|
outer? Rotation | Usage: Rotation object passed in default: null |
Returns
Rotation | Rotation |
---|
Parameters
str string | Usage: string data range: "P=-431602080.000000 Y=-431602080.000000 R=-431602080.000000" |
---|
fromVector
• fromVector(v
): void
other
Read a Vector from the current Rotation
Parameters
v Vector | Vector |
---|---|
outer? Rotation | Usage: Rotation object passed in default: null |
Returns
Rotation | Rotation |
---|
Parameters
v Vector | Usage: Read vector data |
---|
getForce
• getForce(outer?
): Vector
other
Obtain the direction vector after this rotation
Parameters
outer? Vector | Usage: The vector to be written with data, the outer passed in cannot be null/undefined default: null |
---|
Returns
Vector | Direction vector of rotation |
---|
Precautions
If the outer is not empty, return the outer, otherwise return a new Rotation object. It is recommended to pass in the outer to reduce the new object and the outer cannot be null/undefined
getInverse
• getInverse(outer?
): Rotation
other
Return a new reverse rotation.
Parameters
outer? Rotation | Usage: Rotation amount written to data default: null |
---|
Returns
Rotation | Reverse rotation |
---|
Precautions
If the outer is not empty, return the outer, otherwise return a new Rotation object. It is recommended to pass in the outer to reduce the new object and the outer cannot be null/undefined
multiply
• multiply(v
): Rotation
other
Multiply the current rotation by a rotation (equivalent to quaternion cross product)
Parameters
a Rotation | Usage: Rotation amount a |
---|---|
b Rotation | Usage: Rotation amount b |
outer? Rotation | Usage: Rotation variable for receiving results default: null |
Returns
Rotation | The result of multiplication |
---|
Parameters
v Rotation | Usage: Rotation amount |
---|
rotateVector
• rotateVector(v
): Vector
other
Rotate a vector at the current angle
Parameters
v Vector | Usage: rotated vector |
---|
Returns
Vector | Rotated vector |
---|
set
• set(v
): Rotation
other
The current rotation amount is set to the new rotation amount
Parameters
v Rotation | Usage: Rotation amount |
---|
Returns
Rotation | Rotation amount |
---|
• set(x
, y
, z
): Rotation
other
Set each component for the current rotation amount
Parameters
x number | Usage: rotated x-component range: unrestricted type: floating-point number |
---|---|
y number | Usage: rotated y-component range: unrestricted type: floating-point number |
z number | Usage: rotated z-component range: unrestricted type: floating-point number |
Returns
Rotation | Rotation amount |
---|
strictEquals
• strictEquals(other
): boolean
other
Determine whether the current angle is equal to the specified vector.
Parameters
other Rotation | Usage: Rotation amount for comparison |
---|
Returns
boolean | Comparison results |
---|
subtract
• subtract(a
): Rotation
other
Subtract one rotation from the current rotation amount
Parameters
a Rotation | Usage: Rotation amount a |
---|---|
b Rotation | Usage: Rotation amount b |
outer? Rotation | Usage: Rotation variable for receiving results default: null |
Returns
Rotation | The result of subtraction |
---|
Parameters
a Rotation | Usage: Rotation amount |
---|
toQuaternion
• toQuaternion(): Quaternion
other
The current Rotation output is a quaternion
Returns
Quaternion | Output quaternion |
---|
toString
• toString(): string
other
The current rotation is output as a string
Returns
string | Output string data |
---|
add
• Static
add(a
, b
, outer?
): Rotation
other
Rotation amount a plus rotation amount b
Precautions
outer Cannot be null/undefined
Parameters
a Rotation | Usage: Rotation amount a |
---|---|
b Rotation | Usage: Rotation amount b |
outer? Rotation | Usage: The rotation amount of the received result, which is the sum of rotations. default: null |
Returns
Rotation | The result of addition |
---|
copy
• Static
copy(a
, outer
): Rotation
other
Copy target Rotation
Parameters
a Rotation | Usage: target rotation |
---|---|
outer Rotation | Usage: Rotation of receiving results |
Returns
Rotation | Copy the newly rotated object |
---|
Precautions
outer Cannot be null/undefined
fromQuaternion
• Static
fromQuaternion(v
, outer?
): Rotation
other
Convert Quaternion to Rotation
Precautions
If the outer is not empty, return the outer, otherwise return a new Rotation object. It is recommended to pass in the outer to reduce the new object and the outer cannot be null/undefined
Parameters
v Quaternion | Quaternion |
---|---|
outer? Rotation | Usage: Rotation object passed in default: null |
Returns
Rotation | Rotation |
---|
fromString
• Static
fromString(v
, outer?
): Rotation
other
Convert string data to Rotation
Precautions
If the outer is not empty, return the outer, otherwise return a new Rotation object. It is recommended to pass in the outer to reduce the new object and the outer cannot be null/undefined
Parameters
v string | Usage: string range: "0.00000, 0.00000, 0.00000" |
---|---|
outer? Rotation | Usage: Rotation object passed in default: null |
Returns
Rotation | Rotation |
---|
fromVector
• Static
fromVector(v
, outer?
): Rotation
other
Convert Vector to Rotation
Precautions
If the outer is not empty, return the outer, otherwise return a new Rotation object. It is recommended to pass in the outer to reduce the new object and the outer cannot be null/undefined
Parameters
v Vector | Vector |
---|---|
outer? Rotation | Usage: Rotation object passed in default: null |
Returns
Rotation | Rotation |
---|
lerp
• Static
lerp(a
, b
, alpha
): Rotation
other
Interpolate two rotation quantities
Parameters
a Rotation | Usage: Rotation amount a |
---|---|
b Rotation | Usage: Rotation amount b |
alpha number | Usage: Interpolation range: [0,1] type: Floating point number |
Returns
Rotation | Rotation |
---|
multiply
• Static
multiply(a
, b
, outer?
): Rotation
other
Multiply the current rotation amount by a rotation amount
Precautions
outer Cannot be null/undefined
Parameters
a Rotation | Usage: Rotation amount a |
---|---|
b Rotation | Usage: Rotation amount b |
outer? Rotation | Usage: Rotation variable for receiving results default: null |
Returns
Rotation | The result of multiplication |
---|
subtract
• Static
subtract(a
, b
, outer?
): Rotation
other
Subtract one rotation from the current rotation amount
Precautions
outer Cannot be null/undefined
Parameters
a Rotation | Usage: Rotation amount a |
---|---|
b Rotation | Usage: Rotation amount b |
outer? Rotation | Usage: Rotation variable for receiving results default: null |
Returns
Rotation | The result of subtraction |
---|