Two points and a point inside
Hello all .
My name is Cordel and I would appreciate your help with the following problem.
I have two points (x1,y1) (x2,y2) and one more point N(a,b) and I need to check whether or not the point N is inside the rectangle that has been made by the first two points.
I've tried a few ways to solve that problem but came up empty handed.
Any suggestions ?
Thankx in advance
You mean its x coordinate should be in between x1 and x2, and its y coordinate should be in between y1 and y2?
O, and don't cross post please.
O, and don't cross post please.
I mean that if you take P1 and P2 (the 1st two points) and put them on a diagonal line ,you would get a rectangle (the points cannot by on an horizontal line or vertical line - only diagonal) .
Now ,let us take N(a,b) and put it inside the rectangle that has been made.
I need to check whether N is inside or not .
Sorry for not mentioning it before !!!
edit :
BTW I've tried using dot-product but didn't succeed,and therefore I'm looking for other ideas.
Now ,let us take N(a,b) and put it inside the rectangle that has been made.
I need to check whether N is inside or not .
Sorry for not mentioning it before !!!
edit :
BTW I've tried using dot-product but didn't succeed,and therefore I'm looking for other ideas.
I've read it.
You mean maybe to substract each two dots (x1 and x2 ,y1 and y2) and somehow comapare it with (a,b) ?
You mean maybe to substract each two dots (x1 and x2 ,y1 and y2) and somehow comapare it with (a,b) ?
Quote:Original post by cordel
I've read it.
You mean maybe to substract each two dots (x1 and x2 ,y1 and y2) and somehow comapare it with (a,b) ?
No, that wouldn't work.
Just check whether x1 <= a <= x2 and y1 <= b <= y2 (after making sure x1 <= x2 and y1 <= y2 by swapping the coordinates around accordingly if necessary).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement