omdl
v0.6.1
OpenSCAD Mechanical Design Library
|
Length units and conversions. More...
Files | |
file | units_length.scad |
Length units and conversions. | |
Functions | |
function | unit_length_name (u=base_unit_length, d=1, w=false) |
Return the name for a length unit identifier with dimension. More... | |
function | convert_length (v, from=base_unit_length, to=base_unit_length, d=1) |
Convert a value from from one units to another with dimensions. More... | |
Variables | |
base_unit_length = "mm" | |
<string> The base unit for length measurements. | |
Length units and conversions.
These functions allow for lengths to be specified with units. Lengths specified with units are independent of (base_unit_length). There are also unit conversion functions for converting from one unit to another.
The table below enumerates the supported units.
units id | description |
---|---|
pm | picometer |
nm | nanometer |
um | micrometer |
mm | millimeter |
cm | centimeter |
dm | decimeter |
m | meter |
km | kilometer |
thou, mil | thousandth of an inch |
in | inch |
ft | feet |
yd | yard |
mi | mile |
Example
Result (base_unit_length = mm):
Result (base_unit_length = cm):
Result (base_unit_length = mil):
Result (base_unit_length = in):
Example (equivalent lengths)
function convert_length | ( | v | , |
from | = base_unit_length , |
||
to | = base_unit_length , |
||
d | = 1 |
||
) |
Convert a value from from one units to another with dimensions.
v | <decimal> A value to convert. |
from | <string> The units of the value to be converted. |
to | <string> A units to which the value should be converted. |
d | <integer> A dimension. One of [1|2|3]. |
function unit_length_name | ( | u | = base_unit_length , |
d | = 1 , |
||
w | = false |
||
) |
Return the name for a length unit identifier with dimension.
w | <boolean> true for word and false for symbol format. |
u | <string> A length unit identifier. |
d | <integer> A dimension. One of [1|2|3]. |