Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Chuck3d

distance between edge and point

This topic is 5427 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

I have a point and a polygone, i want to know if the point is on an edge of the polygone I have experiment many methods but it failled because of the floating point precision (I think). Any Idea? !o)

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Probably float precision. You need to use some small number (1e-6 is good) to make the edges thick. You can''t treat them as infinitely thin.

Plenty of algorithms for this all over in books and stuff have a look for triangles. For general poly''s it is a lot more work.

Share this post


Link to post
Share on other sites
is this for 2D, 3D? do you want to know if the point lies on the surface or only if it lies on one of the straight edges of the polygon?

Share this post


Link to post
Share on other sites
thank u for u answer anonymous P. I don''t understand why my methods failled. I try to look at 2 vectors , one with the edge and the second with the point and a point of the edge, if this two vectors are co-linear ... but it don''t worked

Share this post


Link to post
Share on other sites
ok well... best thing to do is find the closest distance between the point and the line and then if that distance is lower than a certain tolerance, you can assume that the point lies on the line...

Here''s how:

http://astronomy.swin.edu.au/~pbourke/geometry/pointline/

If you wanna know if the point is inside the polygon then you can use solution 4 from here:

http://astronomy.swin.edu.au/~pbourke/geometry/insidepoly/

whenever your doing calculations like this, you always need a tolerance, you can''t assume the computer is gonna store your numbers perfectly and calculate everything 100% accurately.

Share this post


Link to post
Share on other sites
Thank you for your help !

I know I need a tolerance but it vary between two case of one scene !

ok i go read your link!

Thank you again

Share this post


Link to post
Share on other sites
That exactly that I want: a method I never tested !

Is there a light not far ?

(yes ! it's .... the sun )

!o)

[edited by - Chuck3d on November 12, 2003 5:52:17 PM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!