Iloczyn dwóch wektorów trójwymiarowych i jest unikalny wektor takie, że:
jest ortogonalny zarówno do i
Wielkość jest równa powierzchni równoległoboku utworzonego przez i
Kierunki , → b i → c , w tej kolejności, przestrzegaj zasady prawej ręki .
Istnieje kilka równoważnych wzorów dla produktu krzyżowego, ale jeden z nich jest następujący:
where , , and 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 . Note that the cross product is noncommutative (), 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 , 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.