New coordinates after rotation and translation

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

New coordinates after rotation and translation

Maurice van Peursem
Hi,

Is there an easy way to get the new coordinates of a point after a
few rotations and translations?

Thanks,
Maurice

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: New coordinates after rotation and translation

nophead
No, not without trig and matrix multiplication. But you can always make a module that represents the translations and rotations and apply it to multiple children(). For example to place screws in a bracket that itself has a complicated position.

On Mon, 7 Jan 2019 at 17:43, Maurice van Peursem <[hidden email]> wrote:
Hi,

Is there an easy way to get the new coordinates of a point after a
few rotations and translations?

Thanks,
Maurice

_______________________________________________
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: New coordinates after rotation and translation

JordanBrown
In reply to this post by Maurice van Peursem
On 1/7/2019 9:42 AM, Maurice van Peursem wrote:
Is there an easy way to get the new coordinates of a point after a few rotations and translations?


Simple answer:  No.

More complex answer:  You can generate the matrices yourself and multiply them out.

The documentation for multmatrix() is helpful in generating the matrices: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Transformations#multmatrix

The Wikipedia article is pretty technical but looks to have a good set of patterns:  https://en.wikipedia.org/wiki/Transformation_matrix

Capsule summary:  Every transformation is equivalent to a particular 4x4 matrix.  Multiplying the point by the transformation matrix yields the transformed point.  Multiplying several transformation matrices together yields a transformation matrix that represents all of the transformations.  OpenSCAD does matrix multiplication natively; you can just say "p*tm" where p is a point as an [x,y,z] vector and tm is a transformation matrix, and OpenSCAD will do the right thing and yield a new point.



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: New coordinates after rotation and translation

runsun
In reply to this post by Maurice van Peursem
Ready codes for lazy guys:

https://github.com/runsun/OpenSCAD_Tips/blob/master/snippets.md#rotate_anydir
https://github.com/runsun/OpenSCAD_Tips/blob/master/snippets.md#rotate_anyaxis




-----

$  Runsun Pan, PhD $ libs: scadx , doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), editor of choice: CudaText  ( OpenSCAD lexer );&nbsp;$ Tips ;&nbsp;$ Snippets

--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
$ Runsun Pan, PhD
$ libs: scadx, doctest, faces(git), offline doc(git), runscad.py(2,git), editor of choice: CudaText ( OpenSCAD lexer); $ Tips; $ Snippets