Class Name: CS 003A (FUNDAMENTALS OF COMPUTER SCIENCE II (C++))
Institution: Pasadena City College (Dual Enrollment)
Project Duration: April-May 2022
Project Description: Make a interactive function grapher with C++ and STL
Unfortunately I lost access to my code because my repository was part of Github Classroom and I lost access to it once I was removed from the classroom. However, you can see a demonstration of how the final works in the video to the right.
Functionality:
Plots polynomials of a single variable and trignometric functions (sin cos tan)
Pan and zoom in/out with keyboard keys
Enter equation to plot on the right sidebar by clicking, tying with keyboard, and pressing enter
Previous plots saved in equation history and you can retrieve them by clicking on them
Save and load history
The architecture of my program was as follows:
SFML (graphic interface) related classes
animate: Handles user interactions
system: Updates what the frames should look like after zoom/pan
graph: Plots a vector of Point objects
plot: Translates xy coordinates to coordinates of screen
Equation-parsing classes (Actually generate the points)
shunting-yard: Parses equations in infix notation to postfix notation, puts each number/operand in a vector
RPN: Takes the equation from shunting-yard in postfix notation and computes the answer
So, when the user inputs an new equation or zooms/pans:
animate detects the desired interaction and tells system
system determines the new x y domain of the screen and tells graph this domain
graph asks plot to generate a list of points for the given function in the given domain
For every x in the x domain, the corresponding y is calculated for the user-inputted equation using shunting-yard and RPN
plot turns the (x,y) pairs into coordinates on the physical screen, passes it back up to graph
graph plots the physical screen coordinates
To load/save equations, the equations are saved to and read from a text file. But I forgot the specifics of how that works 🙃Â
SFML library
Constructors, destructors, and copying
1D and 2D pointers
Stacks and queues
Vectors