I am working on a program to detect if one triangle is nested within another.
Here I created the struct point to define x and y as doubles.
struct Point {
double x;
double y;
};
Here is where I implement the struct:
double eval (LineSegment line, Point p)
{
Point p1 = p - line.StartPoint;
Point p2 = line.EndPoint - line.StartPoint;
return p2.x * p2.y - p1.y * p2.x;
}
When I compile it tells me, "no match for 'operator-' in 'p - line.LineSegment::StartPoint'." I don't really understand what is happening, I guess it doesn't understand which 'point' I want since i use them together?
I did research and found operator overloading, but it was sort of confusing to me. I don't really know how to implement Operator Overloading.
If someone could show me how exactly to go about doing this, it would be helpful.