From a14c5676d450f98bc733fdf6b5785b7cfcef60d6 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Fri, 8 Oct 2021 09:36:01 +0800 Subject: [PATCH] use polyline_join --- examples/fidget_ball_fern_leaf.scad | 9 ++--- examples/hollow_out/hollow_out_cylinder.scad | 11 +++--- examples/hollow_out/hollow_out_holder.scad | 5 +-- examples/hollow_out/hollow_out_starburst.scad | 8 +++-- examples/hollow_out/hollow_out_torus.scad | 5 +-- examples/hollow_out/hollow_out_vase.scad | 16 ++++++--- examples/image_slicer.scad | 1 - examples/klein_bottle.scad | 8 ++--- examples/maze/mobius_maze.scad | 5 +-- examples/maze/noisy_circle_maze.scad | 7 ++-- examples/maze/spiral_maze.scad | 15 ++++---- examples/maze/theta_maze.scad | 12 ++++--- examples/maze/torus_knot_maze.scad | 35 +++++++++---------- examples/maze/torus_maze.scad | 5 +-- examples/maze/twisted_maze.scad | 5 +-- examples/samurai_daruma.scad | 5 +-- examples/shape2wire.scad | 9 ++--- examples/sierpinski_pyramid.scad | 14 +++++--- examples/spiral/nautilus_shell.scad | 11 +++--- examples/spiral/spiral_math_constants.scad | 5 +-- examples/spiral/string_tetrahedron.scad | 6 ++-- examples/spiral/string_tetrahedrons.scad | 12 ++++--- examples/spiral/vx_spiral_text.scad | 5 +-- examples/spiral_polygons/spiral_polygons.scad | 7 ++-- .../spiral_polygons/square_pursuit_3d.scad | 8 +++-- examples/taiwan/voronoi_taiwan.scad | 1 - examples/tiles/lavender.scad | 1 - examples/tiles/penrose_basket.scad | 9 +++-- examples/tiles/tiled_line_mobius.scad | 5 +-- examples/tiles/tiled_line_torus.scad | 6 ++-- examples/trefoil_klein_bottle.scad | 8 ++--- examples/turtle/fern_leaf_stencil.scad | 8 +++-- examples/turtle/hilbert_curve_drawing.scad | 5 +-- examples/turtle/lsystem3_collection.scad | 9 ++--- examples/turtle/sierpinski_triangle.scad | 8 ++--- examples/voronoi/voronoi_torus.scad | 5 +-- 36 files changed, 158 insertions(+), 136 deletions(-) diff --git a/examples/fidget_ball_fern_leaf.scad b/examples/fidget_ball_fern_leaf.scad index 899ec0f8..b37b2665 100644 --- a/examples/fidget_ball_fern_leaf.scad +++ b/examples/fidget_ball_fern_leaf.scad @@ -1,4 +1,4 @@ -use ; +use ; use ; use ; use ; @@ -43,11 +43,8 @@ module fidget_ball_fern_leaf(radius, thickness, spacing, drill_angle, support_th for(i = [0:n - 1]) { rotate(i * a_step) for(line = fern) { - hull_polyline3d( - line, - thickness * thickness_scale, - $fn = 5 - ); + polyline_join(line) + sphere(thickness * thickness_scale / 2, $fn = 5); } } } diff --git a/examples/hollow_out/hollow_out_cylinder.scad b/examples/hollow_out/hollow_out_cylinder.scad index 6a9afa9d..a270bd14 100644 --- a/examples/hollow_out/hollow_out_cylinder.scad +++ b/examples/hollow_out/hollow_out_cylinder.scad @@ -1,5 +1,5 @@ -use ; -use ; +use ; +use ; use ; use ; @@ -33,9 +33,6 @@ bisectors = [ for(line = bisectors) { pts = [for(p = line) ptf_bend(size, p, radius, 360)]; - hull_polyline3d( - concat(pts, [pts[0]]), - line_diameter = line_diameter, - $fn = 4 - ); + polyline_join(concat(pts, [pts[0]])) + sphere(d = line_diameter, $fn = 4); } \ No newline at end of file diff --git a/examples/hollow_out/hollow_out_holder.scad b/examples/hollow_out/hollow_out_holder.scad index 4db8301c..c5b74ad6 100644 --- a/examples/hollow_out/hollow_out_holder.scad +++ b/examples/hollow_out/hollow_out_holder.scad @@ -1,4 +1,4 @@ -use ; +use ; use ; use ; @@ -18,7 +18,8 @@ lines = concat( for(line = lines) { transformed = [for(pt = line) ptf_bend([columns * width, rows * width], pt, radius, angle)]; - hull_polyline3d(transformed, diameter, $fn = 4); + polyline_join(transformed) + sphere(d = diameter, $fn = 4); } translate([0, 0, -diameter / 2]) diff --git a/examples/hollow_out/hollow_out_starburst.scad b/examples/hollow_out/hollow_out_starburst.scad index 14593ccb..cc2abfec 100644 --- a/examples/hollow_out/hollow_out_starburst.scad +++ b/examples/hollow_out/hollow_out_starburst.scad @@ -1,5 +1,5 @@ use ; -use ; +use ; use ; r1 = 30; @@ -19,9 +19,11 @@ module hollow_out_starburst(r1, r2, h, n, line_diameter, half = false) { module half_star() { for(tri = tris) { - hull_polyline3d(concat(tri, [tri[0]]), line_diameter = line_diameter); + polyline_join(concat(tri, [tri[0]])) + sphere(d = line_diameter); for(line = tri_bisectors(tri)) { - hull_polyline3d(concat(line, [line[0]]), line_diameter = line_diameter); + polyline_join(concat(line, [line[0]])) + sphere(d = line_diameter); } } } diff --git a/examples/hollow_out/hollow_out_torus.scad b/examples/hollow_out/hollow_out_torus.scad index 21354ef4..afd939d0 100644 --- a/examples/hollow_out/hollow_out_torus.scad +++ b/examples/hollow_out/hollow_out_torus.scad @@ -1,4 +1,4 @@ -use ; +use ; use ; use ; @@ -13,7 +13,8 @@ lines = hollow_out_square([columns, rows], width); for(line = lines) { transformed = [for(pt = line) ptf_torus([columns * width, rows * width], pt, [radius, radius / 2], twist = twist)]; - hull_polyline3d(transformed, line_diameter, $fn = 4); + polyline_join(transformed) + sphere(d = line_diameter, $fn = 4); } color("black") diff --git a/examples/hollow_out/hollow_out_vase.scad b/examples/hollow_out/hollow_out_vase.scad index 84dd076a..b7efef49 100644 --- a/examples/hollow_out/hollow_out_vase.scad +++ b/examples/hollow_out/hollow_out_vase.scad @@ -1,4 +1,4 @@ -use ; +use ; use ; use ; use ; @@ -19,6 +19,7 @@ p4 = [35, 0, 130]; hollow_out_vase([p0, p1, p2, p3, p4], t_step, line_diameter, fn, line_style); module hollow_out_vase(ctrl_pts, t_step, line_diameter, fn, line_style) { + line_r = line_diameter / 2; bezier = bezier_curve(t_step, ctrl_pts ); @@ -45,9 +46,11 @@ module hollow_out_vase(ctrl_pts, t_step, line_diameter, fn, line_style) { for(tri = fst_tris) { lines = tri_bisectors(tri); for(line = lines) { - hull_polyline3d(line, diameter = line_diameter, $fn = 4); + polyline_join(line) + sphere(line_r, $fn = 4); } - hull_polyline3d([lines[2][1], [0, 0, 0]], diameter = line_diameter, $fn = 4); + polyline_join([lines[2][1], [0, 0, 0]]) + sphere(line_r, $fn = 4); } // mouth @@ -59,7 +62,10 @@ module hollow_out_vase(ctrl_pts, t_step, line_diameter, fn, line_style) { dangling_pts = [for(tri = lst_tris) tri_bisectors(tri)[1][1]]; offset_z = [0, 0, line_diameter]; for(i = [0: leng_sect - 1]) { - hull_polyline3d([lst_sect[i] + offset_z, dangling_pts[i]], diameter = line_diameter, $fn = 4); - hull_polyline3d([lst_sect[(i + 1) % leng_sect] + offset_z, dangling_pts[i]], diameter = line_diameter, $fn = 4); + polyline_join([lst_sect[i] + offset_z, dangling_pts[i]]) + sphere(line_r, $fn = 4); + + polyline_join([lst_sect[(i + 1) % leng_sect] + offset_z, dangling_pts[i]]) + sphere(line_r, $fn = 4); } } \ No newline at end of file diff --git a/examples/image_slicer.scad b/examples/image_slicer.scad index 798be4ff..bdc6a798 100644 --- a/examples/image_slicer.scad +++ b/examples/image_slicer.scad @@ -1,4 +1,3 @@ -use ; use ; level_step = 51; diff --git a/examples/klein_bottle.scad b/examples/klein_bottle.scad index 4bb9ed88..ed402b36 100644 --- a/examples/klein_bottle.scad +++ b/examples/klein_bottle.scad @@ -2,7 +2,7 @@ use ; use ; use ; use ; -use ; +use ; use ; radius1 = 10; @@ -31,10 +31,8 @@ module klein_bottle(radius1, radius2, bottom_height, thickness, t_step, fn) { path = concat([for(p = ph1) p + [radius1 + radius2, 0, 0]], ph2); - hull_polyline2d( - path, - thickness - ); + polyline_join(path) + circle(half_thickness); } } diff --git a/examples/maze/mobius_maze.scad b/examples/maze/mobius_maze.scad index 965ad102..06d20628 100644 --- a/examples/maze/mobius_maze.scad +++ b/examples/maze/mobius_maze.scad @@ -1,4 +1,4 @@ -use ; +use ; use ; use ; use ; @@ -24,5 +24,6 @@ walls = mz_square_walls(cells, rows, columns, cell_width, bottom_border = false) size = [columns * cell_width, rows * cell_width]; for(wall_pts = walls) { transformed = [for(pt = wall_pts) ptf_ring(size, pt, radius, 360, angle)]; - hull_polyline3d(transformed, line_diameter); + polyline_join(transformed) + sphere(d = line_diameter); } \ No newline at end of file diff --git a/examples/maze/noisy_circle_maze.scad b/examples/maze/noisy_circle_maze.scad index 9cec9dee..f2067ee7 100644 --- a/examples/maze/noisy_circle_maze.scad +++ b/examples/maze/noisy_circle_maze.scad @@ -1,4 +1,4 @@ -use ; +use ; use ; use ; use ; @@ -18,7 +18,7 @@ module noisy_circle_maze(r_cells, cell_width, wall_thickness, origin_offset, noi rect_size = is_undef(origin_offset) ? [width, width] : [width, width] - origin_offset * 2; noisy_f = is_undef(noisy_factor) ? 1 : noisy_factor; - + half_wall_thickness = wall_thickness / 2; seed = rand(0, 256); for(wall = walls) { for(i = [0:len(wall) - 2]) { @@ -28,7 +28,8 @@ module noisy_circle_maze(r_cells, cell_width, wall_thickness, origin_offset, noi pn01 = nz_perlin2(p0[0] + seed, p0[1] + seed, seed) * noisy_f; pn10 = nz_perlin2(p1[0], p1[1], seed) * noisy_f; pn11 = nz_perlin2(p1[0] + seed, p1[1] + seed, seed) * noisy_f; - hull_polyline2d([p0 + [pn00, pn01], p1 + [pn10, pn11]], width = wall_thickness); + polyline_join([p0 + [pn00, pn01], p1 + [pn10, pn11]]) + circle(half_wall_thickness); } } } diff --git a/examples/maze/spiral_maze.scad b/examples/maze/spiral_maze.scad index f8e7e4a0..fbbbe5d2 100644 --- a/examples/maze/spiral_maze.scad +++ b/examples/maze/spiral_maze.scad @@ -1,6 +1,5 @@ use ; -use ; -use ; +use ; use ; use ; @@ -29,8 +28,10 @@ module spiral_maze() { rows, columns, cell_width ); + half_thickness = wall_thickness / 2; + for(wall = walls) { - hull_polyline3d([ + polyline_join([ for(p = wall) let( x = p[0], @@ -38,14 +39,12 @@ module spiral_maze() { cp = (pts3d[x] + pts3d[x + 1]) / 2 ) cp + [0, y, 0] - ], - wall_thickness, - $fn = 5 - ); + ]) sphere(half_thickness, $fn = 5); } translate([0, rows, 0]) rotate([90, 0, 0]) linear_extrude(rows) - hull_polyline2d([for(i = [1:len(pts2d) - 2]) pts2d[i]], wall_thickness / 2); + polyline_join([for(i = [1:len(pts2d) - 2]) pts2d[i]]) + circle(wall_thickness / 4); } \ No newline at end of file diff --git a/examples/maze/theta_maze.scad b/examples/maze/theta_maze.scad index bca17141..07d68f53 100644 --- a/examples/maze/theta_maze.scad +++ b/examples/maze/theta_maze.scad @@ -1,6 +1,6 @@ use ; use ; -use ; +use ; rows = 5; beginning_number = 8; @@ -16,6 +16,7 @@ module theta_maze(rows, beginning_number, cell_width, wall_thickness, wall_heigh maze = mz_theta_cells(rows, beginning_number); + half_wall_thickness = wall_thickness / 2; linear_extrude(wall_height) { for(rows = maze) { for(cell = rows) { @@ -33,11 +34,13 @@ module theta_maze(rows, beginning_number, cell_width, wall_thickness, wall_heigh outerVt2 = vt_from_angle(theta2, outerR); if(wallType == "INWARD_WALL" || wallType == "INWARD_CCW_WALL") { - hull_polyline2d([innerVt1, innerVt2], width = wall_thickness); + polyline_join([innerVt1, innerVt2]) + circle(half_wall_thickness); } if(wallType == "CCW_WALL" || wallType == "INWARD_CCW_WALL") { - hull_polyline2d([innerVt2, outerVt2], width = wall_thickness); + polyline_join([innerVt2, outerVt2]) + circle(half_wall_thickness); } } } @@ -47,7 +50,8 @@ module theta_maze(rows, beginning_number, cell_width, wall_thickness, wall_heigh for(theta = [0:thetaStep:360 - thetaStep]) { vt1 = vt_from_angle(theta, r); vt2 = vt_from_angle(theta + thetaStep, r); - hull_polyline2d([vt1, vt2], width = wall_thickness); + polyline_join([vt1, vt2]) + circle(half_wall_thickness); } } } \ No newline at end of file diff --git a/examples/maze/torus_knot_maze.scad b/examples/maze/torus_knot_maze.scad index 9f57d910..b11f1a46 100644 --- a/examples/maze/torus_knot_maze.scad +++ b/examples/maze/torus_knot_maze.scad @@ -1,4 +1,4 @@ -use ; +use ; use ; use ; use ; @@ -42,25 +42,22 @@ module torus_knot_maze() { ); half_row = rows / 2; - + r = wall_thickness / 2; for(wall = walls) { - hull_polyline3d([ - for(p = wall) - let( - x = p[0], - y = p[1] - ) - path[x] + ptf_rotate( - ptf_rotate( - [-y + half_row, 0, 0], - [0, 0, -90] - ), - [0, angle_yz[x][0], angle_yz[x][1]] - ) - ], - wall_thickness, - $fn = 4 - ); + polyline_join([ + for(p = wall) + let( + x = p[0], + y = p[1] + ) + path[x] + ptf_rotate( + ptf_rotate( + [-y + half_row, 0, 0], + [0, 0, -90] + ), + [0, angle_yz[x][0], angle_yz[x][1]] + ) + ]) sphere(r, $fn = 4); } if(filled) { diff --git a/examples/maze/torus_maze.scad b/examples/maze/torus_maze.scad index ea8176d5..f7ff6840 100644 --- a/examples/maze/torus_maze.scad +++ b/examples/maze/torus_maze.scad @@ -1,4 +1,4 @@ -use ; +use ; use ; use ; use ; @@ -24,7 +24,8 @@ walls = mz_square_walls(cells, rows, columns, cell_width, left_border = false, b size = [columns * cell_width, rows * cell_width]; for(wall_pts = walls) { transformed = [for(pt = wall_pts) ptf_torus(size, pt, [radius, radius / 2], twist = twist)]; - hull_polyline3d(transformed, line_diameter, $fn = 4); + polyline_join(transformed) + sphere(d = line_diameter, $fn = 4); } color("black") diff --git a/examples/maze/twisted_maze.scad b/examples/maze/twisted_maze.scad index 8098510d..ffe24fbf 100644 --- a/examples/maze/twisted_maze.scad +++ b/examples/maze/twisted_maze.scad @@ -1,4 +1,4 @@ -use ; +use ; use ; use ; use ; @@ -21,5 +21,6 @@ walls = mz_square_walls(cells, rows, columns, cell_width); size = [columns * cell_width, rows * cell_width]; for(wall_pts = walls) { transformed = [for(pt = wall_pts) axis == "X_AXIS" ? ptf_x_twist(size, pt, angle) : ptf_y_twist(size, pt, angle)]; - hull_polyline3d(transformed, line_diameter); + polyline_join(transformed) + sphere(d = line_diameter); } \ No newline at end of file diff --git a/examples/samurai_daruma.scad b/examples/samurai_daruma.scad index ec20b8d0..8abfa3ce 100644 --- a/examples/samurai_daruma.scad +++ b/examples/samurai_daruma.scad @@ -1,6 +1,6 @@ use ; use ; -use ; +use ; text = "順暢"; font = "思源黑體 Medium"; @@ -48,7 +48,8 @@ module helmet() { rotate(-30) rotate_extrude(angle = 240, $fn = 12) - hull_polyline2d([[40.65, 1], [45, -10], [50, -30], [60, -45]], 3.25, $fn = 4); + polyline_join([[40.65, 1], [45, -10], [50, -30], [60, -45]]) + circle(1.625, $fn = 4); translate([0, 0, 1]) linear_extrude(2) diff --git a/examples/shape2wire.scad b/examples/shape2wire.scad index 711da3e5..b147ada2 100644 --- a/examples/shape2wire.scad +++ b/examples/shape2wire.scad @@ -1,6 +1,5 @@ use ; -use ; -use ; +use ; use ; function shape2wire(shape, r) = @@ -28,9 +27,11 @@ rotate([90, 0, 0]) linear_extrude(1, center = true) difference() { square(120, center = true); - hull_polyline2d(concat(shape, [shape[0]]), width = 5); + polyline_join(concat(shape, [shape[0]])) + circle(2.5); } wire = shape2wire(shape, 150); rotate(-$t * 360) - hull_polyline3d(concat(wire, [wire[0]]), 3); \ No newline at end of file +polyline_join(concat(wire, [wire[0]])) + sphere(1.5); \ No newline at end of file diff --git a/examples/sierpinski_pyramid.scad b/examples/sierpinski_pyramid.scad index 4d9dd3c8..fc529b77 100644 --- a/examples/sierpinski_pyramid.scad +++ b/examples/sierpinski_pyramid.scad @@ -1,4 +1,4 @@ -use ; +use ; side_leng = 100; min_leng = 5; @@ -29,11 +29,15 @@ module pyramid_frame(side_leng, diameter) { tri_pts = [[0, 0, h], [half_leng, half_leng, 0], [half_leng, -half_leng, 0], [0, 0, h]]; line_pts = [[half_leng, half_leng, 0], [-half_leng, half_leng, 0]]; - hull_polyline3d(tri_pts, diameter); + polyline_join(tri_pts) + sphere(d = diameter); mirror([1, 0, 0]) - hull_polyline3d(tri_pts, diameter); + polyline_join(tri_pts) + sphere(d = diameter); - hull_polyline3d(line_pts, diameter); + polyline_join(line_pts) + sphere(d = diameter); mirror([0, 1, 0]) - hull_polyline3d(line_pts, diameter); + polyline_join(line_pts) + sphere(d = diameter); } \ No newline at end of file diff --git a/examples/spiral/nautilus_shell.scad b/examples/spiral/nautilus_shell.scad index 5f463d86..b51f831d 100644 --- a/examples/spiral/nautilus_shell.scad +++ b/examples/spiral/nautilus_shell.scad @@ -1,5 +1,5 @@ use ; -use ; +use ; use ; use ; @@ -19,8 +19,10 @@ module nautilus_shell(chambered_section_max_angle, steps, thickness) { ptf_rotate([r(a), 0], a) ]; + half_thickness = thickness / 2; render() { - hull_polyline2d(spiral, thickness); + polyline_join(spiral) + circle(half_thickness); for(a = [a_step:a_step * 2:chambered_section_max_angle]) { a2 = a + 360; @@ -29,9 +31,8 @@ module nautilus_shell(chambered_section_max_angle, steps, thickness) { p2 = ptf_rotate((p1 + ptf_rotate([r(a2), 0], a2)) * .6, -5); p3 = ptf_rotate([r(a3), 0], a3); - hull_polyline2d(bezier_curve(0.1, - [p1, p2, p3] - ), thickness); + polyline_join(bezier_curve(0.1, [p1, p2, p3])) + circle(half_thickness); } } diff --git a/examples/spiral/spiral_math_constants.scad b/examples/spiral/spiral_math_constants.scad index e61b588e..5bffde2c 100644 --- a/examples/spiral/spiral_math_constants.scad +++ b/examples/spiral/spiral_math_constants.scad @@ -1,5 +1,5 @@ use ; -use ; +use ; use ; n = 150; @@ -51,6 +51,7 @@ module spiral_math_constants(n, radius, constants, font_name, font_size, txt_ext } for(i = [0:2:6]) { - hull_polyline3d(spirals[i] * 0.9, 1, $fn = 4); + polyline_join(spirals[i] * 0.9) + sphere(.5, $fn = 4); } } \ No newline at end of file diff --git a/examples/spiral/string_tetrahedron.scad b/examples/spiral/string_tetrahedron.scad index d7108b8c..ed09d5a7 100644 --- a/examples/spiral/string_tetrahedron.scad +++ b/examples/spiral/string_tetrahedron.scad @@ -1,4 +1,4 @@ -use ; +use ; leng = 50; diameter = 5; @@ -20,8 +20,10 @@ module string_tetrahedron(leng, diameter, segs_per_side, line_fn) { pts1 = pts(side1[0], side1[1], segs); pts2 = pts(side2[0], side2[1], segs); + r = diameter / 2; for(i = [0:len(pts1) - 1]) { - hull_polyline3d(points = [pts1[i], pts2[i]], diameter = diameter); + polyline_join([pts1[i], pts2[i]]) + sphere(r); } } diff --git a/examples/spiral/string_tetrahedrons.scad b/examples/spiral/string_tetrahedrons.scad index d1f34263..89a24d5d 100644 --- a/examples/spiral/string_tetrahedrons.scad +++ b/examples/spiral/string_tetrahedrons.scad @@ -1,4 +1,4 @@ -use ; +use ; level = 1; leng = 50; @@ -20,12 +20,16 @@ module string_tetrahedron(leng, diameter, segs_per_side, line_fn) { pts2 = pts(side2[0], side2[1], segs); leng = len(pts1); - hull_polyline3d(points = [pts1[0], pts2[0]], diameter = diameter); + r = diameter / 2; + polyline_join(points = [pts1[0], pts2[0]]) + sphere(r); for(i = [1:leng - 2]) { - hull_polyline3d(points = [pts1[i], pts2[i]], diameter = diameter); + polyline_join([pts1[i], pts2[i]]) + sphere(r); } end = leng - 1; - hull_polyline3d(points = [pts1[end], pts2[end]], diameter = diameter); + polyline_join([pts1[end], pts2[end]]) + sphere(r); } function height(leng) = diff --git a/examples/spiral/vx_spiral_text.scad b/examples/spiral/vx_spiral_text.scad index a9df4318..72d80984 100644 --- a/examples/spiral/vx_spiral_text.scad +++ b/examples/spiral/vx_spiral_text.scad @@ -1,4 +1,4 @@ -use ; +use ; use ; tx = "3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172"; @@ -20,7 +20,8 @@ linear_extrude(1) { translate(pts[i]) square(7, center = true); } - hull_polyline2d([for(i = [0:len(tx) - 1]) pts[i]], width = 2); + polyline_join([for(i = [0:len(tx) - 1]) pts[i]]) + circle(1); } function _px_spiral_forward(pt, leng, dir, clockwise) = diff --git a/examples/spiral_polygons/spiral_polygons.scad b/examples/spiral_polygons/spiral_polygons.scad index 08228b99..6b265df3 100644 --- a/examples/spiral_polygons/spiral_polygons.scad +++ b/examples/spiral_polygons/spiral_polygons.scad @@ -1,5 +1,5 @@ use ; -use ; +use ; use ; beginning_radius = 10; @@ -18,11 +18,14 @@ module spiral_polygons(beginning_radius, line_width, fn, n) { dr = y / cos(theta); pw = pow((beginning_radius + dr) * sin(theta), 2); + half_line_width = line_width / 2; + function a(ri, ro, i) = acos((pow(ro, 2) + pow(ri, 2) - pw * pow(0.985, i)) / (2 * ro * ri)); module drawPolygon(r) { pts = shape_circle(radius = r, $fn = fn); - hull_polyline2d(concat(pts, [pts[0]]), width = line_width, $fn = 12); + polyline_join(concat(pts, [pts[0]])) + circle(half_line_width, $fn = 12); } rs = [for(i = [0: n - 1]) beginning_radius + i * dr]; diff --git a/examples/spiral_polygons/square_pursuit_3d.scad b/examples/spiral_polygons/square_pursuit_3d.scad index 546788bc..9912a7dd 100644 --- a/examples/spiral_polygons/square_pursuit_3d.scad +++ b/examples/spiral_polygons/square_pursuit_3d.scad @@ -1,4 +1,4 @@ -use ; +use ; length = 100; diff_scale = 0.125; @@ -22,7 +22,8 @@ module square_pursuit_3d(length, diff_scale, diameter, n) { npts = [for(i = [0:3]) inter_p(pts[i], pts[(i + 1) % 4], leng, d)]; - hull_polyline3d(concat(npts, [npts[3], npts[0]]), diameter); + polyline_join(concat(npts, [npts[3], npts[0]])) + sphere(d = diameter); _square_pursuit_3d(npts, diff_scale, diameter, n - 1); } @@ -36,7 +37,8 @@ module square_pursuit_3d(length, diff_scale, diameter, n) { [0, length, 0] ]; - hull_polyline3d(concat(pts, [pts[3], pts[0]]), diameter); + polyline_join(concat(pts, [pts[3], pts[0]])) + sphere(d = diameter); _square_pursuit_3d(pts, diff_scale, diameter, n - 1); } diff --git a/examples/taiwan/voronoi_taiwan.scad b/examples/taiwan/voronoi_taiwan.scad index 7749ec82..438508b6 100644 --- a/examples/taiwan/voronoi_taiwan.scad +++ b/examples/taiwan/voronoi_taiwan.scad @@ -1,5 +1,4 @@ use ; -use ; use ; use ; diff --git a/examples/tiles/lavender.scad b/examples/tiles/lavender.scad index a0dc4dc7..770adc3e 100644 --- a/examples/tiles/lavender.scad +++ b/examples/tiles/lavender.scad @@ -1,5 +1,4 @@ use ; -use ; use ; use ; diff --git a/examples/tiles/penrose_basket.scad b/examples/tiles/penrose_basket.scad index 6ea0b3f6..450e66e9 100644 --- a/examples/tiles/penrose_basket.scad +++ b/examples/tiles/penrose_basket.scad @@ -1,7 +1,7 @@ use ; use ; use ; -use ; +use ; use ; use ; use ; @@ -19,6 +19,7 @@ $fn = 4; penrose_basket(basket_radius, radius_in_plane, n, line_diameter, bottom_radius, bottom_height, shell_random_threshold); module penrose_basket(basket_radius, radius_in_plane, n, line_diameter, bottom_radius, bottom_height, shell_random_threshold) { + line_r = line_diameter / 2; tris = [for(t = tile_penrose3(n)) t[1] * radius_in_plane]; for(t = tris) { if(every(t, function(p) norm(p) < radius_in_plane * 1.25)) { @@ -30,10 +31,8 @@ module penrose_basket(basket_radius, radius_in_plane, n, line_diameter, bottom_r cp ]; - hull_polyline3d( - pts, - line_diameter - ); + polyline_join(pts) + sphere(line_r); if(rands(0, 1, 1)[0] < shell_random_threshold) { inward_ratio = (basket_radius - 0.25 * line_diameter) / basket_radius; diff --git a/examples/tiles/tiled_line_mobius.scad b/examples/tiles/tiled_line_mobius.scad index 5aaaed10..aa44d955 100644 --- a/examples/tiles/tiled_line_mobius.scad +++ b/examples/tiles/tiled_line_mobius.scad @@ -1,5 +1,5 @@ use ; -use ; +use ; use ; size = [20, 100]; @@ -28,9 +28,10 @@ module tiled_line_mobius(size, twist, line_diameter = 1) { ] ); + half_line_diameter = line_diameter / 2; for(line = lines) { pts = [for(p = line) ptf_ring(size, p, size[0], twist = twist)]; - hull_polyline3d(pts, diameter = line_diameter); + polyline_join(pts) sphere(half_line_diameter); } } diff --git a/examples/tiles/tiled_line_torus.scad b/examples/tiles/tiled_line_torus.scad index 136291ae..56f06da8 100644 --- a/examples/tiles/tiled_line_torus.scad +++ b/examples/tiles/tiled_line_torus.scad @@ -1,5 +1,5 @@ use ; -use ; +use ; use ; size = [20, 50]; @@ -18,9 +18,11 @@ module tiled_line_torus(size, twist, line_diameter = 1) { i <= 1 ? [[x, y], [x + 1, y + 1]] : [[x + 1, y], [x, y + 1]] ]; + half_line_diameter = line_diameter / 2; for(line = lines) { pts = [for(p = line) ptf_torus(size, p, [size[0], size[0] / 2], twist = twist)]; - hull_polyline3d(pts, diameter = line_diameter); + polyline_join(pts) + sphere(half_line_diameter); } } diff --git a/examples/trefoil_klein_bottle.scad b/examples/trefoil_klein_bottle.scad index e282ea48..9bb2b0ea 100644 --- a/examples/trefoil_klein_bottle.scad +++ b/examples/trefoil_klein_bottle.scad @@ -3,7 +3,7 @@ use ; use ; use ; use ; -use ; +use ; thickness = 4.5; t_step = 0.05; @@ -28,10 +28,8 @@ module dis_connected_klein_bottle(radius1, radius2, bottom_height, thickness, t_ path = concat([for(p = ph1) p + [radius1 + radius2, 0, 0]], ph2); - hull_polyline2d( - path, - thickness - ); + polyline_join(path) + circle(half_thickness); } } diff --git a/examples/turtle/fern_leaf_stencil.scad b/examples/turtle/fern_leaf_stencil.scad index 6e3bcde8..a76cafa2 100644 --- a/examples/turtle/fern_leaf_stencil.scad +++ b/examples/turtle/fern_leaf_stencil.scad @@ -1,4 +1,4 @@ -use ; +use ; use ; use ; @@ -13,7 +13,8 @@ k2 = 0.3; module fern_leaf(t, leng, min_leng, k1, k2, width) { t1 = t2d(t, "forward", leng = leng); - hull_polyline2d([t2d(t, "point"), t2d(t1, "point")], width); + polyline_join([t2d(t, "point"), t2d(t1, "point")]) + circle(width / 2); if(leng > min_leng) { fern_leaf( @@ -22,7 +23,8 @@ module fern_leaf(t, leng, min_leng, k1, k2, width) { ); t2 = t2d(t1, "forward", leng = k1 * leng); - hull_polyline2d([t2d(t1, "point"), t2d(t2, "point")], width); + polyline_join([t2d(t1, "point"), t2d(t2, "point")]) + circle(width / 2); t3 = t2d(t2, "turn", angle = -69.0); fern_leaf( diff --git a/examples/turtle/hilbert_curve_drawing.scad b/examples/turtle/hilbert_curve_drawing.scad index 85063a58..e9dfeae3 100644 --- a/examples/turtle/hilbert_curve_drawing.scad +++ b/examples/turtle/hilbert_curve_drawing.scad @@ -1,5 +1,5 @@ use ; -use ; +use ; use ; use ; @@ -14,7 +14,8 @@ hilbert_path = dedup( ); smoothed_hilbert_path = bezier_smooth(hilbert_path, corner_r); -hull_polyline3d(smoothed_hilbert_path, diameter = diameter); +polyline_join(smoothed_hilbert_path) + sphere(d = diameter); function hilbert_curve() = let( diff --git a/examples/turtle/lsystem3_collection.scad b/examples/turtle/lsystem3_collection.scad index 8ae1b243..fe22968f 100644 --- a/examples/turtle/lsystem3_collection.scad +++ b/examples/turtle/lsystem3_collection.scad @@ -1,13 +1,10 @@ use ; use ; -use ; +use ; for(line = dedup(hilbert_curve())) { - hull_polyline3d( - [line[0], line[1]], - diameter = 0.5, - $fn = 4 - ); + polyline_join([line[0], line[1]]) + sphere(.25, $fn = 4); } function tree1(n = 4, angle = 22.5, leng = 1, heading = 0, start = [0, 0, 0]) = diff --git a/examples/turtle/sierpinski_triangle.scad b/examples/turtle/sierpinski_triangle.scad index da0c1be5..93dc9f69 100644 --- a/examples/turtle/sierpinski_triangle.scad +++ b/examples/turtle/sierpinski_triangle.scad @@ -1,4 +1,4 @@ -use ; +use ; use ; side_leng = 100; @@ -17,10 +17,8 @@ module triangle(t, side_leng, thickness) { ["forward", side_leng] ]); - hull_polyline2d( - [for(turtle = [t, t2, t3, t]) t2d(turtle, "point")], - thickness - ); + polyline_join([for(turtle = [t, t2, t3, t]) t2d(turtle, "point")]) + circle(thickness / 2); } module sierpinski_triangle(t, side_leng, min_leng, thickness) { diff --git a/examples/voronoi/voronoi_torus.scad b/examples/voronoi/voronoi_torus.scad index c0ee25b1..8d687045 100644 --- a/examples/voronoi/voronoi_torus.scad +++ b/examples/voronoi/voronoi_torus.scad @@ -1,5 +1,5 @@ use ; -use ; +use ; use ; size = [40, 80]; @@ -11,5 +11,6 @@ $fn = 4; for(cell = cells) { cell_poly = [for(p = cell[1]) ptf_torus(size, p, [10, 5], [360, 360])]; - hull_polyline3d(cell_poly, diameter = 1); + polyline_join(cell_poly) + sphere(d = 1); } \ No newline at end of file