1 / 9

Rotation And Scalling

Rotation And Scalling . By: Asima Latif. SCALING. #include<iostream.h> #include<conio.h> #include<graphics.h> #include<dos.h> void main() { int gd=DETECT,gm,x[10],y[10],a,b,i,j,dx,dy; clrscr();. SCALING…. initgraph(&gd,&gm,"c:\tc\bgi");

triage
Download Presentation

Rotation And Scalling

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Rotation And Scalling By: Asima Latif

  2. SCALING #include<iostream.h> #include<conio.h> #include<graphics.h> #include<dos.h> void main() { int gd=DETECT,gm,x[10],y[10],a,b,i,j,dx,dy; clrscr();

  3. SCALING… initgraph(&gd,&gm,"c:\\tc\\bgi"); cout<<" To draw polygon enter the number of sides for polygon\t"; cin>>j; cout<<"\n Now enter co-ordinates for each point\n\t"; for(i=0;i<j;i++) cin>>x[i]>>y[i]; a=x[0]; b=y[0]; setcolor(BLUE); for(i=1;i<=j-1;i++) { line(x[i],y[i],x[i+1],y[i+1]); }

  4. SCALING… line(x[i],y[i],a,b); cout<<"\n Enter the co-ordinates for scaling \t"; cin>>dx>>dy; cout<<"\n After scaling"; for(i=1;i<=j-1;i++) { line(x[i]*dx, y[i]*dy, x[i+1]*dx, y[i+1]*dy); } line(x[i]*dx, y[i]*dy, a*dx, b*dy); getch(); closegraph(); }

  5. ROTATION • #include<iostream.h> • #include<conio.h> • #include<graphics.h> • #include<dos.h> • #include<math.h> • void main() • { • int gd=DETECT,gm,x[10],y[10],a,b,i,j,dx,dy,var1,var2,ang; • float d; • clrscr();

  6. ROTATION… • initgraph(&gd,&gm,"c:\\tc\\bgi"); • cout<<" To draw polygon enter the number of sides for polygon\t"; • cin>>j; • cout<<"\n Now enter co-ordinates for each point\n\t"; • for(i=0;i<j;i++) • cin>>x[i]>>y[i]; • a=x[0]; b=y[0]; • setcolor(BLUE); • for(i=0;i<j-1;i++) • { • line(x[i],y[i],x[i+1],y[i+1]); • delay(500); • }

  7. ROTATION… • line(x[i],y[i],a,b); • setcolor(RED); • cout<<"\n Enter the angle for rotation \t"; • cin>>ang; • cout<<"\n After rotation"; • d=(3.14*ang)/180 • var1=x[0]*cos(d)-y[0]*sin(d)-x[0]; • var2=x[0]*sin(d)+y[0]*cos(d)-y[0];

  8. ROTATION… for(i=0;i<j-1;i++) { line( x[i]*cos(d)-y[i]*sin(d)-var1, x[i]*sin(d)+y[i]*cos(d)-var2, x[i+1]*cos(d)-y[i+1]*sin(d)-var1, x[i+1]*sin(d)+y[i+1]*cos(d)-var2 ); delay(500); } line( x[i]*cos(d)-y[i]*sin(d)-var1, x[i]*sin(d)+y[i]*cos(d)-var2, x[0]*cos(d)-y[0]*sin(d)-var1, x[0]*sin(d)+y[0]*cos(d)-var2 ); getch(); closegraph(); }

  9. Eid Mubarik in Advance!

More Related