mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-13 18:24:28 +02:00
use __is_float
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
include <__private__/__frags.scad>;
|
include <__private__/__frags.scad>;
|
||||||
include <__private__/__is_vector.scad>;
|
include <__private__/__is_float.scad>;
|
||||||
include <__private__/__ra_to_xy.scad>;
|
include <__private__/__ra_to_xy.scad>;
|
||||||
include <__private__/__edge_r.scad>;
|
include <__private__/__edge_r.scad>;
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ function arc_path(radius, angle) =
|
|||||||
let(
|
let(
|
||||||
frags = __frags(radius),
|
frags = __frags(radius),
|
||||||
a_step = 360 / frags,
|
a_step = 360 / frags,
|
||||||
angles = __is_vector(angle) ? angle : [0, angle],
|
angles = __is_float(angle) ? [0, angle] : angle,
|
||||||
m = floor(angles[0] / a_step) + 1,
|
m = floor(angles[0] / a_step) + 1,
|
||||||
n = floor(angles[1] / a_step),
|
n = floor(angles[1] / a_step),
|
||||||
points = concat([__ra_to_xy(__edge_r_begin(radius, angles[0], a_step, m), angles[0])],
|
points = concat([__ra_to_xy(__edge_r_begin(radius, angles[0], a_step, m), angles[0])],
|
||||||
|
@@ -9,16 +9,17 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
include <__private__/__to3d.scad>;
|
include <__private__/__to3d.scad>;
|
||||||
include <__private__/__is_vector.scad>;
|
include <__private__/__is_float.scad>;
|
||||||
|
|
||||||
function cross_sections(shape_pts, path_pts, angles, twist = 0, scale = 1.0) =
|
function cross_sections(shape_pts, path_pts, angles, twist = 0, scale = 1.0) =
|
||||||
let(
|
let(
|
||||||
len_path_pts_minus_one = len(path_pts) - 1,
|
len_path_pts_minus_one = len(path_pts) - 1,
|
||||||
sh_pts = len(shape_pts[0]) == 3 ? shape_pts : [for(p = shape_pts) __to3d(p)],
|
sh_pts = len(shape_pts[0]) == 3 ? shape_pts : [for(p = shape_pts) __to3d(p)],
|
||||||
pth_pts = len(path_pts[0]) == 3 ? path_pts : [for(p = path_pts) __to3d(p)],
|
pth_pts = len(path_pts[0]) == 3 ? path_pts : [for(p = path_pts) __to3d(p)],
|
||||||
scale_step_vt = __is_vector(scale) ?
|
scale_step_vt = __is_float(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 - 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_x = scale_step_vt[0],
|
||||||
scale_step_y = scale_step_vt[1],
|
scale_step_y = scale_step_vt[1],
|
||||||
twist_step = twist / len_path_pts_minus_one
|
twist_step = twist / len_path_pts_minus_one
|
||||||
|
@@ -9,10 +9,10 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
include <__private__/__nearest_multiple_of_4.scad>;
|
include <__private__/__nearest_multiple_of_4.scad>;
|
||||||
include <__private__/__is_vector.scad>;
|
include <__private__/__is_float.scad>;
|
||||||
|
|
||||||
module crystal_ball(radius, theta = 360, phi = 180) {
|
module crystal_ball(radius, theta = 360, phi = 180) {
|
||||||
phis = __is_vector(phi) ? phi : [0, phi];
|
phis = __is_float(phi) ? [0, phi] : phi;
|
||||||
|
|
||||||
frags = __frags(radius);
|
frags = __frags(radius);
|
||||||
|
|
||||||
|
@@ -8,14 +8,14 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
include <__private__/__is_vector.scad>;
|
include <__private__/__is_float.scad>;
|
||||||
include <__private__/__frags.scad>;
|
include <__private__/__frags.scad>;
|
||||||
|
|
||||||
function helix(radius, levels, level_dist, vt_dir = "SPI_DOWN", rt_dir = "CT_CLK") =
|
function helix(radius, levels, level_dist, vt_dir = "SPI_DOWN", rt_dir = "CT_CLK") =
|
||||||
let(
|
let(
|
||||||
is_vt = __is_vector(radius),
|
is_flt = __is_float(radius),
|
||||||
r1 = is_vt ? radius[0] : radius,
|
r1 = is_flt ? radius : radius[0],
|
||||||
r2 = is_vt ? radius[1] : radius,
|
r2 = is_flt ? radius : radius[1],
|
||||||
init_r = vt_dir == "SPI_DOWN" ? r2 : r1,
|
init_r = vt_dir == "SPI_DOWN" ? r2 : r1,
|
||||||
_frags = __frags(init_r),
|
_frags = __frags(init_r),
|
||||||
h = level_dist * levels,
|
h = level_dist * levels,
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
include <__private__/__is_vector.scad>;
|
include <__private__/__is_float.scad>;
|
||||||
include <__private__/__frags.scad>;
|
include <__private__/__frags.scad>;
|
||||||
|
|
||||||
module helix_extrude(shape_pts, radius, levels, level_dist,
|
module helix_extrude(shape_pts, radius, levels, level_dist,
|
||||||
@@ -22,9 +22,9 @@ module helix_extrude(shape_pts, radius, levels, level_dist,
|
|||||||
vt[leng - 1 - i]
|
vt[leng - 1 - i]
|
||||||
];
|
];
|
||||||
|
|
||||||
is_vt = __is_vector(radius);
|
is_flt = __is_float(radius);
|
||||||
r1 = is_vt ? radius[0] : radius;
|
r1 = is_flt ? radius : radius[0];
|
||||||
r2 = is_vt ? radius[1] : radius;
|
r2 = is_flt ? radius : radius[1];
|
||||||
|
|
||||||
init_r = vt_dir == "SPI_DOWN" ? r2 : r1;
|
init_r = vt_dir == "SPI_DOWN" ? r2 : r1;
|
||||||
|
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
include <__private__/__is_vector.scad>;
|
include <__private__/__is_float.scad>;
|
||||||
include <__private__/__to3d.scad>;
|
include <__private__/__to3d.scad>;
|
||||||
include <__private__/__angy_angz.scad>;
|
include <__private__/__angy_angz.scad>;
|
||||||
|
|
||||||
@@ -39,12 +39,13 @@ module path_extrude(shape_pts, path_pts, triangles = "SOLID", twist = 0, scale =
|
|||||||
let(s = (scale - 1) / len_path_pts_minus_one)
|
let(s = (scale - 1) / len_path_pts_minus_one)
|
||||||
[s, s, s];
|
[s, s, s];
|
||||||
|
|
||||||
scale_step_vt = __is_vector(scale) ?
|
scale_step_vt = __is_float(scale) ?
|
||||||
|
scale_step() :
|
||||||
[
|
[
|
||||||
(scale[0] - 1) / len_path_pts_minus_one,
|
(scale[0] - 1) / len_path_pts_minus_one,
|
||||||
(scale[1] - 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
|
scale[2] == undef ? 0 : (scale[2] - 1) / len_path_pts_minus_one
|
||||||
] : scale_step();
|
];
|
||||||
|
|
||||||
// get rotation matrice for sections
|
// get rotation matrice for sections
|
||||||
|
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
include <__private__/__frags.scad>;
|
include <__private__/__frags.scad>;
|
||||||
include <__private__/__is_vector.scad>;
|
include <__private__/__is_float.scad>;
|
||||||
include <__private__/__ra_to_xy.scad>;
|
include <__private__/__ra_to_xy.scad>;
|
||||||
include <__private__/__shape_pie.scad>;
|
include <__private__/__shape_pie.scad>;
|
||||||
|
|
||||||
|
@@ -19,7 +19,7 @@ module ring_extrude(shape_pts, radius, angle = 360, twist = 0, scale = 1.0, tria
|
|||||||
} else {
|
} else {
|
||||||
a_step = 360 / __frags(radius);
|
a_step = 360 / __frags(radius);
|
||||||
|
|
||||||
angles = __is_vector(angle) ? angle : [0, angle];
|
angles = __is_float(angle) ? [0, angle] : angle;
|
||||||
|
|
||||||
m = floor(angles[0] / a_step) + 1;
|
m = floor(angles[0] / a_step) + 1;
|
||||||
n = floor(angles[1] / a_step);
|
n = floor(angles[1] / a_step);
|
||||||
|
@@ -8,15 +8,15 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
include <__private__/__is_vector.scad>;
|
include <__private__/__is_float.scad>;
|
||||||
include <__private__/__frags.scad>;
|
include <__private__/__frags.scad>;
|
||||||
include <__private__/__nearest_multiple_of_4.scad>;
|
include <__private__/__nearest_multiple_of_4.scad>;
|
||||||
|
|
||||||
module rounded_cube(size, corner_r, center = false) {
|
module rounded_cube(size, corner_r, center = false) {
|
||||||
is_vt = __is_vector(size);
|
is_flt = __is_float(size);
|
||||||
x = is_vt ? size[0] : size;
|
x = is_flt ? size : size[0];
|
||||||
y = is_vt ? size[1] : size;
|
y = is_flt ? size : size[1];
|
||||||
z = is_vt ? size[2] : size;
|
z = is_flt ? size : size[2];
|
||||||
|
|
||||||
corner_frags = __nearest_multiple_of_4(__frags(corner_r));
|
corner_frags = __nearest_multiple_of_4(__frags(corner_r));
|
||||||
edge_d = corner_r * cos(180 / corner_frags);
|
edge_d = corner_r * cos(180 / corner_frags);
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
include <__private__/__is_vector.scad>;
|
include <__private__/__is_float.scad>;
|
||||||
include <__private__/__frags.scad>;
|
include <__private__/__frags.scad>;
|
||||||
include <__private__/__pie_for_rounding.scad>;
|
include <__private__/__pie_for_rounding.scad>;
|
||||||
include <__private__/__half_trapezium.scad>;
|
include <__private__/__half_trapezium.scad>;
|
||||||
|
@@ -9,13 +9,13 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
include <__private__/__frags.scad>;
|
include <__private__/__frags.scad>;
|
||||||
include <__private__/__is_vector.scad>;
|
include <__private__/__is_float.scad>;
|
||||||
|
|
||||||
module rounded_extrude(size, round_r, angle = 90, twist = 0, convexity = 10) {
|
module rounded_extrude(size, round_r, angle = 90, twist = 0, convexity = 10) {
|
||||||
|
|
||||||
is_vt = __is_vector(size);
|
is_flt = __is_float(size);
|
||||||
x = is_vt ? size[0] : size;
|
x = is_flt ? size : size[0];
|
||||||
y = is_vt ? size[1] : size;
|
y = is_flt ? size : size[1];
|
||||||
|
|
||||||
q_corner_frags = __frags(round_r) / 4;
|
q_corner_frags = __frags(round_r) / 4;
|
||||||
|
|
||||||
|
@@ -8,16 +8,16 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
include <__private__/__is_vector.scad>;
|
include <__private__/__is_float.scad>;
|
||||||
include <__private__/__frags.scad>;
|
include <__private__/__frags.scad>;
|
||||||
include <__private__/__pie_for_rounding.scad>;
|
include <__private__/__pie_for_rounding.scad>;
|
||||||
include <__private__/__half_trapezium.scad>;
|
include <__private__/__half_trapezium.scad>;
|
||||||
include <__private__/__trapezium.scad>;
|
include <__private__/__trapezium.scad>;
|
||||||
|
|
||||||
module rounded_square(size, corner_r, center = false) {
|
module rounded_square(size, corner_r, center = false) {
|
||||||
is_vt = __is_vector(size);
|
is_flt = __is_float(size);
|
||||||
x = is_vt ? size[0] : size;
|
x = is_flt ? size : size[0];
|
||||||
y = is_vt ? size[1] : size;
|
y = is_flt ? size : size[1];
|
||||||
|
|
||||||
position = center ? [0, 0] : [x / 2, y / 2];
|
position = center ? [0, 0] : [x / 2, y / 2];
|
||||||
points = __trapezium(
|
points = __trapezium(
|
||||||
|
Reference in New Issue
Block a user