Advertisement

Translating mouse movement into angle?

Started by June 24, 2021 06:00 PM
2 comments, last by scott8 3 years, 5 months ago

Disclaimer: I don't understand math in depth at all. Long story short, I have a means of viewing the angle between two actions. I also have a means of tracking mouse movement accurately along the X axis.

I'm trying to convert this mouse movement into an angle, and it works perfectly, but only at any given mouse sensitivity. I take the angle difference between 2 actions, divide it by number of X moved, and multiply that by any future X movement I do (which I then add to last known angle from when I started tracking). Problem is that it only works for a given mouse sensitivity, the relationship isn't linear. The multiplier I get at max sensitivity, which I then divide by 100 then multiply by sensitivity doesn't give correct results when at lower sensitivity.

These are some example multipliers:

0.00345145677 = 100% mouse sensitivity calculated from angle difference / x movement

0.0019100665343300869 = 50% mouse sensitivity calculated from angle difference / x movement

0.0003928575210289283 = 1% mouse sensitivity calculated from angle difference / x movement

Is there any reason why this is the case? And any way to do anything about it?

I didn't follow all the details of your problem, but you should break down your problem into smaller problems. I would start by defining a notion of X movement that is independent of the sensitivity. Then use that number to do the angle computations.

Advertisement

@AverageMan Is it possible this is due to a rounding error? I am assuming ‘X movement’ is an integer - like the number of pixels the mouse has moved. How is ‘X Movement’ being calculated? Can you post some of your code?

This topic is closed to new replies.

Advertisement