/CGIP-Project

Computer graphics program to draw different polygons

Primary LanguagePython

CGIP-Project

Computer Graphics and Image Processing

Assignment II

Team 8 [36-40]

Team Members

  • 36 Ashwin P Saji
  • 37 Ashwin Sivasankaran ashwinsk24
  • 38 Aswin Babu
  • 39 Aswin Pradeep
  • 40 Beneeta Ann Jacob

Polygon Reflection

This is a Python program that allows the user to input the coordinates of a polygon, and then reflects it across the line y=x using a 3x3 matrix transformation on: [0,1,0] [1,0,0] [0,0,1] The program uses the numpy and turtle libraries to perform the reflection and display the original and reflected polygons in a graphical window.

Usage

To use the program, simply run the reflected.py file in a Python environment. When prompted, enter the number of vertices in the polygon, followed by the x and y coordinates of each vertex.

The program will then display two polygons in a Turtle graphics window: the original polygon in blue, and the reflected polygon in red. The x- and y-axes are also displayed in black.

Dependencies

This program requires the following libraries to be installed:

numpy
turtle
flask (web app)

Requirements

To run this program, you will need:

  • Python 3.7+
  • NumPy
  • PythonTurtle
  • Code Editor

Usage

  • Clone or download the repository to your local machine.
  • Open a terminal and navigate to the directory where you saved the repository.
  • Run the program using the command: python reflected.py
  • Enter the number of vertices and coordinates of the polygon when prompted.
  • The program will display the original polygon in red and the reflected polygon in blue, with the x and y axes labeled.
  • Check the 2nd branch - webapp to see the web implementation of the project.

Final Result

Input:

>python reflected.py
Enter the number of vertices in the polygon: 3
Enter x-coordinate of vertex 1: 2
Enter y-coordinate of vertex 1: 5
Enter x-coordinate of vertex 2: 5
Enter y-coordinate of vertex 2: 7
Enter x-coordinate of vertex 3: 2
Enter y-coordinate of vertex 3: 8 

Output:

Final Output

DEMO

cgip.mp4