mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-12-06 08:42:32 -08:00
Add space translation helpers to Quaternion
This commit is contained in:
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
|
||||
|
||||
Reference in new issue
Block a user