MCPcopy
hub / github.com/mrdoob/three.js / applyQuaternion

Method applyQuaternion

src/math/Vector3.js:471–490  ·  view source on GitHub ↗

* Applies the given Quaternion to this vector. * * @param {Quaternion} q - The Quaternion. * @return {Vector3} A reference to this vector.

( q )

Source from the content-addressed store, hash-verified

469 * @return {Vector3} A reference to this vector.
470 */
471 applyQuaternion( q ) {
472
473 // quaternion q is assumed to have unit length
474
475 const vx = this.x, vy = this.y, vz = this.z;
476 const qx = q.x, qy = q.y, qz = q.z, qw = q.w;
477
478 // t = 2 * cross( q.xyz, v );
479 const tx = 2 * ( qy * vz - qz * vy );
480 const ty = 2 * ( qz * vx - qx * vz );
481 const tz = 2 * ( qx * vy - qy * vx );
482
483 // v + q.w * t + cross( q.xyz, t );
484 this.x = vx + qw * tx + qy * tz - qz * ty;
485 this.y = vy + qw * ty + qz * tx - qx * tz;
486 this.z = vz + qw * tz + qx * ty - qy * tx;
487
488 return this;
489
490 }
491
492 /**
493 * Projects this vector from world space into the camera's normalized

Callers 15

constructorMethod · 0.95
applyEulerMethod · 0.95
applyAxisAngleMethod · 0.95
constructorMethod · 0.95
constructorMethod · 0.95
constructorMethod · 0.95
buildExtrusionNodeMethod · 0.95
Object3D.tests.jsFile · 0.45
Vector3.tests.jsFile · 0.45
Editor.jsFile · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected