MCPcopy Create free account
hub / github.com/doldecomp/mkdd / transform

Method transform

include/JSystem/JGeometry/Quat.h:188–206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

186 }
187
188 void transform(const JGeometry::TVec3f& v, JGeometry::TVec3f& rDest) const {
189 // transformation via hamiltonian multiplication of a unit quaternion
190 // q*v*q`
191 // where v is the input vector converted into a quaternion with w=0
192 // and q` is the multiplicative inverse of q
193 // (eg: q = w + xi + yj + zk, q` = w - xi - yj - zk)
194
195 TQuat4 r;
196 r.x = ( this->y * v.z) - (this->z * v.y) + (this->w * v.x);
197 r.y = (-this->x * v.z) + (this->z * v.x) + (this->w * v.y);
198 r.z = ( this->x * v.y) - (this->y * v.x) + (this->w * v.z);
199 r.w = (-this->x * v.x) - (this->y * v.y) - (this->z * v.z);
200
201 rDest.template set<T>(
202 r.x * this->w + r.y * -this->z - r.z * -this->y + r.w * -this->x,
203 -r.x * -this->z + r.y * this->w + r.z * -this->x + r.w * -this->y,
204 r.x * -this->y - r.y * -this->x + r.z * this->w + r.w * -this->z
205 );
206 }
207
208 void transform(JGeometry::TVec3f& v) const {
209 transform(v, v);

Callers 1

localMoveMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected