Last active
February 13, 2017 03:14
-
-
Save psiphi75/c15ea137468590f1b0f511c253bf58af to your computer and use it in GitHub Desktop.
The vector.dot function - it's simple right!?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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