1j01 / tracky-mouse

Mouse control via head tracking, as a cross platform desktop app and JS library. eViacam alternative.
https://trackymouse.js.org/
MIT License
25 stars 4 forks source link

Head tracking circularity: balance diagonal movement with horizontal/vertical movement #46

Open 1j01 opened 2 months ago

1j01 commented 2 months ago

I've found that moving diagonally requires too much head movement compared to horizontal/vertical movement.

Acceleration curves may be playing a role in this. Currently the acceleration curve is applied to deltaX and deltaY independently, with the distance parameter being ignored here:

// Acceleration curves add a lot of stability,
// letting you focus on a specific point without jitter, but still move quickly.

// var accelerate = (delta, distance) => (delta / 10) * (distance ** 0.8);
// var accelerate = (delta, distance) => (delta / 1) * (Math.abs(delta) ** 0.8);
var accelerate = (delta, distance) => (delta / 1) * (Math.abs(delta * 5) ** acceleration);

var distance = Math.hypot(movementX, movementY);
var deltaX = accelerate(movementX * sensitivityX, distance);
var deltaY = accelerate(movementY * sensitivityY, distance);

If you picture the head as a sphere, it makes sense that diagonal movements are weakened, due to the projection, in combination with the acceleration curves. Tilting up, down, left, or right, the projected point is moved in a single axis, whereas tilting diagonally moves sqrt(2)/2 in each axis. When spread across two axes, with the acceleration curves applying separately, the exponentiation isn't as high. That said, there may be a reason why I didn't use the distance parameter here; maybe it even makes it worse somehow.

I might need a separate sort of filter to compensate for diagonal movement feeling subdued, reminiscent of the pin-cushion adjustment on old CRT monitors.

Related: