Advertisement
Guest User

Untitled

a guest
Aug 19th, 2016
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <math.h>
  5. #include <stdio.h>
  6.  
  7. #define PI 3.14159265359
  8.  
  9. int main()
  10. {
  11. double x1, x2, x3, y1, y2, y3, z1, z2, z3;
  12. std::vector<double> points;
  13. std::string input;
  14. std::cin >> input;
  15. std::string temp = "";
  16. for(int i = 0; i < input.size(); i++)
  17. {
  18. if (input[i] != ',' && input[i] != ';')
  19. {
  20. temp += input[i];
  21. }
  22. else
  23. {
  24. points.push_back(std::stod(temp));
  25. temp = "";
  26. }
  27. }
  28.  
  29. x1 = points[0];
  30. y1 = points[1];
  31. z1 = points[2];
  32. x2 = points[3];
  33. y2 = points[4];
  34. z2 = points[5];
  35. x3 = points[6];
  36. y3 = points[7];
  37. z3 = points[8];
  38.  
  39. double a = sqrt(pow(x2 - x3, 2) + pow(y2 - y3, 2) + pow(z2 - z3, 2));
  40. double b = sqrt(pow(x3 - x1, 2) + pow(y3 - y1, 2) + pow(z3 - z1, 2));
  41. double c = sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2) + pow(z1 - z2, 2));
  42.  
  43. double ang1 = (b*b + c*c - a*a) / (2*b*c);
  44. double ang2 = (a*a + c*c - b*b) / (2*a*c);
  45. double ang3 = (a*a + b*b - c*c) / (2*a*b);
  46.  
  47.  
  48. std::cout << (int)(acos(ang1) * 180 / PI) << ",";
  49. std::cout << (int)(acos(ang2) * 180 / PI) << ",";
  50. std::cout << (int)(acos(ang3) * 180 / PI);
  51.  
  52. return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement