def derived_loft(): w1 = cm.wire([cm.circle(1.0)]) w2 = cm.wire([cm.circle(2.0)]) w2.translate((0.0, 0.0, 5.0)) w3 = cm.wire([cm.circle(1.5)]) w3.translate((0.0, 0.0, 10.0)) s1 = cm.loft([w1, w2, w3]) save_iso(s1, 'derived_loft.png')
def test_loft(self): w1 = cm.Wire([cm.circle(1.0)]) w2 = cm.Wire([cm.circle(2.0)]) w2.translate((0.0, 0.0, 5.0)) w3 = cm.Wire([cm.circle(1.5)]) w3.translate((0.0, 0.0, 10.0)) s1 = cm.loft([w1, w2, w3]) # empirical self.assert_(close(98.407, s1.volume(), 0.001))
def test_loft(self): w1 = cm.wire([cm.circle(1.0)]) w2 = cm.wire([cm.circle(2.0)]) w2.translate((0.0, 0.0, 5.0)) w3 = cm.wire([cm.circle(1.5)]) w3.translate((0.0, 0.0, 10.0)) s1 = cm.loft([w1, w2, w3]) # empirical self.assert_(close(98.407, s1.volume(), 0.001))
def solidbrick(xsize, ysize, wall_offset, unit, height, draft, knob_rad, knob_height, knob_draft, save_images=0): dx = height * math.tan(math.radians(draft)) wbottom = cm.rectangle(unit * xsize - 2 * wall_offset, unit * ysize - 2 * wall_offset) wtop = cm.rectangle(unit * xsize - 2 * dx - 2 * wall_offset, unit * ysize - 2 * dx - 2 * wall_offset) wtop.translate((dx, dx, height)) brick = cm.loft([wbottom, wtop], True) brick.translate((wall_offset, wall_offset, 0.0)) if save_images: v.display(brick) v.fit() v.save('example1_box.png') drad = knob_height * math.tan(math.radians(knob_draft)) knob_top_rad = knob_rad - drad knob_base_rad = knob_rad + drad knob = cm.cone(knob_base_rad, knob_top_rad, 2 * knob_height) knob.translate((0.5 * unit, 0.5 * unit, height - knob_height)) if save_images: v.display(knob, color=(1.0, 0.0, 0.0)) v.fit() v.save('example1_boxwknob.png') for x in range(xsize): for y in range(ysize): brick = brick + cm.translated(knob, (x * unit, y * unit, 0.0)) if save_images: v.clear() v.display(brick) v.save('example1_boxwknobs.png') return brick
def solidbrick(xsize, ysize, wall_offset, unit, height, draft, knob_rad, knob_height, knob_draft): dx = height * math.tan(math.radians(draft)) wbottom = cm.rectangle(unit * xsize - 2 * wall_offset, unit * ysize - 2 * wall_offset) wtop = cm.rectangle(unit * xsize - 2 * dx - 2 * wall_offset, unit * ysize - 2 * dx - 2 * wall_offset) wtop.translate((dx, dx, height)) brick = cm.loft([wbottom, wtop], True) brick.translate((wall_offset, wall_offset, 0.0)) drad = knob_height * math.tan(math.radians(knob_draft)) knob_top_rad = knob_rad - drad knob_base_rad = knob_rad + drad knob = cm.cone(knob_base_rad, knob_top_rad, 2 * knob_height) knob.translate((0.5 * unit, 0.5 * unit, height - knob_height)) for x in range(xsize): for y in range(ysize): brick = brick + cm.translated(knob, (x * unit, y * unit, 0.0)) return brick