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
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
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
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.