Skip to content
Rotation

[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 VectorUsage: 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 VectorUsage: Forward vector
up VectorUsage: upward vector

new Rotation(rotation)

Copy rotation and return a new one.

Parameters

rotation RotationUsage: copy Rotation object

new Rotation(v)

Construct through quaternions

Parameters

v QuaternionUsage: Quaternion

new Rotation(x, y, z)

Construct through three components

Parameters

x numberUsage: rotated x-component range: unrestricted type: floating-point number
y numberUsage: rotated y-component range: unrestricted type: floating-point number
z numberUsage: 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

Static get zero(): Rotation

Get an empty rotation angle (0,0,0)

Returns

RotationRotation (0, 0, 0)

Methods

add

add(a): Rotation other

Current rotation amount plus one rotation amount

Parameters

a RotationUsage: Rotation amount a
b RotationUsage: Rotation amount b
outer? RotationUsage: The rotation amount of the received result, which is the sum of rotations. default: null

Returns

RotationThe result of addition

Parameters

a RotationUsage: Rotation amount

clone

clone(): Rotation other

Clone the current rotation amount

Returns

RotationReturn 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 RotationUsage: Rotation amount for comparison
epsilon? numberUsage: Error value
default: 1. e-7
range: It is recommended to pass in a value less than 1. Type: Floating point number

Returns

booleanComparison results

fromQuaternion

fromQuaternion(v): void other

The current rotation reads a quaternion

Parameters

v QuaternionQuaternion
outer? RotationUsage: Rotation object passed in default: null

Returns

RotationRotation

Parameters

v QuaternionUsage: Read quaternion data

fromString

fromString(str): void other

The current Rotation reads a string of data

Parameters

v stringUsage: string range: "0.00000, 0.00000, 0.00000"
outer? RotationUsage: Rotation object passed in default: null

Returns

RotationRotation

Parameters

str stringUsage: 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 VectorVector
outer? RotationUsage: Rotation object passed in default: null

Returns

RotationRotation

Parameters

v VectorUsage: Read vector data

getForce

getForce(outer?): Vector other

Obtain the direction vector after this rotation

Parameters

outer? VectorUsage: The vector to be written with data, the outer passed in cannot be null/undefined default: null

Returns

VectorDirection 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? RotationUsage: Rotation amount written to data default: null

Returns

RotationReverse 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 RotationUsage: Rotation amount a
b RotationUsage: Rotation amount b
outer? RotationUsage: Rotation variable for receiving results default: null

Returns

RotationThe result of multiplication

Parameters

v RotationUsage: Rotation amount

rotateVector

rotateVector(v): Vector other

Rotate a vector at the current angle

Parameters

v VectorUsage: rotated vector

Returns

VectorRotated vector

set

set(v): Rotation other

The current rotation amount is set to the new rotation amount

Parameters

v RotationUsage: Rotation amount

Returns

RotationRotation amount

set(x, y, z): Rotation other

Set each component for the current rotation amount

Parameters

x numberUsage: rotated x-component range: unrestricted type: floating-point number
y numberUsage: rotated y-component range: unrestricted type: floating-point number
z numberUsage: rotated z-component range: unrestricted type: floating-point number

Returns

RotationRotation amount

strictEquals

strictEquals(other): boolean other

Determine whether the current angle is equal to the specified vector.

Parameters

other RotationUsage: Rotation amount for comparison

Returns

booleanComparison results

subtract

subtract(a): Rotation other

Subtract one rotation from the current rotation amount

Parameters

a RotationUsage: Rotation amount a
b RotationUsage: Rotation amount b
outer? RotationUsage: Rotation variable for receiving results default: null

Returns

RotationThe result of subtraction

Parameters

a RotationUsage: Rotation amount

toQuaternion

toQuaternion(): Quaternion other

The current Rotation output is a quaternion

Returns

QuaternionOutput quaternion

toString

toString(): string other

The current rotation is output as a string

Returns

stringOutput 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 RotationUsage: Rotation amount a
b RotationUsage: Rotation amount b
outer? RotationUsage: The rotation amount of the received result, which is the sum of rotations. default: null

Returns

RotationThe result of addition

copy

Static copy(a, outer): Rotation other

Copy target Rotation

Parameters

a RotationUsage: target rotation
outer RotationUsage: Rotation of receiving results

Returns

RotationCopy 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 QuaternionQuaternion
outer? RotationUsage: Rotation object passed in default: null

Returns

RotationRotation

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 stringUsage: string range: "0.00000, 0.00000, 0.00000"
outer? RotationUsage: Rotation object passed in default: null

Returns

RotationRotation

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 VectorVector
outer? RotationUsage: Rotation object passed in default: null

Returns

RotationRotation

lerp

Static lerp(a, b, alpha): Rotation other

Interpolate two rotation quantities

Parameters

a RotationUsage: Rotation amount a
b RotationUsage: Rotation amount b
alpha numberUsage: Interpolation
range: [0,1] type: Floating point number

Returns

RotationRotation

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 RotationUsage: Rotation amount a
b RotationUsage: Rotation amount b
outer? RotationUsage: Rotation variable for receiving results default: null

Returns

RotationThe 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 RotationUsage: Rotation amount a
b RotationUsage: Rotation amount b
outer? RotationUsage: Rotation variable for receiving results default: null

Returns

RotationThe result of subtraction