Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 = ,b= , then

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

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

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

More Books

Students also viewed these Databases questions

Question

Determine the amplitude and period of each function.

Answered: 1 week ago

Question

=+such as the dirigenti in Italy?

Answered: 1 week ago

Question

=+ Are there closed-shop requirements or practices?

Answered: 1 week ago