It seems that for some reason Excel programmers chose to omit any vector cross-product functionality.
Furthermore, looking online, there isn't really much demand for it. Although excel is a powerful tool to do linear algebra.
I need a VBA script to do Vector Cross Products. And the only one I could find was from here:
EDIT:
--------------------
Function vCP(v1 As Variant, v2 As Variant) As Variant
vCP = Array(v1(2) * v2(3) - v1(3) * v2(2), _
v1(3) * v2(1) - v1(1) * v2(3), _
v1(1) * v2(2) - v1(2) * v2(1))
End Function
--------------------
Using it is simple,
=vCP(
,
)
I did a couple tests on it, and it works, but it outputs a horizontal vector, not vertical, the way it's preferred for Linear Algebra.
Does anyone know how to change this script so the 3D vectors can be output vertically instead?
Is there a better way to get a cross product in Excel?
Thanks, -D
Use Application.Transpose:
Function vCP(v1 As Variant, v2 As Variant) As Variant
vCP = Application.Transpose(Array(v1(2) * v2(3) - v1(3) * v2(2), _
v1(3) * v2(1) - v1(1) * v2(3), _
v1(1) * v2(2) - v1(2) * v2(1)))
End Function