diff --git a/src/along_with.scad b/src/along_with.scad index 832f7261..2c843810 100644 --- a/src/along_with.scad +++ b/src/along_with.scad @@ -23,9 +23,9 @@ module along_with(points, angles, twist = 0, scale = 1.0, method = "AXIS_ANGLE") scale_step_vt = is_num(scale) ? let(s = (scale - 1) / leng_points_minus_one) [s, s, s] : [ - (scale[0] - 1) / leng_points_minus_one, - (scale[1] - 1) / leng_points_minus_one, - is_undef(scale[2]) ? 0 : (scale[2] - 1) / leng_points_minus_one + (scale.x - 1) / leng_points_minus_one, + (scale.y - 1) / leng_points_minus_one, + is_undef(scale.z) ? 0 : (scale.z - 1) / leng_points_minus_one ]; /* diff --git a/src/bend.scad b/src/bend.scad index e04c418f..baf8a41a 100644 --- a/src/bend.scad +++ b/src/bend.scad @@ -10,9 +10,9 @@ module bend(size, angle, frags = 24) { - x = size[0]; - y = size[1]; - z = size[2]; + x = size.x; + y = size.y; + z = size.z; frag_width = x / frags; frag_angle = angle / frags; half_frag_width = 0.5 * frag_width; diff --git a/src/bend_extrude.scad b/src/bend_extrude.scad index 7af69eef..8752e340 100644 --- a/src/bend_extrude.scad +++ b/src/bend_extrude.scad @@ -9,8 +9,8 @@ **/ module bend_extrude(size, thickness, angle, frags = 24) { - x = size[0]; - y = size[1]; + x = size.x; + y = size.y; frag_width = x / frags ; frag_angle = angle / frags; half_frag_width = 0.5 * frag_width; diff --git a/src/cross_sections.scad b/src/cross_sections.scad index 489e368a..13a23dbd 100644 --- a/src/cross_sections.scad +++ b/src/cross_sections.scad @@ -18,17 +18,14 @@ function cross_sections(shape_pts, path_pts, angles, twist = 0, scale = 1.0) = pth_pts = len(path_pts[0]) == 3 ? path_pts : [for(p = path_pts) __to3d(p)], scale_step_vt = is_num(scale) ? [(scale - 1) / len_path_pts_minus_one, (scale - 1) / len_path_pts_minus_one] : - [(scale[0] - 1) / len_path_pts_minus_one, (scale[1] - 1) / len_path_pts_minus_one] - , - scale_step_x = scale_step_vt[0], - scale_step_y = scale_step_vt[1], + [(scale[0] - 1) / len_path_pts_minus_one, (scale[1] - 1) / len_path_pts_minus_one], twist_step = twist / len_path_pts_minus_one ) [ for(i = 0; i <= len_path_pts_minus_one; i = i + 1) [ for(p = sh_pts) - let(scaled_p = [p[0] * (1 + scale_step_x * i), p[1] * (1 + scale_step_y * i), p[2]]) + let(scaled_p = [p.x * (1 + scale_step_vt.x * i), p.y * (1 + scale_step_vt.y * i), p.z]) ptf_rotate( ptf_rotate(scaled_p, twist_step * i) , angles[i] diff --git a/src/ellipse_extrude.scad b/src/ellipse_extrude.scad index 53cdf1f4..7feb819e 100644 --- a/src/ellipse_extrude.scad +++ b/src/ellipse_extrude.scad @@ -58,7 +58,7 @@ module ellipse_extrude(semi_minor_axis, height, center = false, convexity = 10, } } - center_offset = [0, 0, center == true ? -h / 2 : 0]; + center_offset = [0, 0, center ? -h / 2 : 0]; translate(center_offset) extrude() children(); diff --git a/src/line2d.scad b/src/line2d.scad index 0f6b7b83..38417d84 100644 --- a/src/line2d.scad +++ b/src/line2d.scad @@ -14,8 +14,8 @@ use <__comm__/__nearest_multiple_of_4.scad>; module line2d(p1, p2, width = 1, p1Style = "CAP_SQUARE", p2Style = "CAP_SQUARE") { half_width = 0.5 * width; - atan_angle = atan2(p2[1] - p1[1], p2[0] - p1[0]); - leng = sqrt(pow(p2[0] - p1[0], 2) + pow(p2[1] - p1[1], 2)); + atan_angle = atan2(p2.y - p1.y, p2.x - p1.x); + leng = sqrt(pow(p2.x - p1.x, 2) + pow(p2.y - p1.y, 2)); frags = __nearest_multiple_of_4(__frags(half_width)); diff --git a/src/line3d.scad b/src/line3d.scad index 2f25b062..4f6baa9a 100644 --- a/src/line3d.scad +++ b/src/line3d.scad @@ -17,9 +17,9 @@ module line3d(p1, p2, diameter = 1, p1Style = "CAP_CIRCLE", p2Style = "CAP_CIRCL frags = __nearest_multiple_of_4(__frags(r)); half_fa = 180 / frags; - dx = p2[0] - p1[0]; - dy = p2[1] - p1[1]; - dz = p2[2] - p1[2]; + dx = p2.x - p1.x; + dy = p2.y - p1.y; + dz = p2.z - p1.z; length = sqrt(pow(dx, 2) + pow(dy, 2) + pow(dz, 2)); ay = 90 - atan2(dz, sqrt(pow(dx, 2) + pow(dy, 2))); diff --git a/src/noise/nz_perlin2s.scad b/src/noise/nz_perlin2s.scad index 0cdade66..f1e978cb 100644 --- a/src/noise/nz_perlin2s.scad +++ b/src/noise/nz_perlin2s.scad @@ -13,4 +13,4 @@ use <_impl/_pnoise2_impl.scad>; function nz_perlin2s(points, seed) = let(sd = is_undef(seed) ? floor(rand(0, 256)) : seed % 256) - [for(p = points) _pnoise2(p[0], p[1], sd)]; \ No newline at end of file + [for(p = points) _pnoise2(p.x, p.y, sd)]; \ No newline at end of file diff --git a/src/noise/nz_perlin3s.scad b/src/noise/nz_perlin3s.scad index 957f2838..af855298 100644 --- a/src/noise/nz_perlin3s.scad +++ b/src/noise/nz_perlin3s.scad @@ -13,4 +13,4 @@ use <_impl/_pnoise3_impl.scad>; function nz_perlin3s(points, seed) = let(sd = is_undef(seed) ? floor(rand(0, 256)) : seed % 256) - [for(p = points) _pnoise3(p[0], p[1], p[2], sd)]; \ No newline at end of file + [for(p = points) _pnoise3(p.x, p.y, p.z, sd)]; \ No newline at end of file diff --git a/src/path_extrude.scad b/src/path_extrude.scad index ba6ca0ea..25e472b5 100644 --- a/src/path_extrude.scad +++ b/src/path_extrude.scad @@ -24,22 +24,21 @@ module path_extrude(shape_pts, path_pts, triangles = "SOLID", twist = 0, scale = module axis_angle_path_extrude() { twist_step_a = twist / len_path_pts; - function scale_pts(pts, s) = [ - for(p = pts) [p[0] * s[0], p[1] * s[1], p[2] * s[2]] + function scale_pts(pts, s) = + [ + for(p = pts) [p.x * s.x, p.y * s.y, p.z * s.z] ]; - function translate_pts(pts, t) = [ - for(p = pts) [p[0] + t[0], p[1] + t[1], p[2] + t[2]] - ]; + function translate_pts(pts, t) = [for(p = pts) p + t]; function rotate_pts(pts, a, v) = [for(p = pts) ptf_rotate(p, a, v)]; scale_step_vt = is_num(scale) ? let(s = (scale - 1) / len_path_pts_minus_one) [s, s, s] : [ - (scale[0] - 1) / len_path_pts_minus_one, - (scale[1] - 1) / len_path_pts_minus_one, - is_undef(scale[2]) ? 0 : (scale[2] - 1) / len_path_pts_minus_one + (scale.x - 1) / len_path_pts_minus_one, + (scale.y - 1) / len_path_pts_minus_one, + is_undef(scale[2]) ? 0 : (scale.z - 1) / len_path_pts_minus_one ]; // get rotation matrice for sections @@ -157,10 +156,8 @@ module path_extrude(shape_pts, path_pts, triangles = "SOLID", twist = 0, scale = module euler_angle_path_extrude() { scale_step_vt = is_num(scale) ? [(scale - 1) / len_path_pts_minus_one, (scale - 1) / len_path_pts_minus_one] : - [(scale[0] - 1) / len_path_pts_minus_one, (scale[1] - 1) / len_path_pts_minus_one]; + [(scale.x - 1) / len_path_pts_minus_one, (scale.y - 1) / len_path_pts_minus_one]; - scale_step_x = scale_step_vt[0]; - scale_step_y = scale_step_vt[1]; twist_step = twist / len_path_pts_minus_one; function section(p1, p2, i) = @@ -172,7 +169,7 @@ module path_extrude(shape_pts, path_pts, triangles = "SOLID", twist = 0, scale = ) [ for(p = sh_pts) - let(scaled_p = [p[0] * (1 + scale_step_x * i), p[1] * (1 + scale_step_y * i), p[2]]) + let(scaled_p = [p.x * (1 + scale_step_vt.x * i), p.y * (1 + scale_step_vt.y * i), p.z]) ptf_rotate( ptf_rotate( ptf_rotate(scaled_p, twist_step * i), [90, 0, -90] diff --git a/src/path_scaling_sections.scad b/src/path_scaling_sections.scad index cd658bd7..dc3bf717 100644 --- a/src/path_scaling_sections.scad +++ b/src/path_scaling_sections.scad @@ -17,7 +17,7 @@ function path_scaling_sections(shape_pts, edge_path) = base_leng = norm(start_point), scaling_matrice = [ for(p = edge_path) - let(s = norm([p[0], p[1], 0]) / base_leng) + let(s = norm([p.x, p.y, 0]) / base_leng) m_scaling([s, s, 1]) ], leng_edge_path = len(edge_path) @@ -26,7 +26,7 @@ function path_scaling_sections(shape_pts, edge_path) = for(i = 0; i < leng_edge_path; i = i + 1) [ for(p = shape_pts) - let(scaled_p = scaling_matrice[i] * [p[0], p[1], edge_path[i][2], 1]) - [scaled_p[0], scaled_p[1], scaled_p[2]] + let(scaled_p = scaling_matrice[i] * [p.x, p.y, edge_path[i].z, 1]) + [scaled_p.x, scaled_p.y, scaled_p.z] ] ]); \ No newline at end of file diff --git a/src/polyline2d.scad b/src/polyline2d.scad index fee1b42d..9271048a 100644 --- a/src/polyline2d.scad +++ b/src/polyline2d.scad @@ -51,7 +51,7 @@ module polyline2d(points, width = 1, startingStyle = "CAP_SQUARE", endingStyle = c = cross(v1, v2); // c > 0: ct_clk a = angle(p1, p2, p3); - v1a = atan2(v1[1], v1[0]); + v1a = atan2(v1.y, v1.x); ra = c > 0 ? (-90 + v1a) : (90 + v1a - a); if(joinStyle == "JOIN_ROUND") { diff --git a/src/ptf/ptf_bend.scad b/src/ptf/ptf_bend.scad index 68a9d842..ad30fb63 100644 --- a/src/ptf/ptf_bend.scad +++ b/src/ptf/ptf_bend.scad @@ -11,11 +11,9 @@ function ptf_bend(size, point, radius, angle) = let( // ignored: size.y, - y = point[0], - z = point[1], - x = is_undef(point[2]) ? 0 : point[2], + x = is_undef(point.z) ? 0 : point.z, a_step = angle / size.x, - a = a_step * y, + a = a_step * point.x, r = radius + x ) - [r * cos(a), r * sin(a), z]; \ No newline at end of file + [r * cos(a), r * sin(a), point.y]; \ No newline at end of file diff --git a/src/ptf/ptf_ring.scad b/src/ptf/ptf_ring.scad index fb9eea5f..8e9880d0 100644 --- a/src/ptf/ptf_ring.scad +++ b/src/ptf/ptf_ring.scad @@ -16,4 +16,4 @@ function ptf_ring(size, point, radius, angle = 360, twist = 0) = a_step = angle / size.y, twisted = ptf_y_twist(size, point, twist) ) - ptf_rotate([radius + twisted[0], 0, twisted[2]], a_step * twisted[1]); \ No newline at end of file + ptf_rotate([radius + twisted.x, 0, twisted.z], a_step * twisted.y); \ No newline at end of file diff --git a/src/ptf/ptf_torus.scad b/src/ptf/ptf_torus.scad index f1070086..d94f5a7a 100644 --- a/src/ptf/ptf_torus.scad +++ b/src/ptf/ptf_torus.scad @@ -12,18 +12,14 @@ use ; function ptf_torus(size, point, radius, angle = [360, 360], twist = 0) = let( - xlen = size[0], - ylen = size[1], - x = point[0], - y = point[1], R = radius[0], - r = radius[1] + (is_undef(point[2]) ? 0 : point[2]), + r = radius[1] + (is_undef(point.z) ? 0 : point.z), A = angle[0], a = angle[1], - ya_step = a / xlen, - za_step = A / ylen, - twa_step = twist / ylen, - ya = 180 - x * ya_step + twa_step * y, - za = za_step * y + ya_step = a / size.x, + za_step = A / size.y, + twa_step = twist / size.y, + ya = 180 - point.x * ya_step + twa_step * point.y, + za = za_step * point.y ) ptf_rotate([r * cos(ya) + R + r, 0, r * sin(ya)], za); \ No newline at end of file diff --git a/src/ptf/ptf_x_twist.scad b/src/ptf/ptf_x_twist.scad index 7d483a5c..38f48b7b 100644 --- a/src/ptf/ptf_x_twist.scad +++ b/src/ptf/ptf_x_twist.scad @@ -12,10 +12,8 @@ use ; function ptf_x_twist(size, point, angle) = let( - xlen = size[0], - ylen = size[1], - y_offset = ylen / 2, - a_step = angle / xlen, - y_centered = [point[0], point[1], is_undef(point[2]) ? 0 : point[2]] + [0, -y_offset, 0] + y_offset = size.y / 2, + a_step = angle / size.x, + y_centered = [point.x, point.y, is_undef(point.z) ? 0 : point.z] + [0, -y_offset, 0] ) - ptf_rotate(y_centered, [point[0] * a_step, 0, 0]) + [0, y_offset, 0]; \ No newline at end of file + ptf_rotate(y_centered, [point.x * a_step, 0, 0]) + [0, y_offset, 0]; \ No newline at end of file diff --git a/src/ptf/ptf_y_twist.scad b/src/ptf/ptf_y_twist.scad index 37b45638..ad291c00 100644 --- a/src/ptf/ptf_y_twist.scad +++ b/src/ptf/ptf_y_twist.scad @@ -12,10 +12,8 @@ use ; function ptf_y_twist(size, point, angle) = let( - xlen = size[0], - ylen = size[1], - x_offset = xlen / 2, - a_step = angle / ylen, - x_centered = [point[0], point[1], is_undef(point[2]) ? 0 : point[2]] + [-x_offset, 0, 0] + x_offset = size.x / 2, + a_step = angle / size.y, + x_centered = [point.x, point.y, is_undef(point.z) ? 0 : point.z] + [-x_offset, 0, 0] ) - ptf_rotate(x_centered, [0, point[1] * a_step, 0]) + [x_offset, 0, 0]; \ No newline at end of file + ptf_rotate(x_centered, [0, point.y * a_step, 0]) + [x_offset, 0, 0]; \ No newline at end of file diff --git a/src/rounded_cube.scad b/src/rounded_cube.scad index d89be989..0facf39c 100644 --- a/src/rounded_cube.scad +++ b/src/rounded_cube.scad @@ -13,9 +13,9 @@ use <__comm__/__nearest_multiple_of_4.scad>; module rounded_cube(size, corner_r, center = false) { is_flt = is_num(size); - x = is_flt ? size : size[0]; - y = is_flt ? size : size[1]; - z = is_flt ? size : size[2]; + x = is_flt ? size : size.x; + y = is_flt ? size : size.y; + z = is_flt ? size : size.z; corner_frags = __nearest_multiple_of_4(__frags(corner_r)); edge_d = corner_r * cos(180 / corner_frags); diff --git a/src/rounded_extrude.scad b/src/rounded_extrude.scad index b3af4ecf..edd6cc0a 100644 --- a/src/rounded_extrude.scad +++ b/src/rounded_extrude.scad @@ -12,8 +12,8 @@ use <__comm__/__frags.scad>; module rounded_extrude(size, round_r, angle = 90, twist = 0, convexity = 10) { is_flt = is_num(size); - x = is_flt ? size : size[0]; - y = is_flt ? size : size[1]; + x = is_flt ? size : size.x; + y = is_flt ? size : size.y; q_corner_frags = __frags(round_r) / 4; diff --git a/src/rounded_square.scad b/src/rounded_square.scad index a5f97f93..82ff9660 100644 --- a/src/rounded_square.scad +++ b/src/rounded_square.scad @@ -12,8 +12,8 @@ use <__comm__/__trapezium.scad>; module rounded_square(size, corner_r, center = false) { is_flt = is_num(size); - x = is_flt ? size : size[0]; - y = is_flt ? size : size[1]; + x = is_flt ? size : size.x; + y = is_flt ? size : size.y; position = center ? [0, 0] : [x / 2, y / 2]; points = __trapezium( diff --git a/src/shape_cyclicpolygon.scad b/src/shape_cyclicpolygon.scad index d56ac955..ae8f67f7 100644 --- a/src/shape_cyclicpolygon.scad +++ b/src/shape_cyclicpolygon.scad @@ -27,7 +27,7 @@ function shape_cyclicpolygon(sides, circle_r, corner_r) = __frags(corner_r) * corner_circle_a / 360 ) ) - [pt[0] + corner_circle_center, pt[1]] + [pt.x + corner_circle_center, pt.y] ] ) @@ -38,14 +38,12 @@ function shape_cyclicpolygon(sides, circle_r, corner_r) = for(pt = first_corner) let( a = frag_a * side, - x = pt[0], - y = pt[1], sina = sin(a), cosa = cos(a) ) [ - x * cosa - y * sina, - x * sina + y * cosa + pt.x * cosa - pt.y * sina, + pt.x * sina + pt.y * cosa ] ] ); \ No newline at end of file diff --git a/src/shape_square.scad b/src/shape_square.scad index ab50ec58..a4795fbb 100644 --- a/src/shape_square.scad +++ b/src/shape_square.scad @@ -13,8 +13,8 @@ use <__comm__/__trapezium.scad>; function shape_square(size, corner_r = 0) = let( is_flt = is_num(size), - x = is_flt ? size : size[0], - y = is_flt ? size : size[1] + x = is_flt ? size : size.x, + y = is_flt ? size : size.y ) __trapezium( length = x,