#include <iostream>
#include <cmath>
using namespace std;
//float p=2.0,l=1.0, m=2.0, o=1.5, k=1.0, s=2.5;
//float g=4.0,h=2.0, j=4.0, t=3.0, b=2.0, n=5.0;
float p,l,m,o,k,s,h,j,t,n,g,b,c;
float q,w,e,x,v;
class triangle {
public:
triangle();
triangle(double x1_, double y1_, double x2_, double y2_, double x3_, double y3_) {
x1 = x1_;
y1 = y1_;
x2 = x2_;
y2 = y2_;
x3 = x3_;
y3 = y3_;
a = length(x1, y1, x2, y2);
b = length(x2, y2, x3, y3);
c = length(x3, y3, x1, y1);
}
double length(double, double, double, double);
float medianatoQ(float,float,float);
float medianatoW(float,float,float);
float medianatoE(float,float,float);
float medianatoMin(void);
//int Similarity(float,float,float,float,float,float);
//float get_square(float ,float ,float );
// float get_square1(float ,float ,float );
int check(float ,float ,float ,float , float , float );
int operator ^(const triangle &);
float operator +(const triangle &);
float S,S1;
bool isRight();
double GetLen(int);
//double GetLen(int) { return a; return b; return c; }
private:
double x1, y1;
double x2, y2;
double x3, y3;
double a, b, c;
};
double triangle::length(double x1_, double y1_, double x2_, double y2_) {
return sqrt((x2_ - x1_) * (x2_ - x1_) + (y2_ - y1_) * (y2_ - y1_));
}
/*
bool triangle::isRight() {
if ((sqrt(a * a + b * b) == c) || (sqrt(a * a + c * c) == b))
return true;
return false;
}
*/
double triangle::GetLen(int k) {
double arr[3] = {a, b, c};
return arr[k];
}
/*
float triangle::medianatoQ(float q,float w,float e){
return 0.5*sqrt((2*w*w)+(2*e*e)-(q*q));}
float triangle::medianatoW(float q,float w,float e){
return 0.5*sqrt((2*q*q)+(2*e*e)-(w*w));}
float triangle::medianatoE(float q,float w,float e){
return 0.5*sqrt((2*q*q)+(2*w*w)-(e*e));}
*/
float triangle::medianatoMin(void){
float r;r=min(a,min(b,c));
cout<<r<<endl;
if(a==r)
return 0.5*sqrt((2*b*b)+(2*c*c)-(a*a));
if(b==r)
return 0.5*sqrt((2*a*a)+(2*c*c)-(b*b));
if(c==r)
return 0.5*sqrt((2*a*a)+(2*b*b)-(c*c));
}
/*
int Similarity(float q,float w,float e,float x, float c, float v){
if (((q / x) && (w/c) && (e / v)) ||
((w / x) && (e/c) && (q/v)) ||
((e/x) && (q/c) && (w/v)))
{
cout << "Да" << endl;
return 1;
}
else
{ cout << "Нет" << endl;
return 0;
}
}
/*
float get_square(float q,float w,float e){
float P = (q + w + e) / 2.0;
float S = sqrt(P * (P - q) * (P - w) * (P - e));
// printf("sq_trg0= %lf \n", S);
return S;
}
float get_square1(float x, float c, float v){
float p = (x + c + v) / 2.0;
//cout<<p<<endl;
float S = sqrt((p * (p-x) * (p-c) * abs((p-v))));
cout<<S;
return S;
}
*/
int triangle::operator ^ (const triangle &second)
{
// triangle trg(p,l,m,o,k,s);
//triangle trg1(g,h,j,t,b,n);
if (((q / x) && (w/c) && (e / v)) ||
((w / x) && (e/c) && (q/v)) ||
((e/x) && (q/c) && (w/v)))
{
cout << "Да" << endl;
return 1;
}
else
{ cout << "Нет" << endl;
return 0;
}
}
float triangle::operator + (const triangle &second)
{
float P = (q + w + e) / 2.0;
float S = sqrt(P * (P - q) * (P - w) * (P - e));
// printf("sq_trg0= %lf \n", S);
float p = (x + c + v) / 2.0;
//cout<<p<<endl;
float s = sqrt((p * (p-x) * (p-c) * abs((p-v))));
//cout<<(S+s)<<endl;
cout<<"Сумма площадей :";
return S+s;
}
int main() {
setlocale(LC_ALL, "Russian");
cout<<"Введите координаты вершин треугольника АВС"<<endl;
cin>>p>>l>>m>>o>>k>>s;
cout<<"Введите координаты вершин треугольника DEF"<<endl;
cin>>g>>h>>j>>t>>b>>n;
triangle trg(p,l,m,o,k,s);
triangle trg1(g,h,j,t,b,n);
// float q,w,e,k,x,c,v;
q=trg.GetLen(0);
w=trg.GetLen(1);
e=trg.GetLen(2);
x=trg1.GetLen(0);
c=trg1.GetLen(1);
v=trg1.GetLen(2);
std::cout<<"a:"<<q<<"\t"<<"b:"<<w<<"\t"<<"c:"<<e<<endl;
std::cout<<"d:"<<x<<"\t"<<"e:"<<c<<"\t"<<"f:"<<v<<endl;
std::cout<<"Медиана к наименьшей стороне :"<<trg.medianatoMin()<<endl;
std::cout<<"Подобны:";(trg^trg1);
//std::cout<<(trg^trg1);
std::cout<<(trg+trg1);
return 0;
}