Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/11/2012, 11:10
jeremiselxi
(Desactivado)
 
Fecha de Ingreso: septiembre-2008
Mensajes: 269
Antigüedad: 15 años, 7 meses
Puntos: 22
Agregarle los angulos y funciones trigonometricas

Buenas tardes Colegas.

Hoy tengo un gran dolor de cabeza con respecto a un triangulo.

He tratado de hacerlo de mil maneras pero no lo logro conseguir.

Tengo este codigo

Código C++:
Ver original
  1. # include <conio.h>
  2. # include <dos.h>
  3. # include <stdlib.h>
  4. void SetMCGA(void)
  5. { asm{
  6. MOV AH,00H
  7. MOV AL,13H
  8. INT 10h
  9. }}
  10. void SetText(void)
  11. { asm{
  12. MOV AX,0003H
  13. INT 10h
  14. }
  15. }
  16. void ActPunto(int x, int y,int c)
  17. { pokeb(0xA000,320*y+x ,c);
  18. }
  19. void SwapInt(int *a, int *b)
  20. {   int aux;
  21. aux=*a;
  22. *a=*b;
  23. *b=aux;
  24. }
  25. void Linea (int x0, int y0, int x1, int y1, char color)
  26. {   int dx, dy, IncrS, IncrN, d, x, y, IncrX, IncrY;
  27. if (abs(y1-y0) < abs(x1-x0))
  28. {
  29. if (x0 > x1)
  30. { SwapInt(&x0,&x1);
  31. SwapInt(&y0,&y1);
  32. };
  33. IncrY = (y1 > y0) ? 1:-1;
  34. dx=x1-x0;
  35. dy=abs(y1-y0);
  36. d=2*dy-dx;
  37. IncrS=2*dy;
  38. IncrN=2*(dy-dx);
  39. x=x0;
  40. y=y0;
  41. ActPunto(x,y,color);
  42. for (;x < x1;)
  43. {
  44. if (d <= 0)
  45. {
  46. d+=IncrS;
  47. x+=1;
  48. }
  49. else
  50. {
  51. d+=IncrN;
  52. x+=1;
  53. y+=IncrY;
  54. };
  55. ActPunto(x,y,color);
  56. };
  57. }
  58. else
  59. {if (y0 > y1);
  60. {
  61. SwapInt(&x1,&x0);
  62. SwapInt(&y1,&y0);
  63. }
  64. IncrX = (x1 > x0) ? 1:-1;
  65. dy=y1-y0;
  66. dx=abs(x1-x0);
  67. d=2*dx-dy;
  68. IncrS=2*dx;
  69. IncrN=2*(dx-dy);
  70. x=x0;
  71. y=y0;
  72. ActPunto(x,y,color);
  73. while (y < y1)
  74. {
  75. if (d <= 0)
  76. {
  77. d+=IncrS;
  78. y+=1;
  79. }
  80. else
  81. {
  82. d+=IncrN;
  83. y+=1;
  84. x+=IncrX;
  85. };
  86. ActPunto(x,y,color);
  87. };
  88. };
  89. }
  90. void triangulo(int x, int y, int x1, int y1, int x2, int y2, int c)
  91. {
  92. Linea(x,y,x1,y1,c);
  93. Linea(x,y,x2,y2,c);
  94. Linea(x2,y2,x1,y1,c);
  95. }
  96. union REGS i,o;
  97. void show_mouse()
  98. { i.x.ax=1;
  99. int86(0X33,&i,&o);
  100. }
  101. void hide_mouse()
  102. { i.x.ax=2;
  103. int86(0X33,&i,&o);
  104. }
  105. void get_mouse_pos(int *x, int *y, int *button)
  106. { i.x.ax=3;
  107. int86(0X33,&i,&o);
  108. *x=o.x.cx;
  109. *y=o.x.dx;
  110. *button=o.x.bx,&i;
  111. }
  112. void main(void)
  113. { SetMCGA();
  114. int button,x1,y1,x2,y2,cx=150,cy=150,cx1=100,cy1=100,cx2=200,cy2=100;
  115. triangulo(cx,cy,cx1,cy1,cx2,cy2,7);
  116. while(!kbhit())
  117. { show_mouse();
  118. get_mouse_pos(&x1,&y1,&button);
  119. x2=x1;
  120. y2=y1;
  121. while (button==1)
  122. { hide_mouse();
  123. triangulo(cx,cy,cx1,cy1,cx2,cy2,0);
  124. if ((cx==x1/2) && (cy==y1))
  125. { cx=x2/2;
  126. cy=y2;
  127. }
  128. triangulo(cx,cy,cx1,cy1,cx2,cy2,7);
  129. x1=x2;
  130. y1=y2;
  131. get_mouse_pos(&x2,&y2,&button);
  132. }
  133. }
  134. SetText();
  135. }


Yo lo que quiero es que pinte los angulos y las funciones trigonometricas