Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- #include <math.h>
- #include <stdio.h>
- #define PI 3.14159265359
- int main()
- {
- double x1, x2, x3, y1, y2, y3, z1, z2, z3;
- std::vector<double> points;
- std::string input;
- std::cin >> input;
- std::string temp = "";
- for(int i = 0; i < input.size(); i++)
- {
- if (input[i] != ',' && input[i] != ';')
- {
- temp += input[i];
- }
- else
- {
- points.push_back(std::stod(temp));
- temp = "";
- }
- }
- x1 = points[0];
- y1 = points[1];
- z1 = points[2];
- x2 = points[3];
- y2 = points[4];
- z2 = points[5];
- x3 = points[6];
- y3 = points[7];
- z3 = points[8];
- double a = sqrt(pow(x2 - x3, 2) + pow(y2 - y3, 2) + pow(z2 - z3, 2));
- double b = sqrt(pow(x3 - x1, 2) + pow(y3 - y1, 2) + pow(z3 - z1, 2));
- double c = sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2) + pow(z1 - z2, 2));
- double ang1 = (b*b + c*c - a*a) / (2*b*c);
- double ang2 = (a*a + c*c - b*b) / (2*a*c);
- double ang3 = (a*a + b*b - c*c) / (2*a*b);
- std::cout << (int)(acos(ang1) * 180 / PI) << ",";
- std::cout << (int)(acos(ang2) * 180 / PI) << ",";
- std::cout << (int)(acos(ang3) * 180 / PI);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement