revert scalar_vec3

This commit is contained in:
Adrian Mariano
2025-02-23 16:14:28 -05:00
parent 86455b1624
commit d6041f1878

View File

@@ -748,9 +748,9 @@ function get_radius(r1, r2, r, d1, d2, d, dflt) =
// same way that OpenSCAD expands short vectors in some contexts, e.g. cube(10) or rotate([45,90]). // same way that OpenSCAD expands short vectors in some contexts, e.g. cube(10) or rotate([45,90]).
// If `v` is a scalar, and `dflt==undef`, returns `[v, v, v]`. // If `v` is a scalar, and `dflt==undef`, returns `[v, v, v]`.
// If `v` is a scalar, and `dflt!=undef`, returns `[v, dflt, dflt]`. // If `v` is a scalar, and `dflt!=undef`, returns `[v, dflt, dflt]`.
// if `v` is a list of length 3 or more then reutnrs `v` // if `v` is a list of length 3 or more then returns `v`
// If `v` is a list and dflt is defined, returns a length 3 list by padding with `dflt` // If `v` is a list and dflt is defined, returns a length 3 list by padding with `dflt`
// If `v` is a list and dflt is undef, returns a length 3 list by padding with 0. // If `v` is a list and dflt is undef, returns a length 3 list by padding with 0
// If `v` is `undef`, returns `undef`. // If `v` is `undef`, returns `undef`.
// Arguments: // Arguments:
// v = Value to return vector from. // v = Value to return vector from.
@@ -763,13 +763,9 @@ function get_radius(r1, r2, r, d1, d2, d, dflt) =
// vec = scalar_vec3([10,10]); // Returns: [10,10,0] // vec = scalar_vec3([10,10]); // Returns: [10,10,0]
// vec = scalar_vec3([10]); // Returns: [10,0,0] // vec = scalar_vec3([10]); // Returns: [10,0,0]
function scalar_vec3(v, dflt) = function scalar_vec3(v, dflt) =
is_undef(v)? undef is_undef(v)? undef :
: is_list(v)? [for (i=[0:2]) default(v[i], default(dflt, 0))] :
is_list(v)? len(v)>=3 ? v !is_undef(dflt)? [v,dflt,dflt] : [v,v,v];
: [for (i=[0:2]) default(v[i], default(dflt, 0))]
:
!is_undef(dflt) ? [v,dflt,dflt]
: [v,v,v];
// Function: segs() // Function: segs()
// Synopsis: Returns the number of sides for a circle given `$fn`, `$fa`, and `$fs`. // Synopsis: Returns the number of sides for a circle given `$fn`, `$fa`, and `$fs`.