Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <algorithm>
- #include <iomanip>
- using namespace std;
- struct direct
- {
- double k = 0, b = 0;
- double parametr = 0;
- };
- struct vershina
- {
- double x, y;
- };
- direct storona (vershina first, vershina second)
- {
- direct stright;
- if(first.x - second.x != 0)
- {
- stright.k = (first.y - second.y)/(first.x - second.x);
- stright.b = first.y - stright.k*first.x;
- }
- else stright.parametr = first.x;
- return stright;
- }
- vershina result (direct one, vershina head, double dlina)
- {
- vershina result;
- direct two;
- if (one.k != 0)
- two.k = -1/one.k;
- two.b = head.y - head.x*two.k;
- vershina times;
- times.x = head.x-1;
- times.y = two.k*times.x+two.b;
- times.x = head.x - times.x;
- times.y = head.y - times.y;
- double koeff = sqrt((dlina*dlina)/(times.x*times.x + times.y*times.y));
- result.x = times.x*koeff;
- result.x = head.x - result.x;
- result.y = times.y*koeff;
- result.y = head.y - result.y;
- return result;
- }
- int main ()
- {
- vershina A, B, C, D;
- cin >> A.x >> A.y >> B.x >> B.y;
- direct AB, DB;
- double dlina = sqrt((A.x - B.x)*(A.x - B.x) + (A.y - B.y)*(A.y - B.y));
- AB = storona (A, B);
- D = result(AB, A, dlina);
- DB = storona (D, B);
- C = result(DB, A, dlina*sqrt(2));
- cout << C.x << " " << C.y << " ";
- cout << D.x << " " << D.y << " ";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement