Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Point on a line

Point on a line

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rocky_pulley
    wrote on last edited by
    #1

    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

    J T C 3 Replies Last reply
    0
    • R rocky_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

      J Offline
      J Offline
      Jack Puppy
      wrote on last edited by
      #2

      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!

      R 1 Reply Last reply
      0
      • J Jack Puppy

        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!

        R Offline
        R Offline
        rocky_pulley
        wrote on last edited by
        #3

        thanks a lot -- Rocky Dean Pulley

        1 Reply Last reply
        0
        • R rocky_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

          T Offline
          T Offline
          Ted Ferenc
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          • R rocky_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

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            If the line is curved, you need to know the rate of curve. otherwise, it's basic trigonometry. Christian Graus - Microsoft MVP - C++

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups