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

Function stVec2Qt

src/Sato/stMath.cpp:248–267  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

246}
247
248bool stVec2Qt(Quaternion &q, const Vec &dir, const Vec &vec)
249{
250 Vec cross;
251 bool ret = false;
252 PSVECCrossProduct(&dir, &vec, &cross);
253 float dot = PSVECDotProduct(&dir, &vec);
254
255 float length = stspeedy_sqrtf(2.0f * (1.0f + dot));
256
257 if (length > 0.0f)
258 {
259 q.x = cross.x / length;
260 q.y = cross.y / length;
261 q.z = cross.z / length;
262 q.w = 0.5f * length;
263 ret = true;
264 }
265
266 return ret;
267}
268
269// TODO: match it in a way that makes sense
270// https://decomp.me/scratch/2u8r1

Callers

nothing calls this directly

Calls 3

PSVECCrossProductFunction · 0.85
PSVECDotProductFunction · 0.85
stspeedy_sqrtfFunction · 0.85

Tested by

no test coverage detected