Skip to content

Instantly share code, notes, and snippets.

@aaronsnoswell
Created October 20, 2012 04:17
Show Gist options
  • Save aaronsnoswell/3921992 to your computer and use it in GitHub Desktop.
Save aaronsnoswell/3921992 to your computer and use it in GitHub Desktop.
Fast Unit Vector Normalisation for Discrete Spaces
// Really (really) fast unit vector normalisation
var c = 0.7071067812;
if(v[X] != 0 && v[Y] != 0) {
v[X] *= c, v[Y] *= c;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment