This program graphically displays basic trigonometric functions — sine, cosine, tangent, and cotangent — using the old graphics.h library in C++.
It provides an interactive menu for selecting and plotting these functions, and allows users to plot custom points on the coordinate plane.
- Plot sine, cosine, tangent, and cotangent waveforms.
- Interactive menu system for easy navigation.
- Custom point plotting with coordinate transformation.
- Basic graphical window scaling to full screen.
- Visual guide lines and sector grids for better readability.
- Ensure your system supports
graphics.h(typically an older Windows environment with compatible IDE like Turbo C++ or configured MinGW). - Compile all source files together.
- Run the executable.
- Use the menu to select the desired function or option.
- Follow on-screen prompts for input.
main.cpp— Entry point with main menu.wave.cpp/h— Contains implementations for plotting trigonometric functions.menu.cpp/h— Menu handling and submenus.ValX.inandValY.in— Input files for coordinate transformations.
- Uses old
graphics.hlibrary, which is outdated and hard to set up on modern systems. Not portable outside Windows or specific IDE setups. - Contains magic numbers (e.g.,
-540) in calculations that lack clear explanation or scaling, making behavior inconsistent on different resolutions. - Array indexing and input handling in functions like
FuncPickis risky and can cause crashes if inputs are invalid or out of expected range. - Heavy use of
system("CLS")leads to flickering and is Windows-specific, breaking portability and making the UI less smooth. - Input and timing depend on
kbhit()anddelay(), resulting in a primitive, blocking user experience without proper event handling. - No error handling for file input (e.g.,
ValX.in,ValY.in), so missing or corrupted files will crash the program silently. - No boundary checks on pixel plotting, risking drawing outside the window or undefined behavior.
- Replace
graphics.hwith a modern, cross-platform graphics library (e.g., SFML, SDL). - Add input validation and error handling, especially for file reads and user input.
- Refactor magic numbers into named constants or computed values based on window size.
- Improve user interface with non-blocking input handling and smoother redraws.
- Add comments and documentation to improve maintainability.