discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Rotate about user defined axis ?

R
Robin2
Wed, Oct 30, 2019 8:49 PM

This simple piece of code rotates the cube about what I will call its
left-hand end.

rotate(45, [0, 1, 0]) {
cube( [20,5,1]);
}

I can't figure whether there is a way to get it to rotate about (for
example) its right-hand end?

...R

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

This simple piece of code rotates the cube about what I will call its left-hand end. rotate(45, [0, 1, 0]) { cube( [20,5,1]); } I can't figure whether there is a way to get it to rotate about (for example) its right-hand end? ...R -- Sent from: http://forum.openscad.org/
MM
Matt Maggio
Wed, Oct 30, 2019 9:38 PM

I could be wrong about any/all of this, but if you want to rotate around a
non origin axis, I would stay you should translate the object away from the
origin and then rotate as normal. The effect this has is equal to what you
want and gives you complete control. With 6 degrees of freedom (trans x y
z, rot xy,yz, zx) you should be able to accomplish any possible 3D affine
transformation.

Now using this strategy to make good designs can be tricky, and depending
on exactly what you want might be the wrong approach. Say you want a bolt
hole pattern, but you need the holes to be square (if they were cylindrical
the rotation wouldn't matter)  then you would need to rotate them around an
axis outside of their shape. wrap this in a for loop to make say 10 holes a
fixed radius from the origin.

radius =5;
for(i=[0:10]){
rotate([0,0,i*(360/10)]){
translate([radius, 0,0]){
cube([1,1,1]);
}}}

As an experiment, what happens if you switch the rotate and translate
statements order? Then they evaluate in the opposite way and you should be
left with a star shape.

On Wed, Oct 30, 2019 at 3:38 PM Robin2 robin@nbleopard.com wrote:

This simple piece of code rotates the cube about what I will call its
left-hand end.

rotate(45, [0, 1, 0]) {
cube( [20,5,1]);
}

I can't figure whether there is a way to get it to rotate about (for
example) its right-hand end?

...R

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


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

--
Matt Maggio
Senior Research Technologist
Resuscitation Institute (Rm. 1.380)
Department of Medicine
Rosalind Franklin University of Medicine and Science
3333, Green Bay Rd, North Chicago, IL - 60064.
Office: 224-570-7954
Cell: 815-703-2879
"Take chances, make mistakes, and get messy!!" - Mrs. Frizzle, PhD

