Measure distance using mouse

edited March 2016 in How To...

Let me add some details in my question to elaborate what I am asking for - The idea is to measure the vertical and horizontal distance traveled by the mouse without the screen size limitation. I have a wireless mouse which can move freely in any direction within 10-15 feet range. I want to use this advantage to measure any distance. I know I can map the maximum range of my mouse on my screen and can do that but I don't even want range of the mouse to be the constraint while measuring the distance. Do I need raw mouse data to do this?

Edit: Example - : What I am trying to do is measure the real world distance using mouse. Let say I have to measure the dimension of a table then I would just move my mouse on the table and it will register the dimension. :) :)

Few points to conclude the question

  1. Can we use mouse to measure the distance?

  2. Can we do it without modifying the mouse?

  3. Since mouse cursor can't move beyond the screen it is difficult to measure the x,y coordinate, Isn't it?

  4. Mapping the real world distance to screen is one solution but I don't want to that because it constraints it ability to measure the distance.

  5. Can we move the mouse beyond the screen?

  6. If we can, can we get the mouseX or mouseY location ?

Tagged:

Answers

  • edited March 2016

    1/2. Take a look at the wikipedia page on optical mice to learn how the mouse work and it'll probably give you some insight.

    3/5. But whatif there is no curser? Like in first person games where you can spin around more than 360 degrees without hitting the edge of the screen. But how do we access that data? Idk, maybe try googling "first person game java"?

    4/6. ?? Yes? If we can, we can... https://processing.org/reference/mouseX.html

  • https://processing.org/reference/dist_.html

    Dist can measure between to different points or objects, it will print the distance in pixels, after that you just need to ad a function to convert those values to metres or millimeters .

  • It is easy to calculate distance that the cursor had travelled, as you can see. However, you want the distance that comes from mouse itself, I don't know how mouse communicates with computer or how to get this data stream, but you need raw mouse data (that I think depends on mouse sensor resolution). I', pretty sure, there should be a way.

  • @Eeyorelife @bottled_ant and @Ater thanks for the replies :) :) really appreciated and I am really sorry I wasn't clear about my idea. What I am trying to do is measure the real world distance using mouse. Let say I have to measure the dimension of a table then I would just move my mouse on the table and it will register the dimension. :) :) The idea is simple but I couldn't find any simple method

  • As I said, you need to access mouse data on a lower level then mapped cursor position. Have no idea about how to do it, but check out the link: http://www.epanorama.net/documents/pc/mouse.html

  • But you would first have to know how the mouse works, how is the mouse calculating distance? According to wikipedia an optical mouse takes 100 pictures per second and measures the offset of the pictures, then translates that to pixels before sending the result to the computer. How accurate the mouse is depends on the quality of the camera in the mouse and perhaps even how fast you're moving the mouse. And of course the accuracy of the software that is calculating the distance based on the pictures.

    If you move your mouse very fast for a short distance, the cursor flies over the screen, while the same distance with very slow speed will only move the cursor a little bit. Why is that? is that the mouse being inaccurate or is it the computer translating the data from the mouse?

    It's a simple question, but I don't know if there is a simple and accurate answer. You might end up with a program that only works if you move you mouse on a certain type of surface while moving the mouse at a constant speed. That sounds tedious and not simple...

    I have never done anything like this, so it could be simple, but you have to do some research and try some stuff out. the distance moved on-screen compared to irl could be more accurate than you think.

Sign In or Register to comment.