| 246 | } |
| 247 | |
| 248 | bool 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 |
nothing calls this directly
no test coverage detected