🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Translating mouse movement into angle?

Started by
2 comments, last by scott8 3 years 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?

Advertisement

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.

@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