CSCI 200 - Fall 2023
Foundational Programming Concepts & Design

A2 - Complex Vector Math!

→This assignment is due by Tuesday, September 26, 2023, 11:59 PM.←
→ As with all assignments, this must be an individual effort and cannot be pair programmed. Any debugging assistance must follow the course collaboration policy and be cited in the comment header block for the assignment.←
→ Do not forget to complete the following labs with this set: L2A, L2B, L2C
→ Do not forget to complete zyBooks Assignment 2 for this set.←

Jump To: Rubric Submission


Concepts


When considering points in space, we can use negative numbers to correspond moving backwards along a heading. We can also use imaginary numbers to correspond to a rotation around the origin. The following article gives an excellent explanation and visualization of this process: Better Explained: A Visual, Intuitive Guide to Imaginary Numbers. The section A Real Example: Rotations explains the math of multiplying complex numbers to perform rotations.

We will use complex numbers to correspond to a point in space and a rotation to apply. Our program will then multiply these values together to determine the resultant point after rotation. Our rotation calculator can then continually spin a point around the origin


main() Pseudocode


Your program will prompt the user with a menu of choices. They will continue to enter choices until they opt to quit. Below are the menu options and what happens for each choice:

Be sure to handle the scenario if the user enters a selection that doesn't align to one of the above choices.


The Functions


We will use functions to implement each step of the above pseudocode. The specifications and descriptions for each function are given below. Your task is to create the appropriate functions and call them in the correct order to implement the expected pseudocode.


Public Tests


Below is a sample interaction that demonstrates the correct calculations and program flow.

Menu:
        1) Enter point (x, y) coordinate
        2) Rotate point by angle
        3) Rotate point by vector
        0) Quit
Choice: 1
Enter point x coordinate: 1
Enter point y coordinate: 2
Menu:
        1) Enter point (x, y) coordinate
        2) Rotate point by angle
        3) Rotate point by vector
        0) Quit
Choice: 2
Enter angle in degrees: 45
The point (1, 2) rotated by 45 degrees is now at (-0.707107, 2.12132)
Menu:
        1) Enter point (x, y) coordinate
        2) Rotate point by angle
        3) Rotate point by vector
        0) Quit
Choice: 3
Enter vector x coordinate: 1
Enter vector y coordinate: 1
The point (-0.707107, 2.12132) rotated by the vector <1, 1> (45 degrees) is now at (-2, 1)
Menu:
        1) Enter point (x, y) coordinate
        2) Rotate point by angle
        3) Rotate point by vector
        0) Quit
Choice: 2
Enter angle in degrees: -90
The point (-2, 1) rotated by -90 degrees is now at (1, 2)
Menu:
        1) Enter point (x, y) coordinate
        2) Rotate point by angle
        3) Rotate point by vector
        0) Quit
Choice: 3
Enter vector x coordinate: -1
Enter vector y coordinate: 0
The point (1, 2) rotated by the vector <-1, 0> (180 degrees) is now at (-1, -2)
Menu:
        1) Enter point (x, y) coordinate
        2) Rotate point by angle
        3) Rotate point by vector
        0) Quit
Choice: 5
Invalid selection, enter a valid option
Menu:
        1) Enter point (x, y) coordinate
        2) Rotate point by angle
        3) Rotate point by vector
        0) Quit
Choice: 0
Goodbye!

Be sure to test additional values to ensure the program is correct!


Specification Requirements


Your code and program must meet the following specifications:


Extra Credit


The prior calculations always perform a rotation centered around the origin. Add another menu option that allows the user to rotate around an arbitrary point. An example is shown below.

Menu:
        1) Enter point (x, y) coordinate
        2) Rotate point by angle
        3) Rotate point by vector
        4) Rotate point by vector around point
        0) Quit
Choice: 1
Enter point x coordinate: -1
Enter point y coordinate: -1
Menu:
        1) Enter point (x, y) coordinate
        2) Rotate point by angle
        3) Rotate point by vector
        4) Rotate point by vector around point
        0) Quit
Choice: 3
Enter vector x coordinate: -1
Enter vector y coordinate: 0
The point (-1, -1) rotated by the vector <-1, 0> (180 degrees) is now at (1, 1)
Menu:
        1) Enter point (x, y) coordinate
        2) Rotate point by angle
        3) Rotate point by vector
        4) Rotate point by vector around point
        0) Quit
Choice: 1
Enter point x coordinate: -1
Enter point y coordinate: -1
Menu:
        1) Enter point (x, y) coordinate
        2) Rotate point by angle
        3) Rotate point by vector
        4) Rotate point by vector around point
        0) Quit
Choice: 4
Enter point x coordinate: 1
Enter point y coordinate: 1
Enter vector x coordinate: -1
Enter vector y coordinate: 0
The point (-1, -1) rotated by the vector <-1, 0> (180 degrees) around the point (1, 1) is now at (3, 3)

Grading Rubric


Your submission will be graded according to the following rubric:

PointsRequirement Description
0.5Submitted correctly by Tuesday, September 26, 2023, 11:59 PM
0.5Project builds without errors nor warnings.
2.0Best Practices and Style Guide followed.
0.5Program follows specified user I/O flow.
0.5Public and private tests successfully passed.
2.0Fully meets specifications.
6.00Total Points

Extra Credit PointsRequirement Description
+1.0 Extra credit: Add another menu option to rotate around a point other than the origin.


Submission


Always, always, ALWAYS update the header comments at the top of your main.cpp file. And if you ever get stuck, remember that there is LOTS of help available.

Zip together your main.cpp, vectorMath.h, vectorMath.cpp, Makefile files and name the zip file A2.zip. Upload this zip file to Canvas under A2.


→This assignment is due by Tuesday, September 26, 2023, 11:59 PM.←
→ As with all assignments, this must be an individual effort and cannot be pair programmed. Any debugging assistance must follow the course collaboration policy and be cited in the comment header block for the assignment.←
→ Do not forget to complete the following labs with this set: L2A, L2B, L2C
→ Do not forget to complete zyBooks Assignment 2 for this set.←