Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <iomanip>
- using namespace std;
- struct vershina
- {
- double x, y;
- };
- struct direct
- {
- double k = 0, b = 0;
- double parametr = 0;
- };
- direct normal (direct one, vershina trig)
- {
- direct normal;
- if (one.parametr == 0 && one.k != 0)
- {
- normal.k = -1/one.k;
- normal.b = trig.y - normal.k*trig.x;
- }
- else if (one.parametr != 0)
- {
- normal.k = 0;
- normal.b = trig.y;
- }
- else if (one.k == 0)
- normal.parametr = trig.x;
- //cout << normal.k << "x + " << normal.b << " " << normal.parametr << endl;
- return normal;
- }
- direct stright(vershina one, vershina two)
- {
- direct stright;
- if(two.x - one.x != 0)
- {
- stright.k = (one.y - two.y)/(one.x - two.x);
- stright.b = one.y - stright.k*one.x;
- }
- else stright.parametr = one.x;
- return stright;
- }
- vershina otvet (direct normal_1, direct normal_2)
- {
- vershina otvet;
- if (normal_1.parametr == 0 && normal_2.parametr == 0)
- {
- otvet.x = (normal_2.b - normal_1.b)/(normal_1.k - normal_2.k);
- otvet.y = normal_1.k*otvet.x + normal_1.b;
- }
- else if (normal_1.parametr != 0)
- {
- otvet.x = normal_1.parametr;
- otvet.y = normal_2.k*otvet.x + normal_2.b;
- }
- else if (normal_2.parametr != 0)
- {
- otvet.x = normal_2.parametr;
- otvet.y = normal_1.k*otvet.x + normal_1.b;
- }
- return otvet;
- };
- int main ()
- {
- vershina A, B, C;
- cin >> A.x >> A.y >> B.x >> B.y >> C.x >> C.y;
- direct AB = stright(A, B);
- direct BC = stright(B, C);
- direct normal_one = normal(AB, C);
- direct normal_two = normal(BC, A);
- cout.precision(10);
- cout << fixed << otvet(normal_one, normal_two).x << " ";
- cout << fixed << otvet(normal_one, normal_two).y;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement