Skip to content

format

typescript
Quaternion.RotateTowards(from, to, max_delta_degrees)

class: Quaternion

description

Rotates a quaternion from the current direction to the target direction.

parameter

param_nametypedescription
fromQuaternionThe starting direction.
toQuaternionThe target direction.
max_delta_degreesnumberThe maximum rotation angle.

return

typedescription
QuaternionThe rotated quaternion.

code example

typescript
function QuaternionTest (){
    // Starting quaternion direction
    let a = new Quaternion(1,1,1,1);    
    // Target quaternion direction
    let b = new Quaternion(2,1,2,1);
    // Maximum rotation angle
    let maxDeltaDegrees = 30;
    // Create a quaternion that rotates from the starting direction to the target direction
    let quaternion = Quaternion.RotateTowards(a, b, maxDeltaDegrees);
}