Sign in to follow this  
rockytriton

is point on line?

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this