20
3
The cross product of two three-dimensional vectors \$\vec a\$ and \$\vec b\$ is the unique vector \$\vec c\$ such that:
\$\vec c\$ is orthogonal to both \$\vec a\$ and \$\vec b\$
The magnitude of \$\vec c\$ is equal to the area of the parallelogram formed by \$\vec a\$ and \$\vec b\$
The directions of \$\vec a\$, \$\vec b\$, and \$\vec c\$, in that order, follow the right-hand rule.
There are a few equivalent formulas for cross product, but one is as follows:
$$\vec a\times\vec b=\det\begin{bmatrix}\vec i&\vec j&\vec k\\a_1&a_2&a_3\\b_1&b_2&b_3\end{bmatrix}$$
where \$\vec i\$, \$\vec j\$, and \$\vec k\$ are the unit vectors in the first, second, and third dimensions.
Challenge
Given two 3D vectors, write a full program or function to find their cross product. Builtins that specifically calculate the cross product are disallowed.
Input
Two arrays of three real numbers each. If your language doesn't have arrays, the numbers still must be grouped into threes. Both vectors will have magnitude \$<2^{16}\$. Note that the cross product is noncommutative (\$\vec a\times\vec b=-\bigl(\vec b\times\vec a\bigr)\$), so you should have a way to specify order.
Output
Their cross product, in a reasonable format, with each component accurate to four significant figures or \$10^{-4}\$, whichever is looser. Scientific notation is optional.
Test cases
[3, 1, 4], [1, 5, 9]
[-11, -23, 14]
[5, 0, -3], [-3, -2, -8]
[-6, 49, -10]
[0.95972, 0.25833, 0.22140],[0.93507, -0.80917, -0.99177]
[-0.077054, 1.158846, -1.018133]
[1024.28, -2316.39, 2567.14], [-2290.77, 1941.87, 712.09]
[-6.6345e+06, -6.6101e+06, -3.3173e+06]
This is code-golf, so the shortest solution in bytes wins.
Maltysen posted a similar challenge, but the response was poor and the question wasn't edited.
Can the input be taken as a 2D array? – Dennis – 2016-01-30T03:03:45.287
Yes, as long as 2 is the outer dimension. – lirtosiast – 2016-01-30T03:04:57.563