operator / method

Quaternion operator /(
  1. Object other
)

Computes the division of this number and another one.

Implementation

Quaternion operator /(Object other) {
  if (other is Quaternion) {
    final f = 1 / norm();
    return Quaternion(
      (w * other.w + x * other.x + y * other.y + z * other.z) * f,
      (x * other.w - w * other.x - y * other.z + z * other.y) * f,
      (y * other.w - w * other.y - z * other.x + x * other.z) * f,
      (z * other.w - w * other.z - x * other.y + y * other.x) * f,
    );
  } else if (other is num) {
    return Quaternion(w / other, x / other, y / other, z / other);
  } else {
    throw ArgumentError.value(other, 'other', 'Invalid type');
  }
}