Nabble has removed Mailing-list integration.
Posts created here DO NOT GET SENT TO THE MAILING LIST.
Mailing-list emails DO NOT GET POSTED TO THE FORUM.
So basically the Forum is now out of date, we are looking into migrating the history.

# 2d cross product

 Classic List Threaded
3 messages
Reply | Threaded
Open this post in threaded view
|

## 2d cross product

 The manual says that cross() is only valid on 3d vectors, but it seems that if you give it 2d input it extends them into 3d vectors in the plane and returns the length of the resulting cross product.   So echo(cross([1,2],[5,6])); echo(cross([1,2,0],[5,6,0])); produces the output: ECHO: -4 ECHO: [0, 0, -4] Is this an intentional behavior that we can rely upon?   -- Sent from: http://forum.openscad.org/_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

## Re: 2d cross product

 As far as I know,  cross([x, y], [u, v]) == [-y, x]*[u, v] == [x,y]*[v,-u] == x*v - y*uIt is the scalar product of the first vector by a 90 degree rotation of the second. It is useful to check collinearity and whether three points in a list is CCW, to compute area and the determinant of a 2D matrix, etc. The 3D cross product can be expressed by three 2D cross products:cross([x,y,z], [u,v,w]) == [ cross([y,z], [v,w]), cross([u,w], [x,z]), cross([x,y], [u,v]) ]As it is not documented in the manual, your question is relevant and I expect the answer to be yes!Em ter., 9 de jun. de 2020 às 19:47, adrianv <[hidden email]> escreveu:The manual says that cross() is only valid on 3d vectors, but it seems that if you give it 2d input it extends them into 3d vectors in the plane and returns the length of the resulting cross product.  So echo(cross([1,2],[5,6])); echo(cross([1,2,0],[5,6,0])); produces the output: ECHO: -4 ECHO: [0, 0, -4] Is this an intentional behavior that we can rely upon?  -- Sent from: http://forum.openscad.org/ _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

## Re: 2d cross product

 No answer. Who is in silence agrees, they say.I have found a reference of a 2D cross product in an OpenSCAD regression test: So, it seems it is not accidental. And, as someone said before, what is in the regression tests is what holds.That said, we can update the manual with the information about 2D cross.Em qua., 10 de jun. de 2020 às 00:12, Ronaldo Persiano <[hidden email]> escreveu:As far as I know,  cross([x, y], [u, v]) == [-y, x]*[u, v] == [x,y]*[v,-u] == x*v - y*uIt is the scalar product of the first vector by a 90 degree rotation of the second. It is useful to check collinearity and whether three points in a list is CCW, to compute area and the determinant of a 2D matrix, etc. The 3D cross product can be expressed by three 2D cross products:cross([x,y,z], [u,v,w]) == [ cross([y,z], [v,w]), cross([u,w], [x,z]), cross([x,y], [u,v]) ]As it is not documented in the manual, your question is relevant and I expect the answer to be yes!Em ter., 9 de jun. de 2020 às 19:47, adrianv <[hidden email]> escreveu:The manual says that cross() is only valid on 3d vectors, but it seems that if you give it 2d input it extends them into 3d vectors in the plane and returns the length of the resulting cross product.  So echo(cross([1,2],[5,6])); echo(cross([1,2,0],[5,6,0])); produces the output: ECHO: -4 ECHO: [0, 0, -4] Is this an intentional behavior that we can rely upon?  -- Sent from: http://forum.openscad.org/ _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org