| 27 | } |
| 28 | |
| 29 | Vector3* TriVectorRotateQuaternion( |
| 30 | Vector3* out, |
| 31 | const Vector3* v, |
| 32 | const Quaternion* q ) |
| 33 | { |
| 34 | // q*v*qcomplement, where we treat v as a pure quaternion |
| 35 | |
| 36 | float ww = q->w * q->w; |
| 37 | float wx = q->w * q->x; |
| 38 | float wy = q->w * q->y; |
| 39 | float wz = q->w * q->z; |
| 40 | |
| 41 | float xx = q->x * q->x; |
| 42 | float xy = q->x * q->y; |
| 43 | float xz = q->x * q->z; |
| 44 | |
| 45 | float yy = q->y * q->y; |
| 46 | float yz = q->y * q->z; |
| 47 | |
| 48 | float zz = q->z * q->z; |
| 49 | |
| 50 | Vector3 temp; |
| 51 | temp.x = v->x * ( ww + xx - yy - zz ) + 2.0f * ( v->y * ( xy - wz ) + v->z * ( xz + wy ) ); |
| 52 | temp.y = v->y * ( ww - xx + yy - zz ) + 2.0f * ( v->x * ( xy + wz ) + v->z * ( yz - wx ) ); |
| 53 | temp.z = v->z * ( ww - xx - yy + zz ) + 2.0f * ( v->x * ( xz - wy ) + v->y * ( yz + wx ) ); |
| 54 | *out = temp; |
| 55 | return out; |
| 56 | } |
| 57 | |
| 58 | |
| 59 | // Projects a point onto a plane |
no outgoing calls
no test coverage detected