multiplyQuaternions method

Quaternion multiplyQuaternions(
  1. Quaternion a,
  2. Quaternion b
)

Implementation

Quaternion multiplyQuaternions(Quaternion a, Quaternion b) {
  // from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm

  var qax = a._x, qay = a._y, qaz = a._z, qaw = a._w;
  var qbx = b._x, qby = b._y, qbz = b._z, qbw = b._w;

  _x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;
  _y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;
  _z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;
  _w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;

  onChangeCallback();

  return this;
}