.NET Ascertaining mouse is on line drawn between two arbitrary points

Posted by johnc on Stack Overflow See other posts from Stack Overflow or by johnc
Published on 2010-03-19T20:14:54Z Indexed on 2010/03/19 20:31 UTC
Read the original article Hit count: 227

Filed under:
|
|

I have an arrow drawn between two objects on a Winform.

What would be the simplest way to determine that my mouse is currently hovering over, or near, this line.

I have considered testing whether the mouse point intersects a square defined and extrapolated by the two points, however this would only be feasible if the two points had very similar x or y values.

I am thinking, also, this problem is probably more in the realms of linear algebra rather than simple trigonometry, and whilst I do remember the simpler aspects of matrices, this problem is beyond my knowledge of linear algebra.

On the other hand, if a .NET library can cope with the function, even better.

© Stack Overflow or respective owner

Related posts about .NET

Related posts about geometry