Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <iomanip>
- using namespace std;
- struct otrezok
- {
- public:
- double x1, y1, x2, y2, x, y;
- double length;
- otrezok(double x1, double x2,double y1,double y2)
- {
- length = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
- }
- };
- struct ygol
- {
- double a;
- double cos_ygl, sin_ygl, tg_ygl;
- ygol (double a)
- {
- cos_ygl = cos(a*3.141592653/180.0);
- sin_ygl = sin(a*3.141592653/180.0);
- if (cos_ygl !=0 )
- tg_ygl = sin_ygl/cos_ygl;
- else tg_ygl = INT16_MAX;
- }
- };
- struct direct
- {
- double k = 0, b = 0;
- double parametr = INT16_MAX;
- };
- struct vershina
- {
- double x, y;
- vershina()
- {
- x = 0;
- y = 0;
- }
- };
- direct stright(vershina one, double k)
- {
- direct stright;
- if (k != INT16_MAX)
- {
- stright.k = k;
- stright.b = one.y - stright.k*one.x;
- }
- else stright.parametr = one.x;
- return stright;
- }
- double koeff (otrezok a, otrezok b, ygol A, double mediana)
- {
- double mediana_1;
- mediana_1 = sqrt(a.length*a.length + b.length*b.length/4 - a.length*b.length*A.cos_ygl);
- double koeff = mediana/mediana_1;
- return koeff;
- }
- vershina otvet (direct normal_1, direct normal_2)
- {
- vershina otvet;
- if (normal_1.parametr == INT16_MAX && normal_2.parametr == INT16_MAX)
- {
- 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 != INT32_MAX)
- {
- otvet.x = normal_1.parametr;
- otvet.y = normal_2.k*otvet.x + normal_2.b;
- }
- else if (normal_2.parametr != INT16_MAX)
- {
- otvet.x = normal_2.parametr;
- otvet.y = normal_1.k*otvet.x + normal_1.b;
- }
- return otvet;
- };
- int main ()
- {
- vershina A, B, C, B_1, C_1, seredina_AB;
- double mediana, a, b;
- cin >> mediana >> a >> b;
- ygol ygol_A(a);
- ygol ygol_B(b);
- B_1.x = 100;
- direct AC = stright(A, ygol_A.tg_ygl);
- direct BC = stright(B_1, -ygol_B.tg_ygl);
- C_1 = otvet(AC, BC);
- otrezok AB_1(A.x, B_1.x, A.y, B_1.y);
- otrezok AC_1 (A.x, C_1.x, A.y, C_1.y);
- B.x = koeff(AC_1, AB_1, ygol_A, mediana)*B_1.x;
- BC = stright(B, -ygol_B.tg_ygl);
- C = otvet(AC, BC);
- cout.precision(8);
- cout << fixed << A.x << " " << A.y << endl;
- cout << fixed << B.x << " " << B.y << endl;
- cout << fixed << C.x << " " << C.y << " ";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement