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, int shet)
- {
- 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));
- if (shet == 0)
- {
- result.x = times.x*koeff;
- result.x = head.x - result.x;
- result.y = times.y*koeff;
- result.y = head.y - result.y;
- }
- else
- {
- 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 >> C.x >> C.y;
- direct AC, DB;
- double dlina = sqrt((A.x - C.x)*(A.x - C.x) + (A.y - C.y)*(A.y - C.y));
- AC = storona (A, C);
- vershina seredina_AC;
- seredina_AC.x = (A.x + C.x)/2;
- seredina_AC.y = (A.y + C.y)/2;
- B = result(AC, seredina_AC, dlina/2, 0);
- D = result(AC, seredina_AC, dlina/2, 1);
- cout << B.x << " " << B.y << endl;
- cout << D.x << " " << D.y << " ";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement