Question
IN C++ Create a program using vectors in R3 (3D vectors) that will be used to calculate the volume of a parallelepiped. The volume of
IN C++
Create a program using vectors in R3 (3D vectors) that will be used to calculate the volume of a parallelepiped. The volume of a parallelepiped determined by the vectors a, b and c is the absolute value of the scalar triple product:
????=|?????(???? ????)|, where ???? ???? is the cross product of b and c, and a ? (???? ????) is the dot product of a and the cross product of b and c.
1. Create a void function named input that will receive a vector and load the integer coordinates of a 3D vector. Use this function to load the three vectors va, vb, vc.
2. Create a function named dotproduct that will receive two 3 dimensional vectors and return their dot product. (This function returns an integer)
3. Create a function named crossproduct that will receive two 3 dimensional vectors and return their cross product. (This function returns a vector)
4. Using parts 2 and 3 and the formula above calculate the volume of the parallelepiped and output the appropriate message:
The volume of object is: #
5. Create an outer loop to let the user continue calculating the volume of new vectors.
Would you like to continue? Y, N
Formulas for dot and cross products
If a and b are vectors a =
Dot product: ?????????= ????1????1+ ????2????2+ ????3????3,
Cross product: ???? ????= < ????2????3?????3????2,????3????1?????1????3, ????1????2?????2????1>
Note: Dot product returns an integer and the cross product returns an integer vector.
6. Test your program with the values below:
Expected output for each of the values required:
Vectors: va = <1,-2,3> vb = <4,3,0> vc = <9,2,-3> Volume: 90
Vectors: va = <4,0,-1> vb = <2,2,7> vc = <0,1,6> Volume: 18
Vectors: va = <5,5,-3> vb = <-2,1,1> vc = <7,0,0> Volume: 56
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started