#include <iostream>
#include <string>
#include <math.h>
#define S_FLOAT 0.00000001
using namespace std;
typedef struct Point
{
float x;
float y;
Point() {}
Point(float x,float y)
{
this->x = x;
this->y = y;
}
};
float GetTriangleSquar(const Point a, const Point b, const Point c)
{
Point AB, BC;
AB.x = b.x - a.x;
AB.y = b.y - a.y;
BC.x = c.x - b.x;
BC.y = c.y - b.y;
return fabs(AB.x*BC.y - AB.y*BC.x) / 2;
}
string IsInTriang(Point a, Point b, Point c, Point d)
{
float Sabc, Sabd, Sacd, Sbcd;
Sabc = GetTriangleSquar(a, b, c);
Sabd = GetTriangleSquar(a, b, d);
Sacd = GetTriangleSquar(a, c, d);
Sbcd = GetTriangleSquar(b, c, d);
float Sums = Sabd + Sacd + Sbcd;
cout << "Sabd:" << Sabd << endl << "Sacd:" << Sacd << endl << "Sbcd:" << Sbcd << endl;
cout<< "Sabc:"<<Sabc<<endl<<"Sums:"<<Sums << endl;
if ((-S_FLOAT < (Sabc - Sums) && (Sabc - Sums) < S_FLOAT))
return "Yes";
else return "No";
}
void Test()
{
Point a(2, 2), b(0, 0), c(4, 0), d(2, 1);
cout << IsInTriang(a, b, c, d) << endl;
}
int main()
{
Test();
system("pause");
return 0;
}