Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

image text in transcribed

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. Please give me C++ code!!!
Details . Define a class Quaternion that will store 4 coefficients of quaternion o The default constructor must accept four double-typed parameters. Overload an equality operation for your class to compare two quaternion objects. o 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. o 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 numbe o 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 main.cpp E 1 2 I DO NOT MODIFY NEXT LINE 3 #include "catch.hpp" // Put the assignment code here 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 // DO NOT MODIFY TEST CASES 11- TEST_CASE "Assignment" ) { SECTION "71" ) { Quaternion 9{1.8, 2.0, 3.0, 4.0}; Quaternion P{1.0, 2.0, 3.0, 4.0); REQUIRE( q == p ); } SECTION "42") { 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 "93" ) { Quaternion q{1.8, 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 (9 - p) == r ); 3 SECTION "93" ) { Quaternion 9{1.0, 2.0, 3.0, 4.0}; Quaternion r{2.0, 4.0, 6.0, 8.0}; REQUIRE (9 * 2.0) == r ); } } 11 25 26 27 28 29 30 31 32 33 34 35 36 37 38

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning VB 2008 Databases

Authors: Vidya Vrat Agarwal, James Huddleston

1st Edition

1590599470, 978-1590599471

More Books

Students also viewed these Databases questions

Question

What are the Five Phases of SDLC? Explain each briefly.

Answered: 1 week ago

Question

How can Change Control Procedures manage Project Creep?

Answered: 1 week ago