-
Notifications
You must be signed in to change notification settings - Fork 16
Coordinates and units
- All coordinates are specified as (X,Y,Z). Z may be omitted when discussing 2D shapes.
- Boards are laid out with (0,0) at the center of the nose of the board, with the board extending towards the right (positive X.) So a 168cm board has the nose center at (0,0) and the tail center at (168,0).
- The Y axis is always the centerline of the board.
- There will be references to the "upper half" and "lower half" of the board. The upper half is the portion with positive Y and the lower half is the portion with negative Y.
Internally, all units are centimeters, period.
English and metric measurements may be mixed freely when talking and writing about MonkeyCAM, but as of v4.0.3 there are restrictions on the inputs and outputs:
- Board definitions (passed via
--board
) must all be in centimeters. - Machine definitions (passed via
--machine
) must all be in inches. - All G-Code outputs are in inches.
Issue https://github.com/mikemag/MonkeyCAM/issues/7 tracks improving the madness and allowing all of these to be options. Why the madness? Because the original author of MonkeyCAM, https://github.com/mikemag, learned machining in English units and really relates to thicknesses of materials in inches. And of course skis and snowboard dimensions are standardized on metric, thus a bit of a mix.
The double
datatype is rarely used in MonkeyCAM. When it is used it is for temporary, intermediate values only. They're most often encountered early on in input processing, and in some of the math around forming the basic geometry.
Instead, most points are specified by the type MCFixed
. This represents a fixed-point number with a scale factor chosen to be accurate enough for machining work while still leaving enough coordinate space for skis and snowboards. Most internal API's take MCFixed
values, a Point
is made up of MCFixed
values, etc.
All MCFixed
values represent centimeters.
A fixed-point value as the core of the coordinate system ensures that every point is snapped to a high-resolution grid. It removes the biggest source of variability and errors encountered with floating point math: rounding. It ensures that points which are "close enough" are actually the same point, enables accurate comparison between points, and limits error propagation at every conversion from a double
back to a MCFixed
.
Clipper also uses fixed-point values. Offsetting algorithms are almost impossible to get right without snapping points to a grid.
In most cases you won't notice MCFixed
. There are constructors which take int
and double
, so making one is easy. Most operators are overloaded so comparison and the usual math operations work normally.
Make a MCFixed
:
MCFixed x = 42; // x is 42cm.
To get a MCFixed
from English units:
MCFixed y = MCFixed::fromInches(42); // y is 106.68cm.
To go back to a double (avoid this whenever possible!!):
double d = y.dbl(); // d is 106.68.
To go to a printable string use str()
and inchesStr()
.
The MonkeyCAM Wiki is licensed under a Creative Commons Attribution 4.0 International License.