Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <graphics.h>
- #include <cmath>
- #define N 3
- #define PI 3.1415
- void poli(float valx,int points[],int n)
- {
- int i;
- int xc=0, yc=0;
- for(int i=0;i<5;i++){
- xc += points[2*i];
- yc += points[2*i+1];
- }
- xc/=5;yc/=5;
- double cosa = cos(PI/4), sina = sin(PI/4);
- for(int i=0;i<n;i++){
- double xi,yi;
- xi = points[2*i];
- yi = points[2*i+1];
- points[2*i] = xc + (xi-xc)*cosa - (yi-yc)*sina;
- points[2*i+1] = yc + (xi-xc)*sina + (yi-yc)*cosa;
- }
- }
- void translatie(int valx,int valy,int points[],int n)
- {
- int i; for(i=0;i<5*2;i++)
- {points[2*i]=points[2*i]+valx*100;
- points[2*i+1]=points[2*i+1]+valy*100;
- }
- for(int i=0;i<2*n;i++)
- setcolor(YELLOW);
- drawpoly(5,points);
- }
- int main()
- {int n=5;
- initwindow(800,600); // open a 400x300 graphics window
- int points[]={200,200,300,200,300,300,200,300,200,200},v[50];
- drawpoly(n,points);
- int i;
- int pct=n*2;
- float valx=2;
- float valy=2;
- poli(valx,points,n);
- translatie(valx,valy,points,n);
- valy=0-valy;
- translatie(valx,valy,points,n);
- valx=0-valx;
- translatie(valx,valy,points,n);
- while(!kbhit()); // wait for user to press a key
- closegraph(); // close graphics window
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement