• Advertisement
Sign in to follow this  

is point on line?

This topic is 4655 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'm trying to find out if my mouse position is on a specific line. I've tried using the slopes of the line and of the mouse position from the starting point but this doesn't work because when you get close to the starting point and the line is almost horizontal the slopes vary greatly. Has anyone done this sort of thing before? (I'm using C# btw) Thanks, - Rocky

Share this post


Link to post
Share on other sites
Advertisement
Due to the limits of floating-point precision a point will rarely be exactly on a line, so what you will usually want to do is check to see if the point is within some distance of the line. If the distance is small enough, you consider the point to be on the line. See this thread for a discussion of point-to-line-segment distance methods.

Share this post


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

  • Advertisement