Advertisement Jump to content
Sign in to follow this  
rockytriton

is point on line?

This topic is 4982 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
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!