distance between edge and point

Started by
6 comments, last by Chuck3d 20 years, 5 months ago
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)
!o)
Advertisement
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.

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?
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
!o)
3D , its in 3D.

[edited by - Chuck3d on November 12, 2003 3:47:50 PM]
!o)
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.
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
!o)
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]
!o)

This topic is closed to new replies.

Advertisement