log method

Quaternion log()

Computes the natural logarithm of this quaternion number.

Implementation

Quaternion log() {
  final vectorNorm = (x * x + y * y + z * z).sqrt();
  final scale = vectorNorm.atan2(w) / vectorNorm;
  return Quaternion(0.5 * norm().log(), x * scale, y * scale, z * scale);
}