Skip to content

Rotation Utilities

Swifter edited this page Oct 19, 2024 · 10 revisions

Utilities

"Rotations" in ReMapper use an rm.Vec3 to represent an Euler rotation (in degrees).

[number, number, number]


  • rm.rotatePoint takes in a point and a rotation. The result of rotating the point around (0,0,0) is returned.
rm.rotatePoint([0, 0, 1], [0, 90, 0]) // ~ [1, 0, 0]

Optionally, you can also provide a third anchor argument to rotate around instead.

rm.rotatePoint([0, 0, 1], [0, 90, 0], [0, 0, 0.5]) // ~ [0.5, 0, 0.5]
  • rm.lookAt takes in an eye position and a target position. The rotation to look towards the target from the eye is returned.
rm.lookAt([0, 0, 1], [1, 0, 1]) // ~ [0, 90, 0]
  • rm.combineRotations takes in two rotations and returns a new rotation, which is the result of performing both of them.
rm.combineRotations([90, 0, 0], [180, 90, 0]) // ~ [-90, 90, 0]
  • rm.toRadians and rm.toDegrees take in rotations that are either in radians or degrees, and converts them respectively.
rm.toRadians([0, -180, 180]) // ~ [0, -3.14, 3.14]
rm.toDegrees([0, -3.14, 3.14]) // ~ [0, -180, 180]

You can also provide a single number to convert.

rm.toRadians(180) // ~ 3.14
rm.toDegrees(3.14) // ~ 180
  • rm.lerpRotation takes two rotations and blends between them based on a fraction value. (see Lerp)
rm.lerpRotation([0, 0, 0], [0, 0, 180], 0.5) // ~ [0, 0, 90]

Clone this wiki locally