Skip to content

Instantly share code, notes, and snippets.

@dannygarcia
Created February 9, 2012 18:32
Show Gist options
  • Save dannygarcia/1781857 to your computer and use it in GitHub Desktop.
Save dannygarcia/1781857 to your computer and use it in GitHub Desktop.
Normalizing Mouse Coordinates

Normalizing Input Coordinates

Constants

x = Input X or Y Position
w = Context X or Y Width

Left-to-right

 0 ==========0.5========== +1
n = x / w

From-center

-1 ========== 0 ========== +1
n = (x / w) * 2 - 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment