1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-11 17:24:20 +02:00

refactored

This commit is contained in:
Justin Lin
2017-05-07 10:13:14 +08:00
parent f903a11192
commit 5d30d8f688
7 changed files with 25 additions and 12 deletions

View File

@@ -0,0 +1 @@
function __is_vector(value) = !(value >= "") && len(value) != undef;

View File

@@ -11,12 +11,14 @@
*
**/
include <__private__/__is_vector.scad>;
function cross_sections(shape_pts, path_pts, angles, twist = 0, scale = 1.0) =
let(
len_path_pts_minus_one = len(path_pts) - 1,
sh_pts = len(shape_pts[0]) == 3 ? shape_pts : [for(p = shape_pts) [p[0], p[1], 0]],
pth_pts = len(path_pts[0]) == 3 ? path_pts : [for(p = path_pts) [p[0], p[1], 0]],
scale_step_vt = len(scale) == 2 ?
scale_step_vt = __is_vector(scale) ?
[(scale[0] - 1) / len_path_pts_minus_one, (scale[1] - 1) / len_path_pts_minus_one] :
[(scale - 1) / len_path_pts_minus_one, (scale - 1) / len_path_pts_minus_one],
scale_step_x = scale_step_vt[0],

View File

@@ -12,12 +12,14 @@
*
**/
include <__private__/__is_vector.scad>;
include <__private__/__frags.scad>;
function helix(radius, levels, level_dist, vt_dir = "SPI_DOWN", rt_dir = "CT_CLK") =
let(
r1 = len(radius) == undef ? radius : radius[0],
r2 = len(radius) == undef ? radius : radius[1],
is_vt = __is_vector(radius),
r1 = is_vt ? radius[0] : radius,
r2 = is_vt ? radius[1] : radius,
init_r = vt_dir == "SPI_DOWN" ? r2 : r1,
_frags = __frags(init_r),
h = level_dist * levels,

View File

@@ -10,14 +10,16 @@
*
**/
include <__private__/__is_vector.scad>;
include <__private__/__frags.scad>;
module helix_extrude(shape_pts, radius, levels, level_dist,
vt_dir = "SPI_DOWN", rt_dir = "CT_CLK",
twist = 0, scale = 1.0, triangles = "RADIAL") {
r1 = len(radius) == undef ? radius : radius[0];
r2 = len(radius) == undef ? radius : radius[1];
is_vt = __is_vector(radius);
r1 = is_vt ? radius[0] : radius;
r2 = is_vt ? radius[1] : radius;
init_r = vt_dir == "SPI_DOWN" ? r2 : r1;

View File

@@ -13,6 +13,8 @@
*
**/
include <__private__/__is_vector.scad>;
module path_extrude(shape_pts, path_pts, triangles = "RADIAL", twist = 0, scale = 1.0, closed = false) {
s_pts = to3d(shape_pts);
@@ -21,7 +23,7 @@ module path_extrude(shape_pts, path_pts, triangles = "RADIAL", twist = 0, scale
len_path_pts = len(pth_pts);
len_path_pts_minus_one = len_path_pts - 1;
scale_step_vt = len(scale) == 2 ?
scale_step_vt = __is_vector(scale) ?
[(scale[0] - 1) / len_path_pts_minus_one, (scale[1] - 1) / len_path_pts_minus_one] :
[(scale - 1) / len_path_pts_minus_one, (scale - 1) / len_path_pts_minus_one];

View File

@@ -11,12 +11,14 @@
*
**/
include <__private__/__is_vector.scad>;
include <__private__/__frags.scad>;
module rounded_cube(size, corner_r, center = false) {
x = len(size) == undef ? size : size[0];
y = len(size) == undef ? size : size[1];
z = len(size) == undef ? size : size[2];
is_vt = __is_vector(size);
x = is_vt ? size[0] : size;
y = is_vt ? size[1] : size;
z = is_vt ? size[2] : size;
frags = __frags(corner_r);

View File

@@ -11,6 +11,7 @@
*
**/
include <__private__/__is_vector.scad>;
include <__private__/__frags.scad>;
module rounded_square(size, corner_r, center = false) {
@@ -21,8 +22,9 @@ module rounded_square(size, corner_r, center = false) {
step_a = 360 / corner_frags;
x = len(size) == undef ? size : size[0];
y = len(size) == undef ? size : size[1];
is_vt = __is_vector(size);
x = is_vt ? size[0] : size;
y = is_vt ? size[1] : size;
half_x = x / 2;
half_y = y / 2;