0 Members and 2 Guests are viewing this topic.
x' = x*cos(theta) - y*sin(theta)y' = x*sin(theta) + y*cos(theta)
x' = (x-x0)*cos(theta) - (y-y0)*sin(theta) + x0y' = (x-x0)*sin(theta) + (y-y0)*cos(theta) + y0
c = cos(theta)s = sin(theta)for each point (x, y): x' = x*c - y*s y' = x*s + y*c
float magnitude(int x1,int y1,int x2,int y2){ return(sqrt(pow(x2-x1,2) + pow(y2-y1,2)));}struct floatpoint{ float X; float Y;};//LocationType poly[] = {{10,10},{LocationType sp[]={{10,10},{10,30},{5,27},{10,30},{15,27},{10,30},{10,25},{5,22},{10,25},{15,22},{10,25},{10,20},{5,17},{10,20},{15,17},{10,20}};floatpoint spf[];task main(){ float x,y; float xc,yc;// int dis; //x=0; //y=50; xc= 30; yc=30; float deg; int d; float dis[]; float c,s; int arrs = ArrayLen(sp); ArrayInit(dis,0,arrs); ArrayInit(spf,0,arrs); for(int c=0; c < arrs; c++) { dis[c] = magnitude(xc,yc,sp[c].X,sp[c].Y); sp[c].X += 30; sp[c].Y += 30; spf[c].X = sp[c].X; spf[c].Y = sp[c].Y; } while(1) { // x=x*(cosd(30))-y*(sind(30)); //y=x*(sind(30))+y*(cosd(30)); // x = cosd(deg--)*magnitude(0,0,x,y); // y = sind(deg)*magnitude(0,0,x,y); // x -= xc; //y -= yc; c = cosd(0); s = sind(0); for(int c=0; c < arrs; c++) { // deg = atan2d((sp[c].Y-yc),(sp[c].X-xc)); // x = spf[c].X*c-spf[c].Y*s; //y = spf[c].X*s+spf[c].Y*c; x = sqrt(pow((spf[c].X - xc),2) + pow((spf[c].Y - yc),2))*cosd(atand(spf[c].X - xc)/(spf[c].Y - yc)+ 5)+ xc; y = sqrt(pow((spf[c].X - xc),2) + pow((spf[c].Y - yc),2))*sind(atand(spf[c].X - xc)/(spf[c].Y - yc)+ 5)+ yc; //y = dis[c]*sind(deg + 3)+yc; // x = (sp[c].X-xc)*cosd(d) - (sp[c].Y-yc)*sind(d) + xc; //y = (sp[c].Y-yc)*cosd(d) - (sp[c].X-xc)*sind(d) + yc; spf[c].X = x; spf[c].Y = y; sp[c].X=spf[c].X; sp[c].Y=spf[c].Y; } d--; // sp[0].X=1; //CircleOut(x,y,10); PolyOut(sp);/* for(int c=0; c < arrs; c++) { PointOut(sp[c].X,sp[x].Y); }*/ Wait(30); ClearScreen(); }}
x = sqrt(pow((spf[c].X - xc),2) + pow((spf[c].Y - yc),2))*cosd(atand(spf[c].X - xc)/(spf[c].Y - yc)+ 5)+ xc;y = sqrt(pow((spf[c].X - xc),2) + pow((spf[c].Y - yc),2))*sind(atand(spf[c].X - xc)/(spf[c].Y - yc)+ 5)+ yc;