2-D Transformation

Apr 14th, 2015
Studypool Tutor
Price: $5 USD

Tutor description

A graphics program to perform 2 dimensional transformations such as rotation,reflection,scaling and translation.

Word Count: 483
Showing Page: 1/5
#include#include#include#includeint main(){ int gd=DETECT, gm; int poly[10], temp[10]; int choice, tx, ty, i, xp, yp, choice2; float r, sx, sy; double theta; initgraph(&gd,&gm,"C:\\TurboC3\\BGI"); setviewport(getmaxx()/2, getmaxy()/2, getmaxx(), getmaxy(), 0); printf("\n\tPOLYGON COORDINATES:"); for (i=0; i<10; i++) { if(i%2==0) { printf("\nEnter x- cordinate: "); scanf("%d",&poly[i]); } else { printf("\nEnter y-coordinate: "); scanf("%d",&poly[i]); } } for(i=0; i<10; i++)temp[i]=poly[i]; do { clrscr(); cleardevice(); setlinestyle(SOLID_LINE,1,2); setcolor(WHITE); line(0,-getmaxy(),0, getmaxy()); line(-getmaxx(), 0 ,getmaxx(), 0); drawpoly(5,poly); printf("\n\t\t2-D TRANSFORMATIONS"); printf("\n\t1. Translation"); printf("\n\t2. Scaling"); printf("\n\t3. Rotation"); printf("\n\t4. Reflection"); printf("\n\t5. Exit"); printf("\n\nEnter your choice: "); scanf("%d",&choice); setcolor(WHITE); if(choice==1) { clrscr(); cleardevice(); setcolor(WHITE); line(0,-getmaxy(),0, getmaxy()); line(-getmaxx(), 0 ,getmaxx(), 0); drawpoly(5,poly); printf("\n\t\tTRANSLATION OPERATION"); printf("\nEnter x-translation value: "); scanf("%d",&tx); printf("\nEnter y-translation value: "); scanf("%d",&ty); line(0,-getmaxy(),0, getmaxy()); line(-getmaxx(), 0 ,getmaxx(), 0); drawpoly(5,poly);

Review from student

Studypool Student
" Very Satisfied. "
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1821 tutors are online

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors