#### Archived

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

# distance between edge and point

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

## 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 on other sites
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 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 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 on other sites
3D , its in 3D.

[edited by - Chuck3d on November 12, 2003 3:47:50 PM]

##### 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 on other sites
Thank you for your help !

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

Thank you again

##### 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]

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5
• ### Forum Statistics

• Total Topics
633709
• Total Posts
3013478
×