SHARE
TWEET

Untitled

a guest Oct 22nd, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <graphics.h>
  2. #include <cmath>
  3.  
  4. #define N 3
  5. #define PI 3.1415
  6.  
  7.  
  8. void poli(float valx,int points[],int n)
  9. {
  10. int i;
  11.  int xc=0, yc=0;
  12.     for(int i=0;i<5;i++){
  13.             xc += points[2*i];
  14.             yc += points[2*i+1];
  15.     }
  16.     xc/=5;yc/=5;
  17.  
  18.       double cosa = cos(PI/4), sina = sin(PI/4);
  19.     for(int i=0;i<n;i++){
  20.             double xi,yi;
  21.             xi = points[2*i];
  22.             yi = points[2*i+1];
  23.             points[2*i]   = xc + (xi-xc)*cosa - (yi-yc)*sina;
  24.             points[2*i+1] = yc + (xi-xc)*sina + (yi-yc)*cosa;
  25.     }
  26.  
  27.  
  28. }
  29. void translatie(int valx,int valy,int points[],int n)
  30. {
  31.     int i;    for(i=0;i<5*2;i++)
  32. {points[2*i]=points[2*i]+valx*100;
  33. points[2*i+1]=points[2*i+1]+valy*100;
  34.  
  35. }
  36.       for(int i=0;i<2*n;i++)
  37.     setcolor(YELLOW);
  38.     drawpoly(5,points);
  39.  
  40. }
  41.  
  42.  
  43. int main()
  44. {int n=5;
  45.     initwindow(800,600);        // open a 400x300 graphics window
  46.  
  47.     int points[]={200,200,300,200,300,300,200,300,200,200},v[50];
  48.     drawpoly(n,points);
  49. int i;
  50. int pct=n*2;
  51. float valx=2;
  52. float valy=2;
  53.  
  54.  
  55. poli(valx,points,n);
  56. translatie(valx,valy,points,n);
  57. valy=0-valy;
  58. translatie(valx,valy,points,n);
  59. valx=0-valx;
  60. translatie(valx,valy,points,n);
  61.  
  62.     while(!kbhit());           // wait for user to press a key
  63.  
  64.     closegraph();              // close graphics window
  65.     return 0;
  66. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top