MCPcopy Create free account
hub / github.com/cocos/cocos-engine / transformQuat

Method transformQuat

native/cocos/math/Vec3.cpp:308–324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

306}
307
308void Vec3::transformQuat(const Quaternion &q) {
309 const float qx = q.x;
310 const float qy = q.y;
311 const float qz = q.z;
312 const float qw = q.w;
313
314 // calculate quat * vec
315 const float ix = qw * x + qy * z - qz * y;
316 const float iy = qw * y + qz * x - qx * z;
317 const float iz = qw * z + qx * y - qy * x;
318 const float iw = -qx * x - qy * y - qz * z;
319
320 // calculate result * inverse quat
321 x = ix * qw + iw * -qx + iy * -qz - iz * -qy;
322 y = iy * qw + iw * -qy + iz * -qx - ix * -qz;
323 z = iz * qw + iw * -qz + ix * -qy - iy * -qx;
324}
325
326float Vec3::distance(const Vec3 &v) const {
327 const float dx = v.x - x;

Callers 15

vec4.test.tsFile · 0.45
vec3.test.tsFile · 0.45
updateMethod · 0.45
updateMethod · 0.45
screenPointToRayMethod · 0.45
updateMethod · 0.45
setPlaneFromNodeMethod · 0.45
mergeMethod · 0.45
updateCacheMethod · 0.45
getForwardMethod · 0.45
getUpMethod · 0.45

Calls

no outgoing calls

Tested by 1

TESTFunction · 0.36