4 ms·
Hi! Author here. I hand wrote this website and the source code of the examples mostly comes from my own debugging tools. That method in particular is just a ver
by noodlejs 1y ago
Hi! Author here. I hand wrote this website and the source code of the examples mostly comes from my own debugging tools. That method in particular is just a very minimal implementation of section 8.5.2 of this textbook (but I tried to make it friendly for the blog post).
https://gamemath.com/book/orient.html#quaternion_geometry https://gamemath.com/book/orient.html#quaternion_geometry
- polishdude20 1y agoSorry, but x,y and z are not even being used in that function...
- noodlejs 1y agoLOL ok yeah, that's a copy-paste issue. I'll fix it up here shortly.
- xeonmc 1y agoimo it's better to express the conversion relation as exp-log pairs: fn exp(q: Quat) -> Quat { let ijk = sqrt(q.i*q.i + q.j*q.j + q.k*q.k); Quat { i: exp(q.l) * sin(ijk) * q.i / ijk, j: exp(q.l) * sin(ijk) * q.j / ijk, k: exp(q.l) * sin(ijk) * q.k / ijk, l: exp(q.l) * cos(ijk), } } fn log(q: Quat) -> Quat { let ijk = sqrt(q.i*q.i + q.j*q.j + q.k*q.k); Quat { i: atan2(ijk, q.l) * q.i / ijk, j: atan2(ijk, q.l) * q.j / ijk, k: atan2(ijk, q.l) * q.k / ijk, l: 0.5 * log(q.i*q.i + q.j*q.j + q.k*q.k + q.l*q.l), } }