Added more imperial and metric units as requested.

This commit is contained in:
Chris Palmer 2019-06-27 11:10:37 +01:00
parent fbc0b1d27d
commit e386ce7927
3 changed files with 13 additions and 4 deletions

View File

@ -28,7 +28,6 @@ include <../vitamins/inserts.scad>
foot = [25, 12, 3, 2, M4_cap_screw, 10];
insert_foot = [20, 10, 0, 2, M3_cap_screw, 10];
function foot() = foot; //! Default foot used unless a list of parameters is passed
function insert_foot() = insert_foot; //! Default foot with insert
function foot_diameter(type = foot) = type[0]; //! Outside maximum diameter

View File

@ -3410,7 +3410,6 @@ inserts don't grip well in rubber.
### Functions
| Function | Description |
|:--- |:--- |
| ```foot()``` | Default foot used unless a list of parameters is passed |
| ```insert_foot()``` | Default foot with insert |
### Modules
@ -4220,12 +4219,17 @@ Global constants, functions and modules. This file is used directly or indirectl
| Function | Description |
|:--- |:--- |
| ```Len(x)``` | Returns the length of a list or 0 if ```x``` is not a list |
| ```cm(x)``` | cm to mm conversion |
| ```echoit(x)``` | Echo expression and return it, useful for debugging |
| ```foot(x)``` | Foot to mm conversion |
| ```in(list, x)``` | Returns true if ```x``` is an element in the ```list``` |
| ```inch(x)``` | Inch to mm conversion |
| ```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 |
| ```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``` |
| ```yard(x)``` | Yard to mm conversion |
### Modules
| Module | Description |

View File

@ -22,8 +22,14 @@
//
include <../../global_defs.scad>
function inch(x) = x * 25.4; //! Inch to mm conversion (For fractional inches, 'inch(1 + 7/8)' will work as expected.)
function foot(x) = x * 25.4 * 12; //! Foot to mm conversion
function yard(x) = x * 25.4 * 12 * 3; //! Yard to mm conversion
function mm(x) = x; //! Explicit mm specified
function cm(x) = x * 10.0; //! cm to mm conversion
function m(x) = x * 1000.0; //! m to mm conversion
function sqr(x) = x * x; //! Returns the square of ```x```
function inch(x) = x * 25.4; //! Inch to mm conversion
function echoit(x) = echo(x) x; //! Echo expression and return it, useful for debugging
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