Question: The quaternion number system extends the complex numbers. It's the quotient of two directed lines in a three-dimensional space, or, equivalently, as the quotient of

The quaternion number system extends the complex numbers. It's the quotient of two directed lines in a three-dimensional space, or, equivalently, as the quotient of two vectors. Quaternions are generally represented in the form

a + bi + cj + d k

where a, b, c, and d are real numbers; and i, j, and k are the basic quaternions.

  • Write a class that defines a quaternion and operations with it.

Details

  • Define a class Quaternion that will store 4 coefficients of quaternion
    • The default constructor must accept four double-typed parameters.
  • Overload an equality operation for your class to compare two quaternion objects.
    • Compare corresponding coefficients of the quaternion objects, and return true if they are equal; otherwise return false.
    • The operator must accept constant reference to the Quaternion object.
  • Overload an addition operation for your class to add two quaternion objects.
    • The operator must accept constant reference to the Quaternion object.
    • Add corresponding coefficients of the quaternion objects and return result.
      • The operator must return the Quaternion object. Do not modify current object.
  • Overload a subtraction operation for your class to subtract two quaternion objects.
    • The operator must accept constant reference to the Quaternion object.
    • Subtract corresponding coefficients of the quaternion objects.
      • The operator must return the Quaternion object. Do not modify current object.
  • Overload a multiplication operation for your class to multiply the quaternion object by a scalar number.
    • Multiply all coefficients of the quaternion object by the double-typed value
      • The operator must return the Quaternion object. Do not modify current object.
  • All operators must be const members
  • Make sure that your program compiles without errors

please write in C++ for my OOP class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!