void draw_arrow(int x, int y) { /* draw an arrow on the screen */ moveto(x, y); linerel(4*ARROW_SIZE, 0); linerel(-2*ARROW_SIZE, -1*ARROW_SIZE); linerel(0, 2*ARROW_SIZE); linerel(2*ARROW_SIZE, -1*ARROW_SIZE); }
void draw_arrow(int x, int y) { /* draw an arrow on the screen */ moveto(x, y); linerel(4*az, 0); linerel(-2*az, -1*az); linerel(0, 2*az); linerel(2*az, -1*az); }
void triangle(int xalpha, int yalpha,int mode) { int i,j=0; moveto(xalpha-=5,yalpha+=2); for(i=0;i<5;i++) { moveto(xalpha+0,yalpha+0); linerel(i/0.577,i); //Para ángulo de 30º se divide entre 0.577 para la pendiente. linerel(-i/0.577,i); linerel(0,-i*2); } }
void makeLine( turtle* t, int len ) { int x,y; x = len * cos(t->angle); y = len * sin(t->angle); linerel(x,y); }
int main() { int unidad = 0,modo; initgraph (&unidad,&modo,"c:\\bc\\bgi"); if (graphresult() != 0) { cout << "Error al tratar de pasar al modo grafico\n"; getch(); return 1; } setpalette (8,RED); setcolor(8); setlinestyle(CENTER_LINE,0,0);; linerel (100,100); getch(); closegraph(); return 0; }
void drawaxe(double *axe) { int answx,answy,answz; int i,nx,ny,nz; double px,dx,pasx[32],pasy[32],pasz[32]; extern double extreme[]; double horizont(double x,double y,double z); double vertical(double x,double y,double z); printf("The X axis from %4g to %4g with the origin at %4g. Divide ? (y/n)\n", extreme[0],extreme[1],axe[0]); answx=bioskey(0); if(answx==5465||answx==5497) { printf("division step= "); scanf("%lf",&dx); px=axe[0]; while(px>extreme[0]) px-=dx; for(nx=0;nx<32;nx++) { px+=dx; if(px>=extreme[1]) break; pasx[nx]=px; } } printf("The Y axis from %4g to %4g with the origin at %4g. Divide ? (y/n)\n", extreme[2],extreme[3],axe[1]); answy=bioskey(0); if(answy==5465||answy==5497) { printf("division step = "); scanf("%lf",&dx); px=axe[1]; while(px>extreme[2]) px-=dx; for(ny=0;ny<32;ny++) { px+=dx; if(px>=extreme[3]) break; pasy[ny]=px; } } printf("The Z axis from %4g to %4g with the origin at %4g. Divide ? (y/n)\n", extreme[4],extreme[5],axe[2]); answz=bioskey(0); if(answz==5465||answz==5497) { printf("division step = "); scanf("%lf",&dx); px=axe[2]; while(px>extreme[4]) px-=dx; for(nz=0;nz<32;nz++) { px+=dx; if(px>=extreme[5]) break; pasz[nz]=px; } } dx=(extreme[7]-extreme[6])/639; double dy=extreme[9]-extreme[8]; cleardevice(); setcolor(15); moveto((horizont(extreme[0],axe[1],axe[2])-extreme[6])/dx, ((vertical(extreme[0],axe[1],axe[2])-extreme[8])/dy-1)* -399); lineto((horizont(extreme[1],axe[1],axe[2])-extreme[6])/dx, ((vertical(extreme[1],axe[1],axe[2])-extreme[8])/dy-1)* -399); moveto((horizont(axe[0],extreme[2],axe[2])-extreme[6])/dx, ((vertical(axe[0],extreme[2],axe[2])-extreme[8])/dy-1)* -399); lineto((horizont(axe[0],extreme[3],axe[2])-extreme[6])/dx, ((vertical(axe[0],extreme[3],axe[2])-extreme[8])/dy-1)* -399); moveto((horizont(axe[0],axe[1],extreme[4])-extreme[6])/dx, ((vertical(axe[0],axe[1],extreme[4])-extreme[8])/dy-1)* -399); lineto((horizont(axe[0],axe[1],extreme[5])-extreme[6])/dx, ((vertical(axe[0],axe[1],extreme[5])-extreme[8])/dy-1)* -399); if(answx==5465||answx==5497) { for(i=0;i<nx;i++) { moveto((horizont(pasx[i],axe[1],axe[2])-extreme[6])/dx, ((vertical(pasx[i],axe[1],axe[2])-extreme[8])/dy-1)*-399); linerel(0,-3); } } if(answy==5465||answy==5497) { for(i=0;i<ny;i++) { moveto((horizont(axe[0],pasy[i],axe[2])-extreme[6])/dx, ((vertical(axe[0],pasy[i],axe[2])-extreme[8])/dy-1)*-399); linerel(0,-3); } } if(answz==5465||answz==5497) { for(i=0;i<nz;i++) { moveto((horizont(axe[0],axe[1],pasz[i])-extreme[6])/dx, ((vertical(axe[0],axe[1],pasz[i])-extreme[8])/dy-1)*-399); linerel(3,0); } } return; }