Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. #include "graphics.h"
  2. #include <math.h>
  3. #include <stdlib.h>
  4. #include <dos.h>
  5. #include <windows.h>
  6. #include <iostream>
  7. #include<time.h>
  8. using namespace std;
  9. #define pi 3.14159265359
  10. float x_1, x_2, y_1, y_2;
  11. float xa, xb, xc;
  12. float theta;
  13. int a, b;
  14. int xe(float x){// normalizarea coordonatei
  15. return((int)((x - x_1) / (x_2 - x_1)*a));
  16. }
  17. int ye(float y){// normalizarea coordonatei y
  18. return((int)((y_2 - y) / (y_2 - y_1)*b));
  19. }
  20. void axe(){
  21. setcolor(0);
  22. outtextxy(xe(x_2) - 20, ye(0) - 20, "x");
  23. outtextxy(xe(x_2) - 18, ye(0) - 7, ">");
  24. outtextxy(xe(0) - 15, ye(y_2) + 15, "y");
  25. outtextxy(xe(0) - 15, ye(0) - 15, "O");
  26. outtextxy(xe(0) - 1, ye(y_2) , "^");
  27. line(xe(x_1), ye(0), xe(x_2), ye(0));
  28. line(xe(0), ye(y_1), xe(0), ye(y_2));
  29. }
  30.  
  31. float l_x(float theta) {
  32. float sin_t = sin(theta);
  33. return 1 / (1 + sin_t*sin_t);
  34. }
  35.  
  36. float l_y(float theta) {
  37. float sin_t = sin(theta);
  38. return 1 * cos(theta) / (1 + sin_t*sin_t);
  39. }
  40.  
  41. void grafic() {
  42. float theta;
  43. float h = 2 * pi / 400;
  44. float x, y;
  45. theta = 0;
  46. float r = 1.f;
  47.  
  48. while (-2*pi>= theta <= 2 * pi) {
  49. x = theta*cos(theta) ;
  50. y = sin(theta);
  51. putpixel(xe(x), ye(y), 14);
  52. theta = theta + h;
  53. setcolor(3);
  54. }
  55.  
  56. }
  57.  
  58.  
  59. int main(){
  60. /*printf("Limitele domeniului orizontal:\n");
  61. printf("Atentie, x_1<0<x_2 si y_1<0<y_2 \n");
  62. printf("x_1="); scanf("%f", &x_1); //x_1<0<x_2
  63. printf("x_2="); scanf("%f", &x_2);
  64. printf("Limitele domeniului vertical:\n");
  65. printf("y_1="); scanf("%f", &y_1); //y_1<0<y_2
  66. printf("y_2="); scanf("%f", &y_2);*/
  67. initwindow(800, 600, "AXE", 200, 200);
  68. setbkcolor(20);
  69. cleardevice();
  70. //time_t;
  71. //srand(time(NULL));
  72. //patrat desenat ale carui laturi au culori diferite
  73. //setcolor(rand() % 15);
  74. line(200, 220, 200, 320);
  75. //setcolor(rand() % 15);
  76. line(200, 220, 300, 220);
  77. //setcolor(rand() % 15);
  78. line(300, 220, 300, 320);
  79. //setcolor(rand() % 15);
  80. line(200, 320, 300, 320);
  81. //setcolor(rand() % 15);
  82.  
  83. /*//100 puncte aleatoriu de culori diferite //nu ai treaba cu asta
  84. for (int i = 0;i <= 100; i++) {
  85. putpixel(rand() % 200, rand() % 300, rand() % 15);
  86. }*/
  87.  
  88. //cercuri concentrice
  89. //float raza = 12.4;
  90. circle(400, 200, 12.4);
  91.  
  92.  
  93. /*a = getmaxx(); //nr. maxim de pixeli pe coord. x
  94. b = getmaxy();
  95. axe();
  96. grafic();*/
  97. getch();
  98. closegraph();
  99. return 0;
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement