Advertisement
Guest User

Untitled

a guest
Jul 25th, 2014
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <cmath>
  4.  
  5.  
  6. using namespace std;
  7. class Punkt {
  8. public:
  9. float x;
  10. float y;
  11. void display()
  12. {
  13. cout<<"("<<x<<", "<<y<<")";
  14. }
  15. Punkt(float positionX, float positionY) {
  16. x=positionX;
  17. y=positionY;}
  18.  
  19. Punkt(){
  20. x=0;
  21. y=0;
  22. }
  23.  
  24. };
  25. class Trojkat{
  26. public:
  27. Punkt A, B, C;
  28. float liczPole()
  29. {
  30. float AB = sqrt((A.x - B.x)*(A.x - B.x)+(A.y - B.y)*(A.y - B.y));
  31. float d, e, f;
  32. d=(B.y-A.y)/(B.x-A.x);
  33. e=A.y-d*A.x;
  34. //C.y=(-1/d)*C.x+f
  35. f=C.y-(-1/d)*C.x;
  36. Punkt P;
  37. //y=d*x+e
  38. //y=(-1/d)*x+f
  39. //d*x+e=(-1/d)*x+f
  40. //d*x+(1/d)*x=f-e
  41. P.x=(f-e)/(d+(1/d));
  42. P.y=(-1/d)*P.x+f;
  43. float PC = sqrt((P.x - C.x)*(P.x - C.x)+(P.y - C.y)*(P.y - C.y));
  44. return (AB*PC)/2;
  45. }
  46. float liczObwod()
  47. {
  48. float AB = sqrt((A.x - B.x)*(A.x - B.x)+(A.y - B.y)*(A.y - B.y));
  49. float BC = sqrt((C.x - B.x)*(C.x - B.x)+(C.y - B.y)*(C.y - B.y));
  50. float CA = sqrt((C.x - A.x)*(C.x - A.x)+(C.y - A.y)*(C.y - A.y));
  51. return AB+BC+CA;
  52. }
  53. };
  54.  
  55. int main()
  56. {
  57.  
  58.  
  59. return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement