mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +00:00
refine arg validation of get_radius
It is assumed that args r and d in get_radius can be a finite number or a vector with dimension 1 or 2.
This commit is contained in:
parent
2efd0ca5d0
commit
2b12659d00
1 changed files with 22 additions and 7 deletions
29
common.scad
29
common.scad
|
@ -289,13 +289,28 @@ function get_anchor(anchor,center,uncentered=BOT,dflt=CENTER) =
|
|||
// d = Most general diameter.
|
||||
// dflt = Value to return if all other values given are `undef`.
|
||||
function get_radius(r1=undef, r2=undef, r=undef, d1=undef, d2=undef, d=undef, dflt=undef) = (
|
||||
!is_undef(r1)? assert(is_undef(r2)&&is_undef(d1)&&is_undef(d2), "Conflicting or redundant radius/diameter arguments given.") r1 :
|
||||
!is_undef(r2)? assert(is_undef(d1)&&is_undef(d2), "Conflicting or redundant radius/diameter arguments given.") r2 :
|
||||
!is_undef(d1)? d1/2 :
|
||||
!is_undef(d2)? d2/2 :
|
||||
!is_undef(r)? assert(is_undef(d), "Conflicting or redundant radius/diameter arguments given.") r :
|
||||
!is_undef(d)? d/2 :
|
||||
dflt
|
||||
!is_undef(r1)
|
||||
? assert(is_undef(r2)&&is_undef(d1)&&is_undef(d2), "Conflicting or redundant radius/diameter arguments given.")
|
||||
assert(is_finite(r1), "Invalid radius r1." )
|
||||
r1
|
||||
: !is_undef(r2)
|
||||
? assert(is_undef(d1)&&is_undef(d2), "Conflicting or redundant radius/diameter arguments given.")
|
||||
assert(is_finite(r2), "Invalid radius r2." )
|
||||
r2
|
||||
: !is_undef(d1)
|
||||
? assert(is_finite(d1), "Invalid diameter d1." )
|
||||
d1/2
|
||||
: !is_undef(d2)
|
||||
? assert(is_finite(d2), "Invalid diameter d2." )
|
||||
d2/2
|
||||
: !is_undef(r)
|
||||
? assert(is_undef(d), "Conflicting or redundant radius/diameter arguments given.")
|
||||
assert(is_finite(r) || is_vector(r,1) || is_vector(r,2), "Invalid radius r." )
|
||||
r
|
||||
: !is_undef(d)
|
||||
? assert(is_finite(d) || is_vector(d,1) || is_vector(d,2), "Invalid diameter d." )
|
||||
d/2
|
||||
: dflt
|
||||
);
|
||||
|
||||
// Function: get_height()
|
||||
|
|
Loading…
Reference in a new issue