@guillaume-docquier/tools-ts 6.4.1 → 6.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -3
- package/dist/entry.tools-ts.d.ts +4 -0
- package/dist/entry.tools-ts.js +4 -0
- package/dist/entry.tools-ts.js.map +1 -1
- package/dist/measurements/Angle.d.ts +30 -0
- package/dist/measurements/Angle.js +43 -0
- package/dist/measurements/Angle.js.map +1 -0
- package/dist/measurements/Distance.d.ts +61 -0
- package/dist/measurements/Distance.js +95 -0
- package/dist/measurements/Distance.js.map +1 -0
- package/dist/measurements/Point2D.d.ts +34 -0
- package/dist/measurements/Point2D.js +51 -0
- package/dist/measurements/Point2D.js.map +1 -0
- package/dist/measurements/Point3D.d.ts +49 -0
- package/dist/measurements/Point3D.js +66 -0
- package/dist/measurements/Point3D.js.map +1 -0
- package/dist/measurements/Time.d.ts +4 -4
- package/dist/measurements/Time.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -122,9 +122,13 @@ Use these helpers for quick profiling.
|
|
|
122
122
|
|
|
123
123
|
### Measurements
|
|
124
124
|
|
|
125
|
-
| Export
|
|
126
|
-
|
|
|
127
|
-
| `
|
|
125
|
+
| Export | What it is | Use it when |
|
|
126
|
+
| ---------------------------- | --------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
|
|
127
|
+
| `Angle`, `UnitOfAngle` | An angle measurement and its supported degree and radian units. | You need to represent angles and convert between degrees and radians. |
|
|
128
|
+
| `Time`, `UnitOfTime` | A time measurement and its supported units, with conversion and arithmetic tools. | You need unit-aware durations or calculations across different time units. |
|
|
129
|
+
| `Distance`, `UnitOfDistance` | A distance measurement and its supported units, with conversion and comparison. | You need unit-aware lengths, spatial comparisons, or distances between points. |
|
|
130
|
+
| `Point2D`, `XY` | A two-dimensional position and its plain coordinate-value shape. | You need 2D positions whose axes can use and convert between distance units. |
|
|
131
|
+
| `Point3D`, `XYZ` | A three-dimensional position and its plain coordinate-value shape. | You need 3D positions whose axes can use and convert between distance units. |
|
|
128
132
|
|
|
129
133
|
### Date manipulations
|
|
130
134
|
|
package/dist/entry.tools-ts.d.ts
CHANGED
|
@@ -28,6 +28,10 @@ export { Sort } from "./Sort.js";
|
|
|
28
28
|
export { createRng, type Rng, type Generator } from "./rng/rng.js";
|
|
29
29
|
export { mulberry32Prng } from "./rng/mulberry32prng.js";
|
|
30
30
|
export { Datetime } from "./Datetime.js";
|
|
31
|
+
export { Angle, UnitOfAngle } from "./measurements/Angle.js";
|
|
31
32
|
export { Time, UnitOfTime } from "./measurements/Time.js";
|
|
33
|
+
export { Distance, UnitOfDistance } from "./measurements/Distance.js";
|
|
34
|
+
export { Point2D, type XY } from "./measurements/Point2D.js";
|
|
35
|
+
export { Point3D, type XYZ } from "./measurements/Point3D.js";
|
|
32
36
|
export { Timer } from "./Timer.js";
|
|
33
37
|
export { type Branded, branded } from "./Brand.js";
|
package/dist/entry.tools-ts.js
CHANGED
|
@@ -23,7 +23,11 @@ export { Sort } from "./Sort.js";
|
|
|
23
23
|
export { createRng } from "./rng/rng.js";
|
|
24
24
|
export { mulberry32Prng } from "./rng/mulberry32prng.js";
|
|
25
25
|
export { Datetime } from "./Datetime.js";
|
|
26
|
+
export { Angle, UnitOfAngle } from "./measurements/Angle.js";
|
|
26
27
|
export { Time, UnitOfTime } from "./measurements/Time.js";
|
|
28
|
+
export { Distance, UnitOfDistance } from "./measurements/Distance.js";
|
|
29
|
+
export { Point2D } from "./measurements/Point2D.js";
|
|
30
|
+
export { Point3D } from "./measurements/Point3D.js";
|
|
27
31
|
export { Timer } from "./Timer.js";
|
|
28
32
|
export { branded } from "./Brand.js";
|
|
29
33
|
//# sourceMappingURL=entry.tools-ts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.tools-ts.js","sourceRoot":"","sources":["../src/entry.tools-ts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MA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A;AAEtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAA;AAKvE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,SAAS,EAA4B,MAAM,cAAc,CAAA;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AACrE,OAAO,EAAE,OAAO,EAAW,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,OAAO,EAAY,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAgB,OAAO,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Measurement } from "./Measurement.js";
|
|
2
|
+
/**
|
|
3
|
+
* Represents the possible units to define an angle.
|
|
4
|
+
*/
|
|
5
|
+
export declare enum UnitOfAngle {
|
|
6
|
+
DEGREES = "degrees",
|
|
7
|
+
RADIANS = "radians"
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Represents an angle with its unit.
|
|
11
|
+
*/
|
|
12
|
+
export type Angle = Measurement<UnitOfAngle>;
|
|
13
|
+
/**
|
|
14
|
+
* A set of functions to work with angles.
|
|
15
|
+
*/
|
|
16
|
+
export declare const Angle: {
|
|
17
|
+
/**
|
|
18
|
+
* Creates an angle.
|
|
19
|
+
*/
|
|
20
|
+
create(value: number, unit: UnitOfAngle): Angle;
|
|
21
|
+
/**
|
|
22
|
+
* Converts an angle to another unit.
|
|
23
|
+
* The provided angle is left untouched.
|
|
24
|
+
*/
|
|
25
|
+
convert(angle: Readonly<Angle>, newUnit: UnitOfAngle): Angle;
|
|
26
|
+
/**
|
|
27
|
+
* Returns the value of the angle in the given unit.
|
|
28
|
+
*/
|
|
29
|
+
in({ value, unit }: Readonly<Angle>, newUnit: UnitOfAngle): number;
|
|
30
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the possible units to define an angle.
|
|
3
|
+
*/
|
|
4
|
+
export var UnitOfAngle;
|
|
5
|
+
(function (UnitOfAngle) {
|
|
6
|
+
UnitOfAngle["DEGREES"] = "degrees";
|
|
7
|
+
UnitOfAngle["RADIANS"] = "radians";
|
|
8
|
+
})(UnitOfAngle || (UnitOfAngle = {}));
|
|
9
|
+
const RADIANS_PER_ANGLE = {
|
|
10
|
+
[UnitOfAngle.DEGREES]: Math.PI / 180,
|
|
11
|
+
[UnitOfAngle.RADIANS]: 1,
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* A set of functions to work with angles.
|
|
15
|
+
*/
|
|
16
|
+
export const Angle = {
|
|
17
|
+
/**
|
|
18
|
+
* Creates an angle.
|
|
19
|
+
*/
|
|
20
|
+
create(value, unit) {
|
|
21
|
+
return { value, unit };
|
|
22
|
+
},
|
|
23
|
+
/**
|
|
24
|
+
* Converts an angle to another unit.
|
|
25
|
+
* The provided angle is left untouched.
|
|
26
|
+
*/
|
|
27
|
+
convert(angle, newUnit) {
|
|
28
|
+
return {
|
|
29
|
+
value: Angle.in(angle, newUnit),
|
|
30
|
+
unit: newUnit,
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
/**
|
|
34
|
+
* Returns the value of the angle in the given unit.
|
|
35
|
+
*/
|
|
36
|
+
in({ value, unit }, newUnit) {
|
|
37
|
+
if (unit === newUnit) {
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
return (value * RADIANS_PER_ANGLE[unit]) / RADIANS_PER_ANGLE[newUnit];
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=Angle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Angle.js","sourceRoot":"","sources":["../../src/measurements/Angle.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAN,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,kCAAmB,CAAA;IACnB,kCAAmB,CAAA;AACrB,CAAC,EAHW,WAAW,KAAX,WAAW,QAGtB;AAED,MAAM,iBAAiB,GAAgC;IACrD,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG;IACpC,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;CACzB,CAAA;AAOD;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB;;OAEG;IACH,MAAM,CAAC,KAAa,EAAE,IAAiB;QACrC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAA;IACxB,CAAC;IAED;;;OAGG;IACH,OAAO,CAAC,KAAsB,EAAE,OAAoB;QAClD,OAAO;YACL,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC;YAC/B,IAAI,EAAE,OAAO;SACd,CAAA;IACH,CAAC;IAED;;OAEG;IACH,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,EAAmB,EAAE,OAAoB;QACvD,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;YACrB,OAAO,KAAK,CAAA;QACd,CAAC;QAED,OAAO,CAAC,KAAK,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAA;IACvE,CAAC;CACF,CAAA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { Measurement } from "./Measurement.js";
|
|
2
|
+
import { Point3D } from "./Point3D.js";
|
|
3
|
+
export declare enum UnitOfDistance {
|
|
4
|
+
METERS = "Meters",
|
|
5
|
+
MILLIMETERS = "Millimeters",
|
|
6
|
+
ASTRONOMICAL_UNITS = "Astronomical Units",
|
|
7
|
+
LIGHT_YEARS = "Light Years"
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Represents a distance with its unit
|
|
11
|
+
*/
|
|
12
|
+
export type Distance = Measurement<UnitOfDistance>;
|
|
13
|
+
/**
|
|
14
|
+
* A set of functions to work with Distances.
|
|
15
|
+
*/
|
|
16
|
+
export declare const Distance: {
|
|
17
|
+
/**
|
|
18
|
+
* Creates a distance.
|
|
19
|
+
* @param value The value for the distance.
|
|
20
|
+
* @param unit The unit for the distance.
|
|
21
|
+
*/
|
|
22
|
+
create(value: number, unit: UnitOfDistance): Distance;
|
|
23
|
+
/**
|
|
24
|
+
* Converts a distance to another unit of distance.
|
|
25
|
+
* The provided distance is left untouched.
|
|
26
|
+
* @param distance The distance to convert.
|
|
27
|
+
* @param newUnit The unit to convert to.
|
|
28
|
+
* @returns A new Distance with the requested unit of distance.
|
|
29
|
+
*/
|
|
30
|
+
convert(distance: Readonly<Distance>, newUnit: UnitOfDistance): Distance;
|
|
31
|
+
/**
|
|
32
|
+
* Returns the value of the distance in the given unit of distance.
|
|
33
|
+
* @param distance The distance to get the value of.
|
|
34
|
+
* @param newUnit The unit of distance to get the value of the distance in.
|
|
35
|
+
*/
|
|
36
|
+
in({ value, unit }: Readonly<Distance>, newUnit: UnitOfDistance): number;
|
|
37
|
+
/**
|
|
38
|
+
* Determines if two distances are equal given a certain tolerance.
|
|
39
|
+
* The distances will be converted in the tolerance unit before comparison.
|
|
40
|
+
* @param distance1 The first distance to compare.
|
|
41
|
+
* @param distance2 The second distance to compare.
|
|
42
|
+
* @param tolerance The allowed tolerance.
|
|
43
|
+
*/
|
|
44
|
+
areEqual(distance1: Readonly<Distance>, distance2: Readonly<Distance>, tolerance: Readonly<Distance>): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Computes the squared distance between two positions.
|
|
47
|
+
* @param position1 The first position.
|
|
48
|
+
* @param position2 The second position.
|
|
49
|
+
* @param unitOfReference The unit to use to compare the positions. This unit will also be the unit of the resulting Distance.
|
|
50
|
+
* If not defined, a random unit will be used. Specifying your unit can help mitigate floating point errors.
|
|
51
|
+
*/
|
|
52
|
+
betweenSquared(position1: Readonly<Point3D>, position2: Readonly<Point3D>, unitOfReference?: UnitOfDistance): Distance;
|
|
53
|
+
/**
|
|
54
|
+
* Computes the distance between two positions.
|
|
55
|
+
* @param position1 The first position.
|
|
56
|
+
* @param position2 The second position.
|
|
57
|
+
* @param unitOfReference The unit to use to compare the positions. This unit will also be the unit of the resulting Distance.
|
|
58
|
+
* If not defined, a random unit will be used. Specifying your unit can help mitigate floating point errors.
|
|
59
|
+
*/
|
|
60
|
+
between(position1: Readonly<Point3D>, position2: Readonly<Point3D>, unitOfReference?: UnitOfDistance): Distance;
|
|
61
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Point3D } from "./Point3D.js";
|
|
2
|
+
export var UnitOfDistance;
|
|
3
|
+
(function (UnitOfDistance) {
|
|
4
|
+
UnitOfDistance["METERS"] = "Meters";
|
|
5
|
+
UnitOfDistance["MILLIMETERS"] = "Millimeters";
|
|
6
|
+
UnitOfDistance["ASTRONOMICAL_UNITS"] = "Astronomical Units";
|
|
7
|
+
UnitOfDistance["LIGHT_YEARS"] = "Light Years";
|
|
8
|
+
})(UnitOfDistance || (UnitOfDistance = {}));
|
|
9
|
+
/**
|
|
10
|
+
* The definition of distances in meters.
|
|
11
|
+
* 1 millimeter is 0.001 meters.
|
|
12
|
+
* 1 astronomical unit is 149,597,870,700 meters.
|
|
13
|
+
* 1 light-year is 9,460,730,472,580,800 meters.
|
|
14
|
+
*/
|
|
15
|
+
const METERS_PER_DISTANCE = {
|
|
16
|
+
[UnitOfDistance.MILLIMETERS]: 0.001,
|
|
17
|
+
[UnitOfDistance.METERS]: 1,
|
|
18
|
+
[UnitOfDistance.ASTRONOMICAL_UNITS]: 149_597_870_700,
|
|
19
|
+
[UnitOfDistance.LIGHT_YEARS]: 9_460_730_472_580_800,
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* A set of functions to work with Distances.
|
|
23
|
+
*/
|
|
24
|
+
export const Distance = {
|
|
25
|
+
/**
|
|
26
|
+
* Creates a distance.
|
|
27
|
+
* @param value The value for the distance.
|
|
28
|
+
* @param unit The unit for the distance.
|
|
29
|
+
*/
|
|
30
|
+
create(value, unit) {
|
|
31
|
+
return { value, unit };
|
|
32
|
+
},
|
|
33
|
+
/**
|
|
34
|
+
* Converts a distance to another unit of distance.
|
|
35
|
+
* The provided distance is left untouched.
|
|
36
|
+
* @param distance The distance to convert.
|
|
37
|
+
* @param newUnit The unit to convert to.
|
|
38
|
+
* @returns A new Distance with the requested unit of distance.
|
|
39
|
+
*/
|
|
40
|
+
convert(distance, newUnit) {
|
|
41
|
+
return {
|
|
42
|
+
value: Distance.in(distance, newUnit),
|
|
43
|
+
unit: newUnit,
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
/**
|
|
47
|
+
* Returns the value of the distance in the given unit of distance.
|
|
48
|
+
* @param distance The distance to get the value of.
|
|
49
|
+
* @param newUnit The unit of distance to get the value of the distance in.
|
|
50
|
+
*/
|
|
51
|
+
in({ value, unit }, newUnit) {
|
|
52
|
+
if (unit === newUnit) {
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
return (value * METERS_PER_DISTANCE[unit]) / METERS_PER_DISTANCE[newUnit];
|
|
56
|
+
},
|
|
57
|
+
/**
|
|
58
|
+
* Determines if two distances are equal given a certain tolerance.
|
|
59
|
+
* The distances will be converted in the tolerance unit before comparison.
|
|
60
|
+
* @param distance1 The first distance to compare.
|
|
61
|
+
* @param distance2 The second distance to compare.
|
|
62
|
+
* @param tolerance The allowed tolerance.
|
|
63
|
+
*/
|
|
64
|
+
areEqual(distance1, distance2, tolerance) {
|
|
65
|
+
const difference = Distance.in(distance1, tolerance.unit) - Distance.in(distance2, tolerance.unit);
|
|
66
|
+
return Math.abs(difference) <= tolerance.value;
|
|
67
|
+
},
|
|
68
|
+
/**
|
|
69
|
+
* Computes the squared distance between two positions.
|
|
70
|
+
* @param position1 The first position.
|
|
71
|
+
* @param position2 The second position.
|
|
72
|
+
* @param unitOfReference The unit to use to compare the positions. This unit will also be the unit of the resulting Distance.
|
|
73
|
+
* If not defined, a random unit will be used. Specifying your unit can help mitigate floating point errors.
|
|
74
|
+
*/
|
|
75
|
+
betweenSquared(position1, position2, unitOfReference) {
|
|
76
|
+
const actualUnitOfReference = unitOfReference ?? position1.x.unit;
|
|
77
|
+
const xyz1 = Point3D.in(position1, actualUnitOfReference);
|
|
78
|
+
const xyz2 = Point3D.in(position2, actualUnitOfReference);
|
|
79
|
+
const distanceValue = Math.pow(xyz1.x - xyz2.x, 2) + Math.pow(xyz1.y - xyz2.y, 2) + Math.pow(xyz1.z - xyz2.z, 2);
|
|
80
|
+
return Distance.create(distanceValue, actualUnitOfReference);
|
|
81
|
+
},
|
|
82
|
+
/**
|
|
83
|
+
* Computes the distance between two positions.
|
|
84
|
+
* @param position1 The first position.
|
|
85
|
+
* @param position2 The second position.
|
|
86
|
+
* @param unitOfReference The unit to use to compare the positions. This unit will also be the unit of the resulting Distance.
|
|
87
|
+
* If not defined, a random unit will be used. Specifying your unit can help mitigate floating point errors.
|
|
88
|
+
*/
|
|
89
|
+
between(position1, position2, unitOfReference) {
|
|
90
|
+
const distance = Distance.betweenSquared(position1, position2, unitOfReference);
|
|
91
|
+
distance.value = Math.sqrt(distance.value);
|
|
92
|
+
return distance;
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
//# sourceMappingURL=Distance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Distance.js","sourceRoot":"","sources":["../../src/measurements/Distance.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,MAAM,CAAN,I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= {
|
|
6
|
+
x: Distance;
|
|
7
|
+
y: Distance;
|
|
8
|
+
};
|
|
9
|
+
export type XY = {
|
|
10
|
+
x: Distance["value"];
|
|
11
|
+
y: Distance["value"];
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* A set of functions to work with 2D positions.
|
|
15
|
+
*/
|
|
16
|
+
export declare const Point2D: {
|
|
17
|
+
/**
|
|
18
|
+
* Builds a position from XY values with the same unit.
|
|
19
|
+
*/
|
|
20
|
+
create({ x, y }: Readonly<XY>, unit: UnitOfDistance): Point2D;
|
|
21
|
+
/**
|
|
22
|
+
* Converts x and y to one unit or to the matching units of another position.
|
|
23
|
+
* The provided position is left untouched.
|
|
24
|
+
*/
|
|
25
|
+
convert({ x, y }: Readonly<Point2D>, unit: Readonly<Point2D> | UnitOfDistance): Point2D;
|
|
26
|
+
/**
|
|
27
|
+
* Converts x and y to the given unit and returns their values.
|
|
28
|
+
*/
|
|
29
|
+
in({ x, y }: Readonly<Point2D>, newUnit: UnitOfDistance): XY;
|
|
30
|
+
/**
|
|
31
|
+
* Determines if two positions are within an inclusive distance tolerance.
|
|
32
|
+
*/
|
|
33
|
+
areEqual(position1: Readonly<Point2D>, position2: Readonly<Point2D>, tolerance: Readonly<Distance>): boolean;
|
|
34
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { TypeGuard } from "../TypeGuard.js";
|
|
2
|
+
import { Distance, UnitOfDistance } from "./Distance.js";
|
|
3
|
+
/**
|
|
4
|
+
* A set of functions to work with 2D positions.
|
|
5
|
+
*/
|
|
6
|
+
export const Point2D = {
|
|
7
|
+
/**
|
|
8
|
+
* Builds a position from XY values with the same unit.
|
|
9
|
+
*/
|
|
10
|
+
create({ x, y }, unit) {
|
|
11
|
+
return {
|
|
12
|
+
x: Distance.create(x, unit),
|
|
13
|
+
y: Distance.create(y, unit),
|
|
14
|
+
};
|
|
15
|
+
},
|
|
16
|
+
/**
|
|
17
|
+
* Converts x and y to one unit or to the matching units of another position.
|
|
18
|
+
* The provided position is left untouched.
|
|
19
|
+
*/
|
|
20
|
+
convert({ x, y }, unit) {
|
|
21
|
+
if (TypeGuard.isEnumMember(UnitOfDistance, unit)) {
|
|
22
|
+
return {
|
|
23
|
+
x: Distance.convert(x, unit),
|
|
24
|
+
y: Distance.convert(y, unit),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
x: Distance.convert(x, unit.x.unit),
|
|
29
|
+
y: Distance.convert(y, unit.y.unit),
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
/**
|
|
33
|
+
* Converts x and y to the given unit and returns their values.
|
|
34
|
+
*/
|
|
35
|
+
in({ x, y }, newUnit) {
|
|
36
|
+
return {
|
|
37
|
+
x: Distance.in(x, newUnit),
|
|
38
|
+
y: Distance.in(y, newUnit),
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
/**
|
|
42
|
+
* Determines if two positions are within an inclusive distance tolerance.
|
|
43
|
+
*/
|
|
44
|
+
areEqual(position1, position2, tolerance) {
|
|
45
|
+
const xy1 = Point2D.in(position1, tolerance.unit);
|
|
46
|
+
const xy2 = Point2D.in(position2, tolerance.unit);
|
|
47
|
+
const distance = Math.hypot(xy1.x - xy2.x, xy1.y - xy2.y);
|
|
48
|
+
return distance <= tolerance.value;
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=Point2D.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Point2D.js","sourceRoot":"","sources":["../../src/measurements/Point2D.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAexD;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB;;OAEG;IACH,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAgB,EAAE,IAAoB;Q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KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAA;QAEzD,OAAO,QAAQ,IAAI,SAAS,CAAC,KAAK,CAAA;IACpC,CAAC;CACF,CAAA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Distance, UnitOfDistance } from "./Distance.js";
|
|
2
|
+
/**
|
|
3
|
+
* Represents a position in 3D space
|
|
4
|
+
*/
|
|
5
|
+
export type Point3D = {
|
|
6
|
+
x: Distance;
|
|
7
|
+
y: Distance;
|
|
8
|
+
z: Distance;
|
|
9
|
+
};
|
|
10
|
+
export type XYZ = {
|
|
11
|
+
x: Distance["value"];
|
|
12
|
+
y: Distance["value"];
|
|
13
|
+
z: Distance["value"];
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* A set of functions to work with Positions.
|
|
17
|
+
*/
|
|
18
|
+
export declare const Point3D: {
|
|
19
|
+
/**
|
|
20
|
+
* Builds a position from XYZ with the same unit.
|
|
21
|
+
* @param x The x value
|
|
22
|
+
* @param y The y value
|
|
23
|
+
* @param z The z value
|
|
24
|
+
* @param unit The unit to use for all values
|
|
25
|
+
*/
|
|
26
|
+
create({ x, y, z }: Readonly<XYZ>, unit: UnitOfDistance): Point3D;
|
|
27
|
+
/**
|
|
28
|
+
* Converts x, y, and z to the given unit.
|
|
29
|
+
* The unit can be a UnitOfDistance, or another Position.
|
|
30
|
+
* When the unit is a Position, each value will be converted to the matching Position's unit.
|
|
31
|
+
* @param position The position to convert.
|
|
32
|
+
* @param unit The unit(s) to convert to.
|
|
33
|
+
*/
|
|
34
|
+
convert({ x, y, z }: Readonly<Point3D>, unit: Readonly<Point3D> | UnitOfDistance): Point3D;
|
|
35
|
+
/**
|
|
36
|
+
* Converts x, y, and z to the given unit and returns the values
|
|
37
|
+
* @param position The position to convert.
|
|
38
|
+
* @param newUnit The new unit to convert to.
|
|
39
|
+
*/
|
|
40
|
+
in({ x, y, z }: Readonly<Point3D>, newUnit: UnitOfDistance): XYZ;
|
|
41
|
+
/**
|
|
42
|
+
* Determines if two positions are equal given a certain tolerance.
|
|
43
|
+
* The positions will be converted in the tolerance unit before comparison.
|
|
44
|
+
* @param position1 The first position to compare.
|
|
45
|
+
* @param position2 The second position to compare.
|
|
46
|
+
* @param tolerance The allowed tolerance.
|
|
47
|
+
*/
|
|
48
|
+
areEqual(position1: Readonly<Point3D>, position2: Readonly<Point3D>, tolerance: Readonly<Distance>): boolean;
|
|
49
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { TypeGuard } from "../TypeGuard.js";
|
|
2
|
+
import { Distance, UnitOfDistance } from "./Distance.js";
|
|
3
|
+
/**
|
|
4
|
+
* A set of functions to work with Positions.
|
|
5
|
+
*/
|
|
6
|
+
export const Point3D = {
|
|
7
|
+
/**
|
|
8
|
+
* Builds a position from XYZ with the same unit.
|
|
9
|
+
* @param x The x value
|
|
10
|
+
* @param y The y value
|
|
11
|
+
* @param z The z value
|
|
12
|
+
* @param unit The unit to use for all values
|
|
13
|
+
*/
|
|
14
|
+
create({ x, y, z }, unit) {
|
|
15
|
+
return {
|
|
16
|
+
x: { value: x, unit },
|
|
17
|
+
y: { value: y, unit },
|
|
18
|
+
z: { value: z, unit },
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
/**
|
|
22
|
+
* Converts x, y, and z to the given unit.
|
|
23
|
+
* The unit can be a UnitOfDistance, or another Position.
|
|
24
|
+
* When the unit is a Position, each value will be converted to the matching Position's unit.
|
|
25
|
+
* @param position The position to convert.
|
|
26
|
+
* @param unit The unit(s) to convert to.
|
|
27
|
+
*/
|
|
28
|
+
convert({ x, y, z }, unit) {
|
|
29
|
+
if (TypeGuard.isEnumMember(UnitOfDistance, unit)) {
|
|
30
|
+
return {
|
|
31
|
+
x: Distance.convert(x, unit),
|
|
32
|
+
y: Distance.convert(y, unit),
|
|
33
|
+
z: Distance.convert(z, unit),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
x: Distance.convert(x, unit.x.unit),
|
|
38
|
+
y: Distance.convert(y, unit.y.unit),
|
|
39
|
+
z: Distance.convert(z, unit.z.unit),
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
/**
|
|
43
|
+
* Converts x, y, and z to the given unit and returns the values
|
|
44
|
+
* @param position The position to convert.
|
|
45
|
+
* @param newUnit The new unit to convert to.
|
|
46
|
+
*/
|
|
47
|
+
in({ x, y, z }, newUnit) {
|
|
48
|
+
return {
|
|
49
|
+
x: Distance.in(x, newUnit),
|
|
50
|
+
y: Distance.in(y, newUnit),
|
|
51
|
+
z: Distance.in(z, newUnit),
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
/**
|
|
55
|
+
* Determines if two positions are equal given a certain tolerance.
|
|
56
|
+
* The positions will be converted in the tolerance unit before comparison.
|
|
57
|
+
* @param position1 The first position to compare.
|
|
58
|
+
* @param position2 The second position to compare.
|
|
59
|
+
* @param tolerance The allowed tolerance.
|
|
60
|
+
*/
|
|
61
|
+
areEqual(position1, position2, tolerance) {
|
|
62
|
+
const distance = Distance.between(position1, position2, tolerance.unit);
|
|
63
|
+
return Math.abs(distance.value) <= tolerance.value;
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=Point3D.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Point3D.js","sourceRoot":"","sources":["../../src/measurements/Point3D.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAiBxD;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAiB,EAAE,IAAoB;QACrD,OA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AA;IACH,CAAC;IAED;;;;;;OAMG;IACH,QAAQ,CAAC,SAA4B,EAAE,SAA4B,EAAE,SAA6B;QAChG,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,IAAI,CAAC,CAAA;QAEvE,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,SAAS,CAAC,KAAK,CAAA;IACpD,CAAC;CACF,CAAA"}
|
|
@@ -24,19 +24,19 @@ export declare const Time: {
|
|
|
24
24
|
* @param newUnit The new unit to convert to.
|
|
25
25
|
* @returns A new Time with the requested unit of time.
|
|
26
26
|
*/
|
|
27
|
-
convert(time: Time
|
|
27
|
+
convert(time: Readonly<Time>, newUnit: UnitOfTime): Time;
|
|
28
28
|
/**
|
|
29
29
|
* Returns the value of the time in the given unit of time.
|
|
30
30
|
* @param time The time to get the value of.
|
|
31
31
|
* @param newUnit The unit of time to get the value of the time in.
|
|
32
32
|
*/
|
|
33
|
-
in(time: Time
|
|
33
|
+
in(time: Readonly<Time>, newUnit: UnitOfTime): number;
|
|
34
34
|
/**
|
|
35
35
|
* Adds 2 times together. The unit of the first time will be used.
|
|
36
36
|
*/
|
|
37
|
-
add(timeA: Time
|
|
37
|
+
add(timeA: Readonly<Time>, timeB: Readonly<Time>): Time;
|
|
38
38
|
/**
|
|
39
39
|
* Subtracts 2 times. The unit of the first time will be used.
|
|
40
40
|
*/
|
|
41
|
-
subtract(timeA: Time
|
|
41
|
+
subtract(timeA: Readonly<Time>, timeB: Readonly<Time>): Time;
|
|
42
42
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Time.js","sourceRoot":"","sources":["../../src/measurements/Time.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAN,IAAY,UAKX;AALD,WAAY,UAAU;IACpB,2CAA6B,CAAA;IAC7B,iCAAmB,CAAA;IACnB,iCAAmB,CAAA;IACnB,6BAA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AED;;;;;;OAMG;IACH,OAAO,CAAC,IAAoB,EAAE,OAAmB;QAC/C,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC;YAC7B,IAAI,EAAE,OAAO;SACd,CAAA;IACH,CAAC;IAED;;;;OAIG;IACH,EAAE,CAAC,IAAoB,EAAE,OAAmB;QAC1C,OAAO,CAAC,IAAI,CAAC,KAAK,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC/E,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,KAAqB,EAAE,KAAqB;QAC9C,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAA;IAC1E,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,KAAqB,EAAE,KAAqB;QACnD,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAA;IAC1E,CAAC;CACF,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guillaume-docquier/tools-ts",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.6.0",
|
|
4
4
|
"description": "My personal collection of typescript tools",
|
|
5
5
|
"homepage": "https://github.com/Guillaume-Docquier/tools-ts",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
"husky": "^9.1.7",
|
|
41
41
|
"jiti": "^2.7.0",
|
|
42
42
|
"lint-staged": "^16.4.0",
|
|
43
|
-
"oxfmt": ">=0.
|
|
44
|
-
"oxlint": "^1.
|
|
43
|
+
"oxfmt": ">=0.62.0",
|
|
44
|
+
"oxlint": "^1.77.0",
|
|
45
45
|
"oxlint-tsgolint": "^7.0.2001",
|
|
46
|
-
"semantic-release": "^25.0.
|
|
46
|
+
"semantic-release": "^25.0.9",
|
|
47
47
|
"typescript": "~7.0.2",
|
|
48
48
|
"vite": "^8.2.0",
|
|
49
49
|
"vitest": "^4.1.10",
|