From 283b091c7c2fbe9f603f3c7cafccc76ac243e53b Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Wed, 12 Jun 2019 08:59:54 +0800 Subject: [PATCH] use built-in is_undef --- src/along_with.scad | 4 ++-- src/circle_path.scad | 2 +- src/ellipse_extrude.scad | 2 +- src/m_rotation.scad | 2 +- src/path_extrude.scad | 2 +- src/rotate_p.scad | 2 +- src/sub_str.scad | 2 +- src/turtle2d.scad | 2 +- src/turtle3d.scad | 4 ++-- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/along_with.scad b/src/along_with.scad index b040f257..2a014975 100644 --- a/src/along_with.scad +++ b/src/along_with.scad @@ -20,14 +20,14 @@ module along_with(points, angles, twist = 0, scale = 1.0, method = "AXIS_ANGLE") leng_points_minus_one = leng_points - 1; twist_step_a = twist / leng_points; - angles_defined = angles != undef; + angles_defined = !is_undef(angles); scale_step_vt = is_num(scale) ? scale_step() : [ (scale[0] - 1) / leng_points_minus_one, (scale[1] - 1) / leng_points_minus_one, - scale[2] == undef ? 0 : (scale[2] - 1) / leng_points_minus_one + is_undef(scale[2]) ? 0 : (scale[2] - 1) / leng_points_minus_one ]; diff --git a/src/circle_path.scad b/src/circle_path.scad index b8e5f543..b1950268 100644 --- a/src/circle_path.scad +++ b/src/circle_path.scad @@ -14,7 +14,7 @@ function circle_path(radius, n) = let( _frags = __frags(radius), step_a = 360 / _frags, - end_a = 360 - step_a * ((n == undef || n > _frags) ? 1 : _frags - n + 1) + end_a = 360 - step_a * ((is_undef(n) || n > _frags) ? 1 : _frags - n + 1) ) [ for(a = [0 : step_a : end_a]) diff --git a/src/ellipse_extrude.scad b/src/ellipse_extrude.scad index 8d81b297..953f78a5 100644 --- a/src/ellipse_extrude.scad +++ b/src/ellipse_extrude.scad @@ -9,7 +9,7 @@ **/ module ellipse_extrude(semi_minor_axis, height, center = false, convexity = 10, twist = 0, slices = 20) { - h = height == undef ? semi_minor_axis : ( + h = is_undef(height) ? semi_minor_axis : ( // `semi_minor_axis` is always equal to or greater than `height`. height > semi_minor_axis ? semi_minor_axis : height ); diff --git a/src/m_rotation.scad b/src/m_rotation.scad index d755f3c8..37a7b166 100644 --- a/src/m_rotation.scad +++ b/src/m_rotation.scad @@ -78,4 +78,4 @@ function m_rotation(a, v) = [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1] - ] : (v == undef ? _xyz_rotation(a) : _q_rotation(a, v)); \ No newline at end of file + ] : (is_undef(v) ? _xyz_rotation(a) : _q_rotation(a, v)); \ No newline at end of file diff --git a/src/path_extrude.scad b/src/path_extrude.scad index edd0af39..2213383f 100644 --- a/src/path_extrude.scad +++ b/src/path_extrude.scad @@ -45,7 +45,7 @@ module path_extrude(shape_pts, path_pts, triangles = "SOLID", twist = 0, scale = [ (scale[0] - 1) / len_path_pts_minus_one, (scale[1] - 1) / len_path_pts_minus_one, - scale[2] == undef ? 0 : (scale[2] - 1) / len_path_pts_minus_one + is_undef(scale[2]) ? 0 : (scale[2] - 1) / len_path_pts_minus_one ]; // get rotation matrice for sections diff --git a/src/rotate_p.scad b/src/rotate_p.scad index d1233aea..ac43cc17 100644 --- a/src/rotate_p.scad +++ b/src/rotate_p.scad @@ -86,4 +86,4 @@ function _q_rotate_p(p, a, v) = ); function rotate_p(point, a, v) = - v == undef ? _rotate_p(point, a) : _q_rotate_p(point, a, v); + is_undef(v) ? _rotate_p(point, a) : _q_rotate_p(point, a, v); diff --git a/src/sub_str.scad b/src/sub_str.scad index 3df9ca87..d849b9d1 100644 --- a/src/sub_str.scad +++ b/src/sub_str.scad @@ -9,7 +9,7 @@ **/ function sub_str(t, begin, end, result = "") = - end == undef ? sub_str(t, begin, len(t)) : ( + is_undef(end) ? sub_str(t, begin, len(t)) : ( begin == end ? result : sub_str(t, begin + 1, end, str(result, t[begin])) ); \ No newline at end of file diff --git a/src/turtle2d.scad b/src/turtle2d.scad index 5ab77606..0c55f8cb 100644 --- a/src/turtle2d.scad +++ b/src/turtle2d.scad @@ -34,7 +34,7 @@ function _turtle2d_three_args_command(cmd, arg1, arg2, arg3) = cmd == "create" ? _turtle2d_turtle(arg1, arg2, arg3) : _turtle2d_two_args_command(cmd, arg1, arg2); function _turtle2d_two_args_command(cmd, arg1, arg2) = - arg2 == undef ? _turtle2d_one_arg_command(cmd, arg1) : ( + is_undef(arg2) ? _turtle2d_one_arg_command(cmd, arg1) : ( cmd == "pt" ? _turtle2d_set_point(arg1, arg2) : ( cmd == "x" ? _turtle2d_set_x(arg1, arg2) : ( cmd == "y" ? _turtle2d_set_y(arg1, arg2) : ( diff --git a/src/turtle3d.scad b/src/turtle3d.scad index c93448ed..bc89fedd 100644 --- a/src/turtle3d.scad +++ b/src/turtle3d.scad @@ -122,8 +122,8 @@ function _turtle3d_zu_turn(turtle, a) = ); function _turtle3d_create_cmd(arg1, arg2) = - (arg1 == undef && arg2 == undef) ? _turtle3d_create_default() : ( - (arg1 != undef && arg2 != undef) ? _turtle3d_create(arg1, arg2) : undef + (is_undef(arg1) && is_undef(arg2)) ? _turtle3d_create_default() : ( + (!is_undef(arg1) && !is_undef(arg2)) ? _turtle3d_create(arg1, arg2) : undef ); function _turtle3d_chain_move(cmd, arg1, arg2) =