[OpenSCAD] rotating an object around its center....

caterpillar caterpillar at openhome.cc
Fri Jul 19 23:56:30 EDT 2019


If you module has a center, define it directly. It would more convenient when
rotating and translating. 

module prism(l, w, h, center = false){
  p = center ? [-l / 2, -w / 2, 0] : [0, 0, 0];
  translate(p)
      polyhedron(
          points=[[0,0,0], [l,0,0], [l,w,0], [0,w,0], [0,w,h], [l,w,h]],
          faces=[[0,1,2,3],[5,4,3,2],[0,4,5,1],[0,3,4],[5,2,1]]
      );
}

l = 16;
w = 3;
h = 40;

// This might be what you want.
translate([0,0,8]) 
  rotate([5,0,0])
      translate([0,0,-8]) {
            rotate([180,-90,0])
            translate([1.6, -3.15, 0])
            prism(l, w, h);
      }
      
// Rotate first and translate to where you want
translate([0, -w / 2 + 3.15, l / 2 + 1.6])      
    rotate([5, 0, 0]) 
        rotate([180, -90, 0]) 
            prism(16, 3, 40, center = true);



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



More information about the Discuss mailing list