mult method

Quat mult(
  1. Quat quat, [
  2. Quat? target
])

Multiply the quaternion with an other quaternion.

Implementation

Quat mult(Quat quat, [Quat? target]){
  target ??= Quat();
  final ax = x;
  final ay = y;
  final az = z;
  final aw = w;
  final bx = quat.x;
  final by = quat.y;
  final bz = quat.z;
  final bw = quat.w;

  target.x = ax * bw + aw * bx + ay * bz - az * by;
  target.y = ay * bw + aw * by + az * bx - ax * bz;
  target.z = az * bw + aw * bz + ax * by - ay * bx;
  target.w = aw * bw - ax * bx - ay * by - az * bz;

  return target;
}