Rotate about user defined axis ?

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

Rotate about user defined axis ?

Robin2
This post was updated on .
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 just using a variant of the rotate() command ?

...R





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

_______________________________________________
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Rotate about user defined axis ?

mmaggio
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 <[hidden email]> 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
[hidden email]
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

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

Re: Rotate about user defined axis ?

Robin2
This post was updated on .
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.

I have designed something with two parts, one rotates loosely within the other. It would be nice to be able to rotate the part around its pivot just to get an idea of whether the "arms" touch where they should not.

...R



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

_______________________________________________
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Rotate about user defined axis ?

adrianv




--
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: Rotate about user defined axis ?

thehans
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 <[hidden email]> wrote:

>
>
>
>
>
> --
> 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: Rotate about user defined axis ?

Robin2
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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Rotate about user defined axis ?

David B. Gustavson
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



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
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: Rotate about user defined axis ?

lar3ry
In reply to this post by Robin2
Reply | Threaded
Open this post in threaded view
|

Re: Rotate about user defined axis ?

Robin2
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/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org