operator * method

Quaternion operator *(
  1. Object other
)

Returns the product of this number and another one.

Implementation

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