Qt has a class
QRect which tells whether the point is inside the rectangle or not.
Now, the problem is to find out on which outer side (out of four) of the rectangle does the point lie.
The equation that I already have is:
double m = (y2 - y1) / (x2 - x1); double equationResult = (newY - y1) - ((m * newX) + (m * x1)); if (equationResult < 0) return "in"; else return "out";
newY are the points which we are supposed to check.
The point lies on the right hand side of the rectangle.
So, with this assumption in mind when I supplied the end points of the top of the rectangle, the result I got was
Even with the end points of the right side, the result I got was
So, if more than one sides are going to give the same output, how am I supposed to know the position of the point?