Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that reads in a pair of 2D vectors and outputs the angle between

ID: 3655564 • Letter: W

Question

Write a program that reads in a pair of 2D vectors and outputs the angle between the vec- tors in degrees. The main routine of the program is already provided in vector2D_angle_template.cpp (which you copied into vector2D_angle.cpp). DO NOT MODIFY ANY OF THE CODE in procedure main. Your task is to add five functions normalize(), dot_product(), radians2degrees(), compute_vector_angle(), and output_angle() so that the program produces the desired results. 1. DO NOT MODIFY ANY OF THE CODE in procedure main. 2. All functions should be written AFTER the main procedure. 3. A function prototype should be written for each function and placed BEFORE the main procedure. 4. Each function should have a comment explaining what it does. 5. Each function parameter should have a comment explaining the parameter. 6. Write a function normalize() which normalizes vector(x, y) by dividing by its length. The length of vector (x, y) is ??x2 + y2. Input to the function are the coordinates x and y. The function does not return any value. The function has two parameters:

Explanation / Answer

double calcAngle(double fromX, double fromY, double fromAngle, double toX, double toY) { double d = 0.0; double Ux = 0.0, Uy = 0.0, Vx = 0.0, Vy = 0.0; d = sqrt( calcDistanceSquared(fromX, fromY, toX, toY) ); Ux = (toX - fromX) / d; Uy = (toY - fromY) / d; Vx = cos(fromAngle * (cPI / 180.0)); Vy = sin(fromAngle * (cPI / 180.0)); return atan2(((Ux * Vy) - (Uy * Vx)), ((Ux * Vx) + (Uy * Vy))) * 180.0 / cPI; }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote