Point on a line
-
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? Thanks -- Rocky Dean Pulley
-
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? Thanks -- Rocky Dean Pulley
I used this article to hit test a line: Win32: Hit Testing Lines and Curves
:suss: Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
-
I used this article to hit test a line: Win32: Hit Testing Lines and Curves
:suss: Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
thanks a lot -- Rocky Dean Pulley
-
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? Thanks -- Rocky Dean Pulley
I did this c. 30 years ago using Fortran, but I can't remember how we did it! and I still have the source code! The last time I did it I cheated and use PtInRect, I assume the mouse could be X pixels away from the line? If so then just create a bounding rectange and check if the mouse position is within the rectangle or if it must be on the line just make a 1 pixel rectangle. You will need to 'cheat' slightly the docs state "A point on the right or bottom side is considered outside the rectangle." so make the rectangle 1 pixel too big on these axis.
"An education isn't how much you have committed to memory, or even how much you know. It's being able to differentiate between what you do know and what you don't." - Anatole France
-
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? Thanks -- Rocky Dean Pulley
If the line is curved, you need to know the rate of curve. otherwise, it's basic trigonometry. Christian Graus - Microsoft MVP - C++