rotation around a particular point?

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

rotation around a particular point?

marhar
I'm not understanding the docs on rotate() and the rotation vector.

Could somebody show me how this rotation could be made around
the center of the cube?  i.e. so it would generate an 8-point star,
where the two cubes would have the same center (x,y) point?

cube([10,10,1]);
rotate(45) cube([10,10,1]);


--
Mark Harrison
[hidden email]

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

Re: rotation around a particular point?

fred_dot_u
Even though I'm no wizard at OpenSCAD, this one was an easy one, using the for-loop feature:

for (spin = [0 : 45 : 360])
    rotate(spin)
    cube([10,10,1]);



On Wednesday, August 16, 2017, 8:20:47 PM EDT, Mark Harrison <[hidden email]> wrote:


I'm not understanding the docs on rotate() and the rotation vector.

Could somebody show me how this rotation could be made around
the center of the cube?  i.e. so it would generate an 8-point star,
where the two cubes would have the same center (x,y) point?

cube([10,10,1]);
rotate(45) cube([10,10,1]);


--
Mark Harrison
[hidden email]
_______________________________________________
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: rotation around a particular point?

cacb
In reply to this post by marhar
On 2017-08-17 02:19, Mark Harrison wrote:
> I'm not understanding the docs on rotate() and the rotation vector.
>
> Could somebody show me how this rotation could be made around
> the center of the cube?  i.e. so it would generate an 8-point star,
> where the two cubes would have the same center (x,y) point?
>
> cube([10,10,1]);
> rotate(45) cube([10,10,1]);

Rotations are always around the origin of your coordinate system, but
your cubes are not at the origin. The easiest answer in this case is

cube([10,10,1],center=true);
rotate(45) cube([10,10,1],center=true);

But a more general answer that will generate the 8-point star at the
center of the first cube would be:

cube([10,10,1]);
translate([5,5,0])
    rotate(45)
       translate([-5,-5,0])
          cube([10,10,1]);

Basically, the idea is to move the second cube center to the origin,
rotate that cube, then move it back to the original location.

Carsten Arnholm

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

Re: rotation around a particular point?

thehans
You could also write your own custom rotate module to do the
translation back and forth for you

here is as a one-liner that should work:
module rotate_about_pt(a, v, pt) translate(pt) rotate(a,v)
translate(-pt) children();

On Thu, Aug 17, 2017 at 2:17 AM,  <[hidden email]> wrote:

> ...
> But a more general answer that will generate the 8-point star at the center
> of the first cube would be:
>
> cube([10,10,1]);
> translate([5,5,0])
>    rotate(45)
>       translate([-5,-5,0])
>          cube([10,10,1]);
>
> Basically, the idea is to move the second cube center to the origin, rotate
> that cube, then move it back to the original location.

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