Skip to content

Instantly share code, notes, and snippets.

@psiphi75
Last active February 13, 2017 03:14
Show Gist options
  • Save psiphi75/c15ea137468590f1b0f511c253bf58af to your computer and use it in GitHub Desktop.
Save psiphi75/c15ea137468590f1b0f511c253bf58af to your computer and use it in GitHub Desktop.
The vector.dot function - it's simple right!?
var vector = {
make: function (x, y, z) {
if (x instanceof Array) {
return [x[0], x[1], x[2]];
} else {
return [x, y, z];
}
},
dot: function (v, w) {
return (v[0] * w[0] + v[1] * w[1] + v[2] * w[2]);
},
// ... more vector functions
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment