applyRotation method
Multiplies the given quaternion with this 3D vector.
Implementation
Vector3 applyRotation(Quaternion q ) {
final x = this.x, y = this.y, z = this.z;
final qx = q.x, qy = q.y, qz = q.z, qw = q.w;
// calculate quat * vector
final ix = qw * x + qy * z - qz * y;
final iy = qw * y + qz * x - qx * z;
final iz = qw * z + qx * y - qy * x;
final iw = - qx * x - qy * y - qz * z;
// calculate result * inverse quat
this.x = ix * qw + iw * - qx + iy * - qz - iz * - qy;
this.y = iy * qw + iw * - qy + iz * - qx - ix * - qz;
this.z = iz * qw + iw * - qz + ix * - qy - iy * - qx;
return this;
}