diff --git a/src/_impl/_angle_between_impl.scad b/src/_impl/_angle_between_impl.scad index aa053dd3..b2b5a2c6 100644 --- a/src/_impl/_angle_between_impl.scad +++ b/src/_impl/_angle_between_impl.scad @@ -1,12 +1,12 @@ function angle_between_ccw_2d(v1, v2) = - let(a = atan2(v1[0] * v2[1] - v1[1] * v2[0], v1 * v2)) + let(a = atan2(v1.x * v2.y - v1.y * v2.x, v1 * v2)) a >= 0 ? a : a + 360; function angle_between_ccw_3d(v1, v2) = let( dot = v1 * v2, - lenSq1 = v1[0] ^ 2 + v1[1] ^ 2 + v1[2] ^ 2, - lenSq2 = v2[0] ^ 2 + v2[1] ^ 2 + v2[2] ^ 2, + lenSq1 = v1.x ^ 2 + v1.y ^ 2 + v1.z ^ 2, + lenSq2 = v2.x ^ 2 + v2.y ^ 2 + v2.z ^ 2, a = acos(dot / sqrt(lenSq1 * lenSq2)) ) a >= 0 ? a : a + 360; \ No newline at end of file diff --git a/src/_impl/_bijection_offset_impl.scad b/src/_impl/_bijection_offset_impl.scad index 873a0209..b9eee155 100644 --- a/src/_impl/_bijection_offset_impl.scad +++ b/src/_impl/_bijection_offset_impl.scad @@ -5,8 +5,8 @@ function _bijection_inward_edge_normal(edge) = let( pt1 = edge[0], pt2 = edge[1], - dx = pt2[0] - pt1[0], - dy = pt2[1] - pt1[1], + dx = pt2.x - pt1.x, + dy = pt2.y - pt1.y, edge_leng = norm([dx, dy]) ) [-dy / edge_leng, dx / edge_leng]; @@ -26,8 +26,8 @@ function _bijection__bijection_offset_edges(edges, d) = for(edge = edges) let( ow_normal = _bijection_outward_edge_normal(edge), - dx = ow_normal[0] * d, - dy = ow_normal[1] * d + dx = ow_normal.x * d, + dy = ow_normal.y * d ) _bijection_offset_edge(edge, dx, dy) ]; diff --git a/src/_impl/_contours_impl.scad b/src/_impl/_contours_impl.scad index fa5888cc..84eb0c95 100644 --- a/src/_impl/_contours_impl.scad +++ b/src/_impl/_contours_impl.scad @@ -2,9 +2,9 @@ use <../util/lerp.scad>; function interpolated_pt(p0, p1, threshold) = lerp( - [p0[0], p0[1], p0[2]], - [p1[0], p1[1], p1[2]], - (threshold - p0[2]) / (p1[2] - p0[2]) + [p0.x, p0.y, p0.z], + [p1.x, p1.y, p1.z], + (threshold - p0.z) / (p1.z - p0.z) ); /* @@ -21,7 +21,7 @@ function interpolated_pt(p0, p1, threshold) = function _isolines_pn_label(pts, threshold) = [ for(row = pts) - [for(p = row) [p[0], p[1], p[2], p[2] >= threshold]] + [for(p = row) [p.x, p.y, p.z, p.z >= threshold]] ]; function _isolines_corner_value(cell_pts) = diff --git a/src/_impl/_in_shape_impl.scad b/src/_impl/_in_shape_impl.scad index 7805da94..96f2d6ee 100644 --- a/src/_impl/_in_shape_impl.scad +++ b/src/_impl/_in_shape_impl.scad @@ -2,14 +2,14 @@ use <__comm__/__in_line.scad>; function _in_shape_in_line_equation(edge, pt) = let( - x1 = edge[0][0], - y1 = edge[0][1], - x2 = edge[1][0], - y2 = edge[1][1], + x1 = edge[0].x, + y1 = edge[0].y, + x2 = edge[1].x, + y2 = edge[1].y, a = (y2 - y1) / (x2 - x1), b = y1 - a * x1 ) - (pt[1] == a * pt[0] + b); + (pt.y == a * pt.x + b); function _in_shape_in_any_edges(edges, pt, epsilon) = let( @@ -19,13 +19,13 @@ function _in_shape_in_any_edges(edges, pt, epsilon) = is_undef(maybe_last); function _in_shape_interpolate_x(y, p1, p2) = - p1[1] == p2[1] ? p1[0] : ( - p1[0] + (p2[0] - p1[0]) * (y - p1[1]) / (p2[1] - p1[1]) + p1.y == p2.y ? p1.x : ( + p1.x + (p2.x - p1.x) * (y - p1.y) / (p2.y - p1.y) ); function _in_shape_does_pt_cross(pts, i, j, pt) = - ((pts[i][1] > pt[1]) != (pts[j][1] > pt[1])) && - (pt[0] < _in_shape_interpolate_x(pt[1], pts[i], pts[j])); + ((pts[i].y > pt.y) != (pts[j].y > pt.y)) && + (pt.x < _in_shape_interpolate_x(pt.y, pts[i], pts[j])); function _in_shape_sub(shapt_pts, leng, pt, cond, i, j) = diff --git a/src/_impl/_shape_liquid_splitting_impl.scad b/src/_impl/_shape_liquid_splitting_impl.scad index a3f5affb..ebee6a6f 100644 --- a/src/_impl/_shape_liquid_splitting_impl.scad +++ b/src/_impl/_shape_liquid_splitting_impl.scad @@ -16,9 +16,9 @@ function _liquid_splitting_pie_curve(radius, centre_dist, tangent_angle) = function _liquid_splitting_bezier(radius, centre_dist, tangent_angle, t_step, ctrl_p1) = let( ctrl_p = ptf_rotate([radius * tan(tangent_angle), -radius], tangent_angle), - ctrl_p2 = [-ctrl_p[0], ctrl_p[1]] + [centre_dist / 2, 0], - ctrl_p3 = [-ctrl_p2[0], ctrl_p2[1]], - ctrl_p4 = [-ctrl_p1[0], ctrl_p1[1]] + ctrl_p2 = [-ctrl_p.x, ctrl_p.y] + [centre_dist / 2, 0], + ctrl_p3 = [-ctrl_p2.x, ctrl_p2.y], + ctrl_p4 = [-ctrl_p1.x, ctrl_p1.y] ) bezier_curve( t_step, @@ -34,7 +34,7 @@ function _liquid_splitting_lower_half_curve(curve_pts, leng) = [ for(i = 0; i < leng; i = i + 1) let(p = curve_pts[leng - 1 - i]) - if(p[0] >= 0) p + if(p.x >= 0) p ]; function _liquid_splitting_half_liquid_splitting(radius, centre_dist, tangent_angle, t_step) = @@ -46,7 +46,7 @@ function _liquid_splitting_half_liquid_splitting(radius, centre_dist, tangent_an upper_curve_pts = [ for(i = 0; i < leng_half_curve_pts; i = i + 1) let(pt = lower_curve_pts[leng_half_curve_pts - 1 - i]) - [pt[0], -pt[1]] + [pt.x, -pt.y] ] ) concat( lower_curve_pts, @@ -61,6 +61,6 @@ function _shape_liquid_splitting_impl(radius, centre_dist, tangent_angle, t_step left_half_liquid_splittings = [ for(i = 0; i < leng_half_liquid_splittings; i = i + 1) let(pt = half_liquid_splittings[leng_half_liquid_splittings - 1 - i]) - [-pt[0], pt[1]] + [-pt.x, pt.y] ] ) concat(half_liquid_splittings, left_half_liquid_splittings); \ No newline at end of file diff --git a/src/_impl/_trim_shape_impl.scad b/src/_impl/_trim_shape_impl.scad index d04bf1cb..135d22cd 100644 --- a/src/_impl/_trim_shape_impl.scad +++ b/src/_impl/_trim_shape_impl.scad @@ -25,10 +25,10 @@ function _trim_sub(lines, leng, epsilon) = // no intersecting pt, collect current_p and trim remain lines inter_p == [] ? (concat([current_p], _trim_shape_trim_lines(lines_from_next, epsilon))) : ( // collect current_p, intersecting pt and the last pt - (leng == 3 || (inter_p[0] == (leng_lines_from_next2 - 1))) ? [current_p, inter_p[1], lines[leng - 1]] : ( + (leng == 3 || (inter_p.x == (leng_lines_from_next2 - 1))) ? [current_p, inter_p.y, lines[leng - 1]] : ( // collect current_p, intersecting pt and trim remain lines - concat([current_p, inter_p[1]], - _trim_shape_trim_lines([for(i = inter_p[0] + 1; i < leng_lines_from_next2; i = i + 1) lines_from_next2[i]], epsilon) + concat([current_p, inter_p.x], + _trim_shape_trim_lines([for(i = inter_p.x + 1; i < leng_lines_from_next2; i = i + 1) lines_from_next2[i]], epsilon) ) ) );