inverse method

Quaternion inverse([
  1. Quaternion? target
])

Get the inverse quaternion rotation.

Implementation

Quaternion inverse([Quaternion? target]){
  target ??= Quaternion();
  conjugate(target);
  final inorm2 = 1 / (x * x + y * y + z * z + w * w);
  target.x *= inorm2;
  target.y *= inorm2;
  target.z *= inorm2;
  target.w *= inorm2;

  return target;
}