-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathkerf_util.ts
43 lines (38 loc) · 1.46 KB
/
kerf_util.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* Definition of kerf correction. It is a size correction necessary to obtain the desired
* tightness between elements. It is dependent on the laser type, focus, material type, desired
* tightness and other variables.
* See the calibrator in _calibration/kerf.ts_.
*/
export interface Kerf {
/** The distance (in units) by which each of two adjacent edges be moved towards each other. */
readonly oneSideInUnits: number;
}
/** Zero kerf, corresponding to a very loose connection. */
export const ZERO: Kerf = {oneSideInUnits: 0};
/**
* Creates kerf specified as the total relative displacement of the adjacent edges, in millimeters.
*/
export function millimeters(
inMillimeters: number,
{millimetersPerUnit}: {millimetersPerUnit: number},
) {
return oneSideMillimeters(inMillimeters / 2, {millimetersPerUnit});
}
/**
* Creates kerf specified as the displacement of one of a pair of adjacent edges, in millimeters.
*/
export function oneSideMillimeters(
oneSideMillimeters: number,
{millimetersPerUnit}: {millimetersPerUnit: number},
) {
return oneSideUnits(oneSideMillimeters / millimetersPerUnit);
}
/** Creates kerf specified as the total relative displacement of the adjacent edges, in units. */
export function units(inUnits: number) {
return oneSideUnits(inUnits / 2);
}
/** Creates kerf specified as the displacement of one of a pair of adjacent edges, in units. */
export function oneSideUnits(oneSideInUnits: number): Kerf {
return {oneSideInUnits};
}