Name: Anonymous 2007-10-16 13:44
Anyone feel like doing some C++ programs for me???
Itll be fun!
And you will be loved forever!
Consider two vectors A and B specified in rectangular coordinates that have their tails fixed at the origin (x, y, z) = (0, 0, 0). The cosine of the included angle between the vectors is given by
cos y = (A B) / (|A| |B| )
where the “dot product” is defined as
A . B = xA xB + yA yB + zA zB
and the magnitudes of the vectors are defined as
|A| = sqrt (xA2 + yA2 + zA2)
|B| = sqrt (xB2 + yB2 + zB2)
Knowing the rectangular components of the vectors, we can use the above formulas to compute cos y and from it the included angle y.
For this project, write a C program that prompts the user for the two vectors and calculates the angle between them. This program should employ user-defined functions to improve its structure and readability. Specifically, the program should do the following:
1. Prompt the user for the coordinates of the first vector one at a time.
2. Prompt the user for the coordinates of the second vector one at a time.
3. Calculate the angle y in degrees; define and use a function gamma for this purpose. Gamma in turn should call a function dot_prod that calculates the dot product of two vectors and a function vector_mag that calculates the magnitude of a vector.
4. Print the value of y to the screen.
5. Prompt the user to enter ‘c’ to continue with another pair of vectors or ‘q’ to quit.
Itll be fun!
And you will be loved forever!
Consider two vectors A and B specified in rectangular coordinates that have their tails fixed at the origin (x, y, z) = (0, 0, 0). The cosine of the included angle between the vectors is given by
cos y = (A B) / (|A| |B| )
where the “dot product” is defined as
A . B = xA xB + yA yB + zA zB
and the magnitudes of the vectors are defined as
|A| = sqrt (xA2 + yA2 + zA2)
|B| = sqrt (xB2 + yB2 + zB2)
Knowing the rectangular components of the vectors, we can use the above formulas to compute cos y and from it the included angle y.
For this project, write a C program that prompts the user for the two vectors and calculates the angle between them. This program should employ user-defined functions to improve its structure and readability. Specifically, the program should do the following:
1. Prompt the user for the coordinates of the first vector one at a time.
2. Prompt the user for the coordinates of the second vector one at a time.
3. Calculate the angle y in degrees; define and use a function gamma for this purpose. Gamma in turn should call a function dot_prod that calculates the dot product of two vectors and a function vector_mag that calculates the magnitude of a vector.
4. Print the value of y to the screen.
5. Prompt the user to enter ‘c’ to continue with another pair of vectors or ‘q’ to quit.