Skip to content

Commit

Permalink
Add quaternion method to extract rotation axis and angle
Browse files Browse the repository at this point in the history
  • Loading branch information
yzrmn committed Nov 14, 2024
1 parent f43edf6 commit 9c117b8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/redgeometry/src/primitives/quaternion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,14 @@ export class Quaternion implements QuaternionLike {
this.d = qd * cos + qa * sin;
}

public rotationAngle(): number {
return 2 * Math.acos(this.a);
}

public rotationAxis(): Vector3 {
return new Vector3(this.b, this.c, this.d);
}

/**
* Returns the spherical linear interpolation of the current quaternion and `q`.
*/
Expand Down

0 comments on commit 9c117b8

Please sign in to comment.