Created
April 7, 2019 05:16
-
-
Save singularitti/847a79f4d9e64915f74a46707c42cb43 to your computer and use it in GitHub Desktop.
Compute cross product of 2 3D arrays #JavaScript #math #array
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
function crossProduct(arr1, arr2) { | |
/* | |
Here arr1, arr2 are both 1D arrays. | |
*/ | |
let u1 = arr1[0]; | |
let u2 = arr1[1]; | |
let u3 = arr1[2]; | |
let v1 = arr2[0]; | |
let v2 = arr2[1]; | |
let v3 = arr2[2]; | |
return [u2 * v3 - u3 * v2, u3 * v1 - u1 * v3, u1 * v2 - u2 * v1]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment