diff --git a/readme.md b/readme.md index 706bd9a..6421ff7 100644 --- a/readme.md +++ b/readme.md @@ -5798,6 +5798,7 @@ Global constants, functions and modules. This file is used directly or indirectl | ```inch(x)``` | Inch to mm conversion (For fractional inches, 'inch(1 + 7/8)' will work as expected.) | | ```m(x)``` | m to mm conversion | | ```mm(x)``` | Explicit mm specified | +| ```no_point(str)``` | Replace decimal point in string with 'p' | | ```r2sides(r)``` | Replicates the OpenSCAD logic to calculate the number of sides from the radius | | ```r2sides4n(r)``` | Round up the number of sides to a multiple of 4 to ensure points land on all axes | | ```sqr(x)``` | Returns the square of ```x``` | diff --git a/utils/core/global.scad b/utils/core/global.scad index 6563a85..b018de7 100644 --- a/utils/core/global.scad +++ b/utils/core/global.scad @@ -31,6 +31,7 @@ function m(x) = x * 1000.0; function sqr(x) = x * x; //! Returns the square of ```x``` function echoit(x) = echo(x) x; //! Echo expression and return it, useful for debugging +function no_point(str) = chr([for(c = str(str)) if(c == ".") ord("p") else ord(c)]);//! Replace decimal point in string with 'p' function in(list, x) = !!len([for(v = list) if(v == x) true]); //! Returns true if ```x``` is an element in the ```list``` function Len(x) = is_list(x) ? len(x) : 0; //! Returns the length of a list or 0 if ```x``` is not a list function r2sides(r) = $fn ? $fn : ceil(max(min(360/ $fa, r * 2 * PI / $fs), 5)); //! Replicates the OpenSCAD logic to calculate the number of sides from the radius diff --git a/vitamins/belt.scad b/vitamins/belt.scad index 415e916..01d3890 100644 --- a/vitamins/belt.scad +++ b/vitamins/belt.scad @@ -39,8 +39,6 @@ function belt_tooth_height(type) = type[4]; //! Tooth height function belt_pitch_height(type) = type[5] + belt_tooth_height(type); //! Offset of the pitch radius from the tips of the teeth function belt_pitch_to_back(type) = belt_thickness(type) - belt_pitch_height(type); //! Offset of the back from the pitch radius - -function no_point(str) = chr([for(c = str) if(c == ".") ord("p") else ord(c)]); // // We model the belt path at the pitch radius of the pulleys and the pitch line of the belt to get an accurate length. // The belt is then drawn by offseting each side from the pitch line.