Jump to content
  • Advertisement
Sign in to follow this  
cordel

Two points and a point inside

This topic is 3449 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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) ?

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!