Question: lab / C++ (complete the main.cpp) main.cpp //------------------------------ // DO NOT MODIFY NEXT LINE //------------------------------ #include catch.hpp //------------------------------ // Put the assignment code here class

lab / C++ (complete the main.cpp)
main.cpp
//------------------------------
// DO NOT MODIFY NEXT LINE
//------------------------------
#include "catch.hpp"
//------------------------------
// Put the assignment code here
class Quaternion {
};
//------------------------------
// DO NOT MODIFY TEST CASES
//------------------------------
TEST_CASE( "Assignment" ) {
SECTION( "q1" ) {
Quaternion q{1.0, 2.0, 3.0, 4.0};
Quaternion p{1.0, 2.0, 3.0, 4.0};
REQUIRE( q == p );
}
SECTION( "q2" ) {
Quaternion q{1.0, 2.0, 3.0, 4.0};
Quaternion p{1.0, 2.0, 3.0, 4.0};
Quaternion r{2.0, 4.0, 6.0, 8.0};
REQUIRE( (q + p) == r );
}
SECTION( "q3" ) {
Quaternion q{1.0, 2.0, 3.0, 4.0};
Quaternion p{1.0, 2.0, 3.0, 4.0};
Quaternion r{0.0, 0.0, 0.0, 0.0};
REQUIRE( (q - p) == r );
}
SECTION( "q3" ) {
Quaternion q{1.0, 2.0, 3.0, 4.0};
Quaternion r{2.0, 4.0, 6.0, 8.0};
REQUIRE( (q * 2.0) == r );
}
}
//------------------------------
lab / C++ (complete the main.cpp) main.cpp //------------------------------ // DO NOT MODIFY

Lab 3 Task: Quaternion 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+g+dk 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. o 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 Quaternton 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

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!