discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

rotation around a particular point?

MH
Mark Harrison
Thu, Aug 17, 2017 12:19 AM

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
marhar@gmail.com

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 marhar@gmail.com
F
fred
Thu, Aug 17, 2017 12:26 AM

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 marhar@gmail.com wrote:

I'm not understanding the docs on rotate() and the rotation vector.
Could somebody show me how this rotation could be made aroundthe 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
marhar@gmail.com_______________________________________________
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

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 <marhar@gmail.com> wrote: I'm not understanding the docs on rotate() and the rotation vector. Could somebody show me how this rotation could be made aroundthe 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 marhar@gmail.com_______________________________________________ OpenSCAD mailing list Discuss@lists.openscad.org http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
A
arnholm@arnholm.org
Thu, Aug 17, 2017 7:17 AM

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

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
HL
Hans L
Thu, Aug 17, 2017 6:54 PM

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,  arnholm@arnholm.org 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.

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, <arnholm@arnholm.org> 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.