You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Daniel Flassig edited this page Jul 17, 2026
·
1 revision
Cross product of two 3-vectors.
w=pymath.cross(u, v)
Parameter
Type
Description
u
{x, y, z}
Left vector
v
{x, y, z}
Right vector
Return value
Type
Description
w
A new 3-vector u × v, perpendicular to both u and v.
Notes:
Both arguments must be 3-vectors (arrays of length 3) — the cross product is only provided in three dimensions.
u and v are not modified.
The orientation follows the right-hand rule: pymath.cross({1,0,0}, {0,1,0}) == {0,0,1}.
The length of w equals the area of the parallelogram spanned by u and v; for parallel inputs the result is {0, 0, 0} (which pymath.normalize then rejects with nil).
Example:
localn=pymath.cross({1, 0, 0}, {0, 1, 0})
-- n == {0, 0, 1}-- normal of the triangle (p1, p2, p3)localu= {p2[1] -p1[1], p2[2] -p1[2], p2[3] -p1[3]}
localv= {p3[1] -p1[1], p3[2] -p1[2], p3[3] -p1[3]}
localnormal=pymath.normalize(pymath.cross(u, v))