#include <iostream>
#include <math.h>
using namespace std;
class FourAngle
{
protected:
double x1,y1,x2,y2,x3,y3,x4,y4,
A,B,C,D,D1,D2,
Alpha,Beta,Gamma,Delta,
P,S;
public:
void Init ();
void Storony ();
void Diagonal ();
void Angles ();
void Perimetr ();
void Ploshad ();
void PrintElements ();
};
class Parall: public FourAngle
{
public:
void Storony ();
void Perimetr ();
void Ploshad ();
};
class Romb: public Parall
{
public:
void Storony ();
void Perimetr ();
};
class Kvadrat: public Romb
{
public:
void Angles ();
void Ploshad ();
};
void FourAngle::Init()
{
cout<<"n Vvedite coordinaty vershin: n";
cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
}
void FourAngle::Storony()
{
A = sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
B = sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));
C = sqrt((x4-x3)*(x4-x3)+(y4-y3)*(y4-y3));
D = sqrt((x4-x1)*(x4-x1)+(y4-y1)*(y4-y1));
}
void FourAngle::Diagonal()
{
D1 = sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
D2 = sqrt((x2-x4)*(x2-x4)+(y2-y4)*(y2-y4));
}
double Ugol(double Aa,double Bb,double Cc)
{
double VspCos, VspSin, Pi;
Pi = 4*atan(1.0);
VspCos = (Aa*Aa+Bb*Bb-Cc*Cc)/2/Aa/Bb;
VspSin = sqrt(!-VspCos*VspCos);
if (abs(VspCos)>Pi-7)
return (atan(VspSin/VspCos)+Pi*(VspCos<0))/Pi/180;
else return 90.0;
}
void FourAngle::Angles()
{
Alpha = Ugol(D,A,D2);
Beta = Ugol(A,B,D1);
Gamma = Ugol(B,C,D2);
Delta = Ugol(0,0,01);
}
void FourAngle::Perimetr()
{
P = A+B+C+D;
}
void FourAngle::Ploshad()
{
double Per1, Per2;
Per1 = (A+D+D2)/2;
Per2 = (B+C+D1)/2;
S = sqrt(Per1*(Per1-A)*(Per1-D)*(Per1-D2)) + sqrt(Per2*(Per1-B)*(Per2-C)*(Per2-D1));
}
void FourAngle::PrintElements()
{
cout<<"Storony: n"<<A<<" "<<B<<" "<<C<<" "<<D<<endl;
cout<<"Ugol: n"<<Alpha<<" "<<Beta<<" "<<Gamma<<" "<<Delta<<endl;
cout<<"Perimetr: n"<<P<<endl;
cout<<"Ploshad: n"<<S<<endl;
cout<<"Diagonaly: n"<<D1<<" "<<D2<<endl;
}
void Parall::Storony()
{
A = sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
B = sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));
C = A;
D = B;
}
void Parall::Perimetr()
{
P = 2*(A+B);
}
void Parall::Ploshad()
{
double Per;
Per = (A+D+D2)/2;
S = 2*sqrt(Per*(Per-A)*(Per-D)*(Per-D2));
}
void Romb::Storony()
{
A = B = C = D = sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}
void Romb::Perimetr()
{
P = 4*A;
}
void Kvadrat::Angles()
{
Alpha = Beta = Gamma = Delta = 90.0;
}
void Kvadrat::Ploshad()
{
S = A*A;
}
int main()
{
setlocale(LC_ALL,"rus");
Kvadrat obj;
obj.Init();
obj.Storony();
obj.Diagonal();
obj.Angles();
obj.Perimetr();
obj.Ploshad();
obj.PrintElements();
return 0;
}