MCPcopy Create free account
hub / github.com/carbonengine/trinity / TriVectorRotateQuaternion

Function TriVectorRotateQuaternion

trinity/TriMath.cpp:29–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27}
28
29Vector3* 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

Callers 15

TransformQuaternionMethod · 0.85
UpdateMethod · 0.85
UpdateMethod · 0.85
UpdateMethod · 0.85
SetupAudioMethod · 0.85
ResetMethod · 0.85
ProcessSpawnModifierMethod · 0.85
CalculateSplineDataMethod · 0.85
UpdateAgentsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected