1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 22:28:16 +01:00

use built-in is_undef

This commit is contained in:
Justin Lin 2019-06-12 08:59:54 +08:00
parent bf0601eaef
commit 283b091c7c
9 changed files with 11 additions and 11 deletions

View File

@ -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
];

View File

@ -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])

View File

@ -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
);

View File

@ -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));
] : (is_undef(v) ? _xyz_rotation(a) : _q_rotation(a, v));

View File

@ -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

View File

@ -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);

View File

@ -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]))
);

View File

@ -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) : (

View File

@ -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) =