https://github.com/bhavyac16/polygon-transformer
Interactive program to visualise geometric transformations on 2D objects.
https://github.com/bhavyac16/polygon-transformer
Last synced: 4 months ago
JSON representation
Interactive program to visualise geometric transformations on 2D objects.
- Host: GitHub
- URL: https://github.com/bhavyac16/polygon-transformer
- Owner: BhavyaC16
- License: gpl-3.0
- Created: 2019-06-10T05:21:10.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-06-11T05:39:54.000Z (about 6 years ago)
- Last Synced: 2025-01-08T16:31:58.876Z (5 months ago)
- Language: Python
- Homepage:
- Size: 30.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Polygon-Transformer
Polygon-Transformer lets you visualize polygons, circles and ellipses, as well as the following geometrical transformations:- Translation
- Rotation
- Scaling## Usage
1. Run [polygonTransformer.py](https://github.com/BhavyaC16/Polygon-Transformer/blob/master/polygonTransformer.py)
2. In the first line, enter the type of geometric object you wish to create. It can either be a POLYGON, or a DISC. In the next line, you specify the object coordinates and dimensions as follows:
```
POLYGON
for n sided polygon, enter space separated list of X coordinates of vertices in the first line
enter space separated list of corresponding Y coordinates in the second line
DISC
for a circle, this line contains the following space separated attributes: centerX centerY radius
```
3. Now, any of the following commands can be used for any number of times:
```
T x y
Translates the 2D object by x units on the X axis, and Y units on the Y axis
R theta
Rotates the 2D object by theta degrees in the anti-clockwise direction
S x y
Scales the 2D object by x times about the X axis, and y times about the Y axis
```
4. To exit the program, type 'quit'.## Output
After each command, the transformed figure is plotted, and the attributes of the transformed figure are displayed as follows:
```
POLYGON:
line 1: list of x coordinates of transformed object
line 2: list of y coordinates of transformed object
DISC:
centerX centerY majorAxis minorAxis
```## Sample Input and Output
### Input
```
polygon
1 -1 -1 1
1 1 -1 -1
S 2 1
R 90
T 0 -2
quit
```
### Output
```
2 -2 -2 2
1 1 -1 -1
-1 -1 1 1
2 -2 -2 2
-1 -1 1 1
0 -4 -4 0
```