def lighthouse(height=10, r=1.5): mat = random.choice([ddd.mats.metal_paint_green, ddd.mats.metal_paint_red]) disc = ddd.point([0, 0]).buffer(r, resolution=3, cap_style=ddd.CAP_ROUND) obj = disc.extrude_step(disc, height * 0.3) obj = obj.extrude_step(disc.scale(0.7), height * 0.5) obj = obj.extrude_step(disc.scale(1.0), height * 0.18) obj = obj.extrude_step(disc.scale(1.2), height * 0.02) obj = obj.material(mat) obj = ddd.uv.map_cylindrical(obj) obj.name = "Lighthouse" lamp = lamp_ball(r=0.2).material(mat) lamp = ddd.uv.map_spherical(lamp) top = post(top=lamp, mat_post=ddd.mats.steel).translate([0, 0, height]) rail = disc.scale(1.2).extrude_step(disc.scale(1.2), 1.0, base=False, cap=False) #.twosided() rail = rail.translate([0, 0, height]).material(ddd.mats.railing) rail = ddd.uv.map_cylindrical(rail) obj = ddd.group([obj, top, rail], name="Lighthouse Small") return obj
def tennis_net(width, net_height_center=0.914, net_height_post=1.07): """ Tennis net, on XY along the Y axis (since playground fields are seen x: length, y: width). """ post1 = urban.post(net_height_post + 0.15).translate( [0, -width * 0.5, 0]).material(ddd.mats.steel) post2 = urban.post(net_height_post + 0.15).translate( [0, +width * 0.5, 0]).material(ddd.mats.steel) net = ddd.polygon( [[-width * 0.5, 0], [width * 0.5, 0], [width * 0.5, net_height_post], [0, net_height_center], [-width * 0.5, net_height_post]], name="Tennis net") net = net.triangulate(twosided=True).material(ddd.mats.fence) net = net.rotate(ddd.ROT_FLOOR_TO_FRONT).rotate(ddd.ROT_TOP_CCW) net = ddd.uv.map_cubic(net) item = ddd.group3([post1, post2, net]) return item
def pipeline_start(pipeline, root): """ Draws several catenary cables. """ items = ddd.group3(name="Catenary test") length_ratio_factor = pipeline.data.get( 'ddd:example:catenary:length_ratio_factor', 0.025) pipeline.data[ 'ddd:example:catenary:length_ratio_factor'] = length_ratio_factor post_a = post(6) items.append(post_a) pa = [0, 0, 6] for i in range(12): d = 80 # 2 * i h = i a = math.pi * 2 / 12 * i pd = d / 12 * (i + 1) pb = [math.cos(a) * pd, math.sin(a) * pd, h] obj = catenary_cable(pa, pb, length_ratio=1 + (length_ratio_factor / (d / 10))) #obj.show() items.append(obj) post_b = post(h + 0.1, r=0.2) post_b = post_b.rotate(ddd.VECTOR_UP * a) post_b = post_b.translate([pb[0], pb[1], 0]) items.append(post_b) # All items #items = ddd.align.grid(items, space=10.0) items.append(ddd.helper.all()) items.show() root.append(items)
def golf_flag(pole_height=2.1336, flag_width=20 * 0.0254, flag_height=14 * 0.0254): """ The USGA recommends a golf flagstick height should be at least 7 feet tall, measured from the bottom of the flagstick in the ground to the top of the stick. The standard 14”x20” golf flags are the official size used at golf courses. """ flag = ddd.rect([0, 0, flag_width, flag_height]) flag = flag.material(ddd.mats.red) flag = flag.triangulate() # twosided=True) flag = flag.rotate(ddd.ROT_FLOOR_TO_FRONT).twosided() flag = ddd.uv.map_cubic(flag) flag = flag.translate([0.025, 0, -0.02 - flag_height]) item_post = post(height=pole_height, r=0.025, top=flag, mat_post=ddd.mats.metal_paint_yellow) return item_post