Add space translation helpers to Quaternion

This commit is contained in:
Butterscotch! committed 2026-10-28 18:51:30 -04:00
1 parent 6b159eb5a5
commit 44a34d6142
2 files changed
+30

No files matched your search

@@ -441,6 +441,20 @@ class Quaternion(val w: Float, val x: Float, val y: Float, val z: Float) {
w * w - x * x - y * y + z * z,
)
/**
* Aligns this global quaternion to be local within the [parent]'s space.
* @param parent The global quaternion to become relative to.
* @return This quaternion aligned to [parent]'s local space.
*/
fun localAbout(parent: Quaternion): Quaternion = parent.inv() * this
/**
* Aligns this local quaternion to be global from within the parent's space.
* @param parent The global quaternion which this quaternion is relative to.
* @return This quaternion aligned to a global space.
*/
fun globalAbout(parent: Quaternion): Quaternion = parent * this
/**
* computes this quaternion's unit length rotation axis
* @return rotation axis