Previously, MCAD libraries that dealt with absolutely-sized
artifacts (for example, nuts_and_bolts.scad) either implicitly worked in
millimeters or used a set of multiplicative constants defined in
units.scad (and one constant in constants.scad).
This change introduces a set of scaled functions in units.scad that help
creating objects that are specified in mixed dimensions:
These functions convert from the indicated quantity to OpenSCAD's
internal units. By default, they are set up so that
1 /*OpenSCAD unit*/ == mm(1),
but, this can be switched by setting the variable MCAD_BASE_UNIT before
including units.scad. MCAD_BASE_UNIT is a multiplicative scale factor
that determines the correspondence between MCAD millimeters and OpenSCAD
units. For example:
// a.scad
include <MCAD/units.scad>
echo(cm(1)); // Outputs 10
// b.scad
include <MCAD/units.scad>
MCAD_BASE_UNIT = MCAD_BASE_UNIT_CM;
echo(cm(1)); // Outputs 1
Every place in MCAD that was previously using the scale constants from
units.scad and constants.scad has been converted to use the new scale
functions, including the definition of MCAD_EPSILON (now 0.01 mm).
The scale constants have been kept for backwards-compatibility, but are
now defined in terms of the scale functions.
A small suite of tests has been added in the test/ subdirectory of the
project root. The test suite can be invoked using make test from the
top project directory.
If you want to omit the tests or translate them into the python testing
framework, that's fine.
Previously, MCAD libraries that dealt with absolutely-sized artifacts (for example, nuts_and_bolts.scad) either implicitly worked in millimeters or used a set of multiplicative constants defined in units.scad (and one constant in constants.scad).
This change introduces a set of scaled functions in units.scad that help creating objects that are specified in mixed dimensions:
These functions convert from the indicated quantity to OpenSCAD's internal units. By default, they are set up so that
but, this can be switched by setting the variable MCAD_BASE_UNIT before including units.scad. MCAD_BASE_UNIT is a multiplicative scale factor that determines the correspondence between MCAD millimeters and OpenSCAD units. For example:
Every place in MCAD that was previously using the scale constants from units.scad and constants.scad has been converted to use the new scale functions, including the definition of MCAD_EPSILON (now 0.01 mm).
The scale constants have been kept for backwards-compatibility, but are now defined in terms of the scale functions.
A small suite of tests has been added in the test/ subdirectory of the project root. The test suite can be invoked using
make test
from the top project directory.If you want to omit the tests or translate them into the python testing framework, that's fine.