I could be wrong about any/all of this, but if you want to rotate around a non origin axis, I would stay you should translate the object away from the origin and then rotate as normal. The effect this has is equal to what you want and gives you complete control. With 6 degrees of freedom (trans x y z, rot xy,yz, zx) you should be able to accomplish any possible 3D affine transformation. Now using this strategy to make good designs can be tricky, and depending on exactly what you want might be the wrong approach. Say you want a bolt hole pattern, but you need the holes to be square (if they were cylindrical the rotation wouldn't matter) then you would need to rotate them around an axis outside of their shape. wrap this in a for loop to make say 10 holes a fixed radius from the origin. radius =5; for(i=[0:10]){ rotate([0,0,i*(360/10)]){ translate([radius, 0,0]){ cube([1,1,1]); }}} As an experiment, what happens if you switch the rotate and translate statements order? Then they evaluate in the opposite way and you should be left with a star shape. On Wed, Oct 30, 2019 at 3:38 PM Robin2 <robin@nbleopard.com> wrote: > This simple piece of code rotates the cube about what I will call its > left-hand end. > > rotate(45, [0, 1, 0]) { > cube( [20,5,1]); > } > > I can't figure whether there is a way to get it to rotate about (for > example) its right-hand end? > > ...R > > > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > -- Matt Maggio Senior Research Technologist Resuscitation Institute (Rm. 1.380) Department of Medicine Rosalind Franklin University of Medicine and Science 3333, Green Bay Rd, North Chicago, IL - 60064. Office: 224-570-7954 Cell: 815-703-2879 "Take chances, make mistakes, and get messy!!" - Mrs. Frizzle, PhD
R
Robin2
Wed, Oct 30, 2019 10:54 PM

mmaggio wrote

I could be wrong about any/all of this, but if you want to rotate around a
non origin axis, I would stay you should translate the object away from
the
origin and then rotate as normal.

Thanks.

I'm aware that I can do that. My question is whether it is possible just
using the rotate() command - in other words, maybe I have missed a feature
of the rotate() command.

...R

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

mmaggio wrote > I could be wrong about any/all of this, but if you want to rotate around a > non origin axis, I would stay you should translate the object away from > the > origin and then rotate as normal. Thanks. I'm aware that I can do that. My question is whether it is possible just using the rotate() command - in other words, maybe I have missed a feature of the rotate() command. ...R -- Sent from: http://forum.openscad.org/
A
adrianv
Thu, Oct 31, 2019 9:59 PM
-- Sent from: http://forum.openscad.org/
HL
Hans L
Fri, Nov 1, 2019 8:07 AM

The builtin rotate module can rotate about any vector which goes
through the origin.  If you want to pivot around something not on the
origin, then you'll have to do additional translations.

Here is a "one-liner" module to do it for you.  just specify the pivot point p.

module rotate_about(a, v, p=[0,0,0]) {
translate(p) rotate(a,v) translate(-p) children();
}

-Hans

On Thu, Oct 31, 2019 at 4:48 PM adrianv avm4@cornell.edu wrote:

The builtin rotate module can rotate about any vector which goes through the origin. If you want to pivot around something not on the origin, then you'll have to do additional translations. Here is a "one-liner" module to do it for you. just specify the pivot point p. module rotate_about(a, v, p=[0,0,0]) { translate(p) rotate(a,v) translate(-p) children(); } -Hans On Thu, Oct 31, 2019 at 4:48 PM adrianv <avm4@cornell.edu> wrote: > > > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
R
Robin2
Fri, Nov 1, 2019 8:28 AM

thehans wrote

The builtin rotate module can rotate about any vector which goes
through the origin.

Thanks. That's how it had seemed to me. I had been hoping I was missing
something because for the use-case I have in mind it would be very
inconvenient to use a translate()

It will be easier to make a roughly equivalent 2D drawing in LibreOffice and
experiment with the motion in it.

...R

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

thehans wrote > The builtin rotate module can rotate about any vector which goes > through the origin. Thanks. That's how it had seemed to me. I had been hoping I was missing something because for the use-case I have in mind it would be very inconvenient to use a translate() It will be easier to make a roughly equivalent 2D drawing in LibreOffice and experiment with the motion in it. ...R -- Sent from: http://forum.openscad.org/
DG
David Gustavson
Fri, Nov 1, 2019 10:39 AM

Geogebra.org is a very useful tool for trying motions.
I once used it to determine how a string length varied going around multiple pulleys in a joined arm, as the arm moved.
Dave

--
David Gustavson
dbg@SCIzzL.com

On Fri, Nov 1, 2019, at 9:28 AM, Robin2 wrote:

thehans wrote

The builtin rotate module can rotate about any vector which goes
through the origin.

Thanks. That's how it had seemed to me. I had been hoping I was missing
something because for the use-case I have in mind it would be very
inconvenient to use a translate()

It will be easier to make a roughly equivalent 2D drawing in LibreOffice and
experiment with the motion in it.

...R

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


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Geogebra.org is a very useful tool for trying motions. I once used it to determine how a string length varied going around multiple pulleys in a joined arm, as the arm moved. Dave -- David Gustavson dbg@SCIzzL.com On Fri, Nov 1, 2019, at 9:28 AM, Robin2 wrote: > thehans wrote > > The builtin rotate module can rotate about any vector which goes > > through the origin. > > Thanks. That's how it had seemed to me. I had been hoping I was missing > something because for the use-case I have in mind it would be very > inconvenient to use a translate() > > It will be easier to make a roughly equivalent 2D drawing in LibreOffice and > experiment with the motion in it. > > ...R > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
L
lar3ry
Sat, Nov 2, 2019 5:30 PM
the dotSCAD 2.0 library (see http://forum.openscad.org/dotSCAD-2-0-RELEASE-tt26893.html#a27518 <http://forum.openscad.org/dotSCAD-2-0-RELEASE-tt26893.html#a27518> ) has a rotate_p that might help. See https://openhome.cc/eGossip/OpenSCAD/lib-rotate_p.html <https://openhome.cc/eGossip/OpenSCAD/lib-rotate_p.html> , which is linked to by a page that discusses openSCAD and dotSCAD 2.0. See https://openhome.cc/eGossip/OpenSCAD/index.html <https://openhome.cc/eGossip/OpenSCAD/index.html> -- Sent from: http://forum.openscad.org/
R
Robin2
Sat, Nov 2, 2019 9:20 PM

lar3ry wrote

the dotSCAD 2.0 library (see
...........

Many thanks but the need is not sufficient to justify that much effort :)

...R

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

lar3ry wrote > the dotSCAD 2.0 library (see > ........... Many thanks but the need is not sufficient to justify that much effort :) ...R -- Sent from: http://forum.openscad.org/