Project 79: Magnitude and Direction of Vector

Intro Problem: Suppose you walked 5 km east and 3 km south of your house.  How far are you from your house?  What is the direction you are facing?  

Note: We know we must be facing southeast, but it should be closer to due east (0 or 360 degrees) than it is due south (270 degrees).

The vector in the graph above is <5, -3>.  The magnitude of the vector is the square root of 25 + 9 or about 5.83.  The direction of the vector is 329.04 degrees.  For this project, we will represent the direction of the vector in degrees (in the interval between 0 and 360).   The direction can be calculated using the inverse trig functions.  It is important that you know and understand the range for inverse trig functions.  For example, invsereTan of -3/5 yields -30.96 which is in the fourth quadrant (which is coterminal to the desired value of 329.04).  


Project 79: Variables 'x' and 'y' have been initialized.  The values for x and y represent the xy-components for the given vector.

x is 5 in the example above

y is -3 in the example above.

Task: Appropriately initialize values for 'magnitude' and 'direction'.  Remember, that 'direction' should be initialized as a value between 0 and 360.


Note: The following trig methods are available.

cosine(x) 

sine(x) 

tangent(x) 

cosineInverse(x)

sineInverse(x)

tangentInverse(x)

**If your code works for 5 test cases, you can enter your e-mail address

Universal Computational Math Methods:

pow(5,2) returns 25.0

abs(-3.0) returns 3

sqrt(49.0) returns 7.0