Code Monkey home page Code Monkey logo

polytransformer's Introduction

PolyTransformer

An interactive python program to apply transformations (both linear and non - linear) to an object and plot it using matplotlib.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

This project needs python3 installed on the local machine along with matplotlib, which can be installed using:

$ python3 -m pip install matplotlib

Running

main.py defines all the functions and can be run using:

$ python3 main.py

Input

The first line contains the word disc or polygon denoting the figure you want to plot and transform

  • If the word is disc, the next line contains three space-separated integers as:

    disc
    center_X center_Y radius
  • If the word is polygon, the next two lines contain space separated lists X[] and Y[] of equal length, denoting the x-y co-ordinates of the vertices of the polygon.

    polygon
    x1 x2 x3 ... xN
    y1 y2 y3 ... yN
    

The next few lines should contain a single query each, denoting the transformation you have to perform. Each query will be of the form:

  • S x y : scale the object by a factor of x along the x-axis, and y along the y-axis.

  • R theta : rotate the object by angle theta(in degrees, 0 <= theta <= 360) in the counter-clockwise direction about the origin.

  • T dx dy : translate the object by dx units along the x-axis, and by dy units along the y-axis.

Each transformation will be performed on the shape obtained as a result of all the previous transformations, ie the effect of the transformations will be cumulative.

To exit the program, type quit and enter.

Output

Each transformation will be reflected on an X-Y plot and the new coordinates after each transformation will be printed as output.

Example

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

Authors

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.