ducjs 2.0.0 → 2.1.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 +1 -1
- package/dist/flatbuffers/duc/duc-feature-control-frame-style.d.ts +0 -3
- package/dist/flatbuffers/duc/duc-feature-control-frame-style.js +0 -8
- package/dist/flatbuffers/duc/duc-leader-style.d.ts +0 -3
- package/dist/flatbuffers/duc/duc-leader-style.js +0 -8
- package/dist/flatbuffers/duc/duc-plot-style.d.ts +1 -4
- package/dist/flatbuffers/duc/duc-plot-style.js +1 -10
- package/dist/flatbuffers/duc/duc-table-style.d.ts +0 -3
- package/dist/flatbuffers/duc/duc-table-style.js +0 -8
- package/dist/flatbuffers/duc/duc-text-style.d.ts +0 -3
- package/dist/flatbuffers/duc/duc-text-style.js +0 -8
- package/dist/flatbuffers/duc/duc-viewport-style.d.ts +1 -4
- package/dist/flatbuffers/duc/duc-viewport-style.js +1 -10
- package/dist/flatbuffers/duc/duc-xray-style.d.ts +1 -4
- package/dist/flatbuffers/duc/duc-xray-style.js +1 -10
- package/dist/flatbuffers/duc/exported-data-state.d.ts +3 -0
- package/dist/flatbuffers/duc/exported-data-state.js +8 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/parse.d.ts +5 -5
- package/dist/parse.js +57 -20
- package/dist/restore/restoreDataState.d.ts +14 -10
- package/dist/restore/restoreDataState.js +29 -22
- package/dist/restore/restoreElements.d.ts +2 -2
- package/dist/restore/restoreElements.js +21 -14
- package/dist/restore/restoreStandards.d.ts +2 -2
- package/dist/restore/restoreStandards.js +4 -4
- package/dist/serialize.d.ts +3 -2
- package/dist/serialize.js +14 -27
- package/dist/technical/measurements.d.ts +2 -2
- package/dist/technical/measurements.js +1 -1
- package/dist/technical/scopes.d.ts +4 -4
- package/dist/technical/scopes.js +1 -1
- package/dist/technical/standards.d.ts +4 -4
- package/dist/types/elements/index.d.ts +13 -13
- package/dist/types/elements/typeChecks.d.ts +5 -4
- package/dist/types/elements/typeChecks.js +5 -2
- package/dist/types/geometryTypes.d.ts +2 -2
- package/dist/types/index.d.ts +11 -8
- package/dist/types/index.js +1 -0
- package/dist/types/typeChecks.d.ts +5 -0
- package/dist/types/typeChecks.js +10 -0
- package/dist/utils/bounds.d.ts +3 -3
- package/dist/utils/bounds.js +3 -3
- package/dist/utils/constants.d.ts +5 -3
- package/dist/utils/constants.js +3 -5
- package/dist/utils/elements/frameElement.d.ts +2 -1
- package/dist/utils/elements/frameElement.js +13 -1
- package/dist/utils/elements/freedrawElement.d.ts +1 -1
- package/dist/utils/elements/freedrawElement.js +1 -1
- package/dist/utils/elements/index.d.ts +4 -4
- package/dist/utils/elements/index.js +17 -21
- package/dist/utils/elements/linearElement.d.ts +6 -6
- package/dist/utils/elements/linearElement.js +4 -4
- package/dist/utils/elements/newElement.d.ts +3 -3
- package/dist/utils/elements/newElement.js +26 -26
- package/dist/utils/elements/textElement.d.ts +7 -7
- package/dist/utils/elements/textElement.js +11 -9
- package/dist/utils/elements/viewportElement.d.ts +1 -1
- package/dist/utils/functionCodec.js +2 -2
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/math/algebra/gadirections.d.ts +1 -1
- package/dist/utils/math/algebra/gadirections.js +1 -1
- package/dist/utils/math/algebra/galines.d.ts +1 -1
- package/dist/utils/math/algebra/galines.js +1 -1
- package/dist/utils/math/algebra/gapoints.d.ts +1 -1
- package/dist/utils/math/algebra/gapoints.js +3 -3
- package/dist/utils/math/algebra/gatransforms.d.ts +1 -1
- package/dist/utils/math/algebra/gatransforms.js +2 -2
- package/dist/utils/math/bbox.d.ts +2 -2
- package/dist/utils/math/geometry.d.ts +3 -3
- package/dist/utils/math/geometry.js +2 -2
- package/dist/utils/math/index.d.ts +6 -6
- package/dist/utils/math/index.js +3 -3
- package/dist/utils/normalize.d.ts +2 -2
- package/dist/utils/normalize.js +2 -2
- package/dist/utils/shape.d.ts +2 -2
- package/dist/utils/shape.js +8 -8
- package/dist/utils/state/grid.d.ts +1 -1
- package/dist/utils/state/grid.js +3 -3
- package/dist/utils/state/index.d.ts +1 -1
- package/dist/utils/state/index.js +7 -7
- package/dist/utils/traverse.d.ts +22 -0
- package/dist/utils/traverse.js +87 -0
- package/dist/utils/version.d.ts +1 -1
- package/dist/utils/version.js +1 -1
- package/package.json +4 -2
- package/dist/legacy/index.d.ts +0 -1
- package/dist/legacy/index.js +0 -1
- package/dist/legacy/v1/duc/app-state.d.ts +0 -124
- package/dist/legacy/v1/duc/app-state.js +0 -388
- package/dist/legacy/v1/duc/binary-file-data.d.ts +0 -27
- package/dist/legacy/v1/duc/binary-file-data.js +0 -90
- package/dist/legacy/v1/duc/binary-files-entry.d.ts +0 -16
- package/dist/legacy/v1/duc/binary-files-entry.js +0 -43
- package/dist/legacy/v1/duc/binary-files.d.ts +0 -17
- package/dist/legacy/v1/duc/binary-files.js +0 -55
- package/dist/legacy/v1/duc/binding-point.d.ts +0 -15
- package/dist/legacy/v1/duc/binding-point.js +0 -48
- package/dist/legacy/v1/duc/bound-element.d.ts +0 -17
- package/dist/legacy/v1/duc/bound-element.js +0 -48
- package/dist/legacy/v1/duc/duc-block-attribute-details.d.ts +0 -22
- package/dist/legacy/v1/duc/duc-block-attribute-details.js +0 -57
- package/dist/legacy/v1/duc/duc-block-attribute.d.ts +0 -16
- package/dist/legacy/v1/duc/duc-block-attribute.js +0 -43
- package/dist/legacy/v1/duc/duc-block-instance-element-override.d.ts +0 -17
- package/dist/legacy/v1/duc/duc-block-instance-element-override.js +0 -48
- package/dist/legacy/v1/duc/duc-block.d.ts +0 -34
- package/dist/legacy/v1/duc/duc-block.js +0 -110
- package/dist/legacy/v1/duc/duc-element.d.ts +0 -273
- package/dist/legacy/v1/duc/duc-element.js +0 -865
- package/dist/legacy/v1/duc/duc-group.d.ts +0 -40
- package/dist/legacy/v1/duc/duc-group.js +0 -114
- package/dist/legacy/v1/duc/duc-line-reference.d.ts +0 -15
- package/dist/legacy/v1/duc/duc-line-reference.js +0 -43
- package/dist/legacy/v1/duc/duc-line.d.ts +0 -15
- package/dist/legacy/v1/duc/duc-line.js +0 -43
- package/dist/legacy/v1/duc/duc-path.d.ts +0 -26
- package/dist/legacy/v1/duc/duc-path.js +0 -69
- package/dist/legacy/v1/duc/duc-table-cell.d.ts +0 -22
- package/dist/legacy/v1/duc/duc-table-cell.js +0 -57
- package/dist/legacy/v1/duc/duc-table-column.d.ts +0 -18
- package/dist/legacy/v1/duc/duc-table-column.js +0 -50
- package/dist/legacy/v1/duc/duc-table-row.d.ts +0 -18
- package/dist/legacy/v1/duc/duc-table-row.js +0 -50
- package/dist/legacy/v1/duc/duc-table-style-props.d.ts +0 -39
- package/dist/legacy/v1/duc/duc-table-style-props.js +0 -114
- package/dist/legacy/v1/duc/duc-table-style.d.ts +0 -14
- package/dist/legacy/v1/duc/duc-table-style.js +0 -41
- package/dist/legacy/v1/duc/element-background.d.ts +0 -14
- package/dist/legacy/v1/duc/element-background.js +0 -41
- package/dist/legacy/v1/duc/element-content-base.d.ts +0 -22
- package/dist/legacy/v1/duc/element-content-base.js +0 -64
- package/dist/legacy/v1/duc/element-stroke.d.ts +0 -23
- package/dist/legacy/v1/duc/element-stroke.js +0 -66
- package/dist/legacy/v1/duc/exported-data-state.d.ts +0 -51
- package/dist/legacy/v1/duc/exported-data-state.js +0 -155
- package/dist/legacy/v1/duc/image-crop.d.ts +0 -23
- package/dist/legacy/v1/duc/image-crop.js +0 -80
- package/dist/legacy/v1/duc/linear-element-editor.d.ts +0 -44
- package/dist/legacy/v1/duc/linear-element-editor.js +0 -119
- package/dist/legacy/v1/duc/point-binding.d.ts +0 -25
- package/dist/legacy/v1/duc/point-binding.js +0 -72
- package/dist/legacy/v1/duc/point.d.ts +0 -20
- package/dist/legacy/v1/duc/point.js +0 -63
- package/dist/legacy/v1/duc/pointer-down-state.d.ts +0 -32
- package/dist/legacy/v1/duc/pointer-down-state.js +0 -90
- package/dist/legacy/v1/duc/renderer-state.d.ts +0 -17
- package/dist/legacy/v1/duc/renderer-state.js +0 -54
- package/dist/legacy/v1/duc/segment-midpoint-state.d.ts +0 -18
- package/dist/legacy/v1/duc/segment-midpoint-state.js +0 -57
- package/dist/legacy/v1/duc/simple-point.d.ts +0 -15
- package/dist/legacy/v1/duc/simple-point.js +0 -48
- package/dist/legacy/v1/duc/stroke-sides.d.ts +0 -23
- package/dist/legacy/v1/duc/stroke-sides.js +0 -66
- package/dist/legacy/v1/duc/stroke-style.d.ts +0 -31
- package/dist/legacy/v1/duc/stroke-style.js +0 -102
- package/dist/legacy/v1/duc/tiling-properties.d.ts +0 -21
- package/dist/legacy/v1/duc/tiling-properties.js +0 -75
- package/dist/legacy/v1/duc.d.ts +0 -35
- package/dist/legacy/v1/duc.js +0 -37
- package/dist/legacy/v1/index.d.ts +0 -1
- package/dist/legacy/v1/index.js +0 -1
- package/dist/legacy/v1/parse/index.d.ts +0 -67
- package/dist/legacy/v1/parse/index.js +0 -101
- package/dist/legacy/v1/parse/parseAppStateFromBinary.d.ts +0 -3
- package/dist/legacy/v1/parse/parseAppStateFromBinary.js +0 -139
- package/dist/legacy/v1/parse/parseBinaryFilesFromBinary.d.ts +0 -4
- package/dist/legacy/v1/parse/parseBinaryFilesFromBinary.js +0 -32
- package/dist/legacy/v1/parse/parseBlockFromBinary.d.ts +0 -3
- package/dist/legacy/v1/parse/parseBlockFromBinary.js +0 -70
- package/dist/legacy/v1/parse/parseElementFromBinary.d.ts +0 -8
- package/dist/legacy/v1/parse/parseElementFromBinary.js +0 -387
- package/dist/legacy/v1/parse/parseGroupFromBinary.d.ts +0 -4
- package/dist/legacy/v1/parse/parseGroupFromBinary.js +0 -36
- package/dist/legacy/v1/parse/parseRendererStateFromBinary.d.ts +0 -4
- package/dist/legacy/v1/parse/parseRendererStateFromBinary.js +0 -15
- package/dist/legacy/v1/serialize/index.d.ts +0 -5
- package/dist/legacy/v1/serialize/index.js +0 -81
- package/dist/legacy/v1/serialize/serializationUtils.d.ts +0 -17
- package/dist/legacy/v1/serialize/serializationUtils.js +0 -27
- package/dist/legacy/v1/serialize/serializeAppStateFromDuc.d.ts +0 -4
- package/dist/legacy/v1/serialize/serializeAppStateFromDuc.js +0 -145
- package/dist/legacy/v1/serialize/serializeBinaryFilesFromDuc.d.ts +0 -4
- package/dist/legacy/v1/serialize/serializeBinaryFilesFromDuc.js +0 -46
- package/dist/legacy/v1/serialize/serializeBlockFromDuc.d.ts +0 -3
- package/dist/legacy/v1/serialize/serializeBlockFromDuc.js +0 -60
- package/dist/legacy/v1/serialize/serializeElementFromDuc.d.ts +0 -8
- package/dist/legacy/v1/serialize/serializeElementFromDuc.js +0 -435
- package/dist/legacy/v1/serialize/serializeGroupFromDuc.d.ts +0 -3
- package/dist/legacy/v1/serialize/serializeGroupFromDuc.js +0 -37
- package/dist/legacy/v1/serialize/serializeRendererStateFromDuc.d.ts +0 -4
- package/dist/legacy/v1/serialize/serializeRendererStateFromDuc.js +0 -7
- package/dist/legacy/v1/types/elements/index.d.ts +0 -480
- package/dist/legacy/v1/types/elements/index.js +0 -1
- package/dist/legacy/v1/types/elements/typeChecks.d.ts +0 -40
- package/dist/legacy/v1/types/elements/typeChecks.js +0 -179
- package/dist/legacy/v1/types/geometryTypes.d.ts +0 -78
- package/dist/legacy/v1/types/geometryTypes.js +0 -1
- package/dist/legacy/v1/types/index.d.ts +0 -496
- package/dist/legacy/v1/types/index.js +0 -1
- package/dist/legacy/v1/types/utility-types.d.ts +0 -31
- package/dist/legacy/v1/types/utility-types.js +0 -1
- package/dist/legacy/v1/utils/bounds.d.ts +0 -76
- package/dist/legacy/v1/utils/bounds.js +0 -415
- package/dist/legacy/v1/utils/constants.d.ts +0 -370
- package/dist/legacy/v1/utils/constants.js +0 -571
- package/dist/legacy/v1/utils/elements/index.d.ts +0 -26
- package/dist/legacy/v1/utils/elements/index.js +0 -108
- package/dist/legacy/v1/utils/elements/linearElement.d.ts +0 -133
- package/dist/legacy/v1/utils/elements/linearElement.js +0 -544
- package/dist/legacy/v1/utils/elements/textElement.d.ts +0 -89
- package/dist/legacy/v1/utils/elements/textElement.js +0 -563
- package/dist/legacy/v1/utils/index.d.ts +0 -26
- package/dist/legacy/v1/utils/index.js +0 -40
- package/dist/legacy/v1/utils/math/algebra/ga.d.ts +0 -63
- package/dist/legacy/v1/utils/math/algebra/ga.js +0 -268
- package/dist/legacy/v1/utils/math/algebra/gadirections.d.ts +0 -9
- package/dist/legacy/v1/utils/math/algebra/gadirections.js +0 -18
- package/dist/legacy/v1/utils/math/algebra/galines.d.ts +0 -23
- package/dist/legacy/v1/utils/math/algebra/galines.js +0 -32
- package/dist/legacy/v1/utils/math/algebra/gapoints.d.ts +0 -8
- package/dist/legacy/v1/utils/math/algebra/gapoints.js +0 -30
- package/dist/legacy/v1/utils/math/algebra/gatransforms.d.ts +0 -10
- package/dist/legacy/v1/utils/math/algebra/gatransforms.js +0 -23
- package/dist/legacy/v1/utils/math/bbox.d.ts +0 -10
- package/dist/legacy/v1/utils/math/bbox.js +0 -42
- package/dist/legacy/v1/utils/math/geometry.d.ts +0 -102
- package/dist/legacy/v1/utils/math/geometry.js +0 -790
- package/dist/legacy/v1/utils/math/index.d.ts +0 -309
- package/dist/legacy/v1/utils/math/index.js +0 -1140
- package/dist/legacy/v1/utils/math/random.d.ts +0 -4
- package/dist/legacy/v1/utils/math/random.js +0 -25
- package/dist/legacy/v1/utils/measurements.d.ts +0 -33
- package/dist/legacy/v1/utils/measurements.js +0 -65
- package/dist/legacy/v1/utils/normalize.d.ts +0 -14
- package/dist/legacy/v1/utils/normalize.js +0 -49
- package/dist/legacy/v1/utils/restore.d.ts +0 -197
- package/dist/legacy/v1/utils/restore.js +0 -1255
- package/dist/legacy/v1/utils/scopes.d.ts +0 -260
- package/dist/legacy/v1/utils/scopes.js +0 -661
- package/dist/legacy/v1/utils/standards.d.ts +0 -12
- package/dist/legacy/v1/utils/standards.js +0 -10
- package/dist/legacy/v1/utils/state/index.d.ts +0 -2
- package/dist/legacy/v1/utils/state/index.js +0 -68
- package/dist/legacy/v1/utils/url.d.ts +0 -8
- package/dist/legacy/v1/utils/url.js +0 -33
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* supply `null` as message if non-never value is valid, you just need to
|
|
3
|
-
* typecheck against it
|
|
4
|
-
*/
|
|
5
|
-
export const assertNever = (value, message, softAssert) => {
|
|
6
|
-
if (!message) {
|
|
7
|
-
return value;
|
|
8
|
-
}
|
|
9
|
-
if (softAssert) {
|
|
10
|
-
console.error(message);
|
|
11
|
-
return value;
|
|
12
|
-
}
|
|
13
|
-
throw new Error(message);
|
|
14
|
-
};
|
|
15
|
-
export const getUpdatedTimestamp = () => Date.now();
|
|
16
|
-
export const isFiniteNumber = (value) => {
|
|
17
|
-
return typeof value === "number" && Number.isFinite(value);
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Transforms array of objects containing `id` attribute,
|
|
21
|
-
* or array of ids (strings), into a Map, keyd by `id`.
|
|
22
|
-
*/
|
|
23
|
-
export const arrayToMap = (items) => {
|
|
24
|
-
if (items instanceof Map) {
|
|
25
|
-
return items;
|
|
26
|
-
}
|
|
27
|
-
return items.reduce((acc, element) => {
|
|
28
|
-
acc.set(typeof element === "string" ? element : element.id, element);
|
|
29
|
-
return acc;
|
|
30
|
-
}, new Map());
|
|
31
|
-
};
|
|
32
|
-
export const updateActiveTool = (appState, data) => {
|
|
33
|
-
var _a, _b, _c;
|
|
34
|
-
if (data.type === "custom") {
|
|
35
|
-
return Object.assign(Object.assign({}, appState.activeTool), { type: "custom", customType: data.customType, locked: (_a = data.locked) !== null && _a !== void 0 ? _a : appState.activeTool.locked });
|
|
36
|
-
}
|
|
37
|
-
return Object.assign(Object.assign({}, appState.activeTool), { lastActiveTool: data.lastActiveToolBeforeEraser === undefined
|
|
38
|
-
? appState.activeTool.lastActiveTool
|
|
39
|
-
: data.lastActiveToolBeforeEraser, type: data.type, customType: null, locked: (_b = data.locked) !== null && _b !== void 0 ? _b : appState.activeTool.locked, fromSelection: (_c = data.fromSelection) !== null && _c !== void 0 ? _c : false });
|
|
40
|
-
};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This is a 2D Projective Geometric Algebra implementation.
|
|
3
|
-
*
|
|
4
|
-
* For wider context on geometric algebra visit see https://bivector.net.
|
|
5
|
-
*
|
|
6
|
-
* For this specific algebra see cheatsheet https://bivector.net/2DPGA.pdf.
|
|
7
|
-
*
|
|
8
|
-
* Converted from generator written by enki, with a ton of added on top.
|
|
9
|
-
*
|
|
10
|
-
* This library uses 8-vectors to represent points, directions and lines
|
|
11
|
-
* in 2D space.
|
|
12
|
-
*
|
|
13
|
-
* An array `[a, b, c, d, e, f, g, h]` represents a n(8)vector:
|
|
14
|
-
* a + b*e0 + c*e1 + d*e2 + e*e01 + f*e20 + g*e12 + h*e012
|
|
15
|
-
*
|
|
16
|
-
* See GAPoint, GALine, GADirection and GATransform modules for common
|
|
17
|
-
* operations.
|
|
18
|
-
*/
|
|
19
|
-
export type Point = NVector;
|
|
20
|
-
export type Direction = NVector;
|
|
21
|
-
export type Line = NVector;
|
|
22
|
-
export type Transform = NVector;
|
|
23
|
-
export declare const point: (x: number, y: number) => Point;
|
|
24
|
-
export declare const origin: () => Point;
|
|
25
|
-
export declare const direction: (x: number, y: number) => Direction;
|
|
26
|
-
export declare const offset: (x: number, y: number) => Direction;
|
|
27
|
-
type NVector = readonly [
|
|
28
|
-
number,
|
|
29
|
-
number,
|
|
30
|
-
number,
|
|
31
|
-
number,
|
|
32
|
-
number,
|
|
33
|
-
number,
|
|
34
|
-
number,
|
|
35
|
-
number
|
|
36
|
-
];
|
|
37
|
-
export declare const nvector: (value?: number, index?: number) => NVector;
|
|
38
|
-
export declare const toString: (nvector: NVector) => string;
|
|
39
|
-
export declare const reverse: (nvector: NVector) => NVector;
|
|
40
|
-
export declare const dual: (nvector: NVector) => NVector;
|
|
41
|
-
export declare const conjugate: (nvector: NVector) => NVector;
|
|
42
|
-
export declare const involute: (nvector: NVector) => NVector;
|
|
43
|
-
export declare const add: (a: NVector, b: NVector | number) => NVector;
|
|
44
|
-
export declare const sub: (a: NVector, b: NVector | number) => NVector;
|
|
45
|
-
export declare const mul: (a: NVector, b: NVector | number) => NVector;
|
|
46
|
-
export declare const mulScalar: (a: NVector, b: NVector) => number;
|
|
47
|
-
export declare const meet: (a: NVector, b: NVector) => NVector;
|
|
48
|
-
export declare const join: (a: NVector, b: NVector) => NVector;
|
|
49
|
-
export declare const joinScalar: (a: NVector, b: NVector) => number;
|
|
50
|
-
export declare const dot: (a: NVector, b: NVector) => NVector;
|
|
51
|
-
export declare const norm: (a: NVector) => number;
|
|
52
|
-
export declare const inorm: (a: NVector) => number;
|
|
53
|
-
export declare const normalized: (a: NVector) => NVector;
|
|
54
|
-
export declare const inormalized: (a: NVector) => NVector;
|
|
55
|
-
export declare const E0: NVector;
|
|
56
|
-
export declare const E1: NVector;
|
|
57
|
-
export declare const E2: NVector;
|
|
58
|
-
export declare const E01: NVector;
|
|
59
|
-
export declare const E20: NVector;
|
|
60
|
-
export declare const E12: NVector;
|
|
61
|
-
export declare const E012: NVector;
|
|
62
|
-
export declare const I: NVector;
|
|
63
|
-
export {};
|
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This is a 2D Projective Geometric Algebra implementation.
|
|
3
|
-
*
|
|
4
|
-
* For wider context on geometric algebra visit see https://bivector.net.
|
|
5
|
-
*
|
|
6
|
-
* For this specific algebra see cheatsheet https://bivector.net/2DPGA.pdf.
|
|
7
|
-
*
|
|
8
|
-
* Converted from generator written by enki, with a ton of added on top.
|
|
9
|
-
*
|
|
10
|
-
* This library uses 8-vectors to represent points, directions and lines
|
|
11
|
-
* in 2D space.
|
|
12
|
-
*
|
|
13
|
-
* An array `[a, b, c, d, e, f, g, h]` represents a n(8)vector:
|
|
14
|
-
* a + b*e0 + c*e1 + d*e2 + e*e01 + f*e20 + g*e12 + h*e012
|
|
15
|
-
*
|
|
16
|
-
* See GAPoint, GALine, GADirection and GATransform modules for common
|
|
17
|
-
* operations.
|
|
18
|
-
*/
|
|
19
|
-
export const point = (x, y) => [0, 0, 0, 0, y, x, 1, 0];
|
|
20
|
-
export const origin = () => [0, 0, 0, 0, 0, 0, 1, 0];
|
|
21
|
-
export const direction = (x, y) => {
|
|
22
|
-
const norm = Math.hypot(x, y); // same as `inorm(direction(x, y))`
|
|
23
|
-
return [0, 0, 0, 0, y / norm, x / norm, 0, 0];
|
|
24
|
-
};
|
|
25
|
-
export const offset = (x, y) => [
|
|
26
|
-
0,
|
|
27
|
-
0,
|
|
28
|
-
0,
|
|
29
|
-
0,
|
|
30
|
-
y,
|
|
31
|
-
x,
|
|
32
|
-
0,
|
|
33
|
-
0,
|
|
34
|
-
];
|
|
35
|
-
// These are labels for what each number in an nvector represents
|
|
36
|
-
const NVECTOR_BASE = ["1", "e0", "e1", "e2", "e01", "e20", "e12", "e012"];
|
|
37
|
-
// Used to represent points, lines and transformations
|
|
38
|
-
export const nvector = (value = 0, index = 0) => {
|
|
39
|
-
const result = [0, 0, 0, 0, 0, 0, 0, 0];
|
|
40
|
-
if (index < 0 || index > 7) {
|
|
41
|
-
throw new Error(`Expected \`index\` between 0 and 7, got \`${index}\``);
|
|
42
|
-
}
|
|
43
|
-
if (value !== 0) {
|
|
44
|
-
result[index] = value;
|
|
45
|
-
}
|
|
46
|
-
return result;
|
|
47
|
-
};
|
|
48
|
-
const STRING_EPSILON = 0.000001;
|
|
49
|
-
export const toString = (nvector) => {
|
|
50
|
-
const result = nvector
|
|
51
|
-
.map((value, index) => Math.abs(value) > STRING_EPSILON
|
|
52
|
-
? value.toFixed(7).replace(/(\.|0+)$/, "") +
|
|
53
|
-
(index > 0 ? NVECTOR_BASE[index] : "")
|
|
54
|
-
: null)
|
|
55
|
-
.filter((representation) => representation != null)
|
|
56
|
-
.join(" + ");
|
|
57
|
-
return result === "" ? "0" : result;
|
|
58
|
-
};
|
|
59
|
-
// Reverse the order of the basis blades.
|
|
60
|
-
export const reverse = (nvector) => [
|
|
61
|
-
nvector[0],
|
|
62
|
-
nvector[1],
|
|
63
|
-
nvector[2],
|
|
64
|
-
nvector[3],
|
|
65
|
-
-nvector[4],
|
|
66
|
-
-nvector[5],
|
|
67
|
-
-nvector[6],
|
|
68
|
-
-nvector[7],
|
|
69
|
-
];
|
|
70
|
-
// Poincare duality operator.
|
|
71
|
-
export const dual = (nvector) => [
|
|
72
|
-
nvector[7],
|
|
73
|
-
nvector[6],
|
|
74
|
-
nvector[5],
|
|
75
|
-
nvector[4],
|
|
76
|
-
nvector[3],
|
|
77
|
-
nvector[2],
|
|
78
|
-
nvector[1],
|
|
79
|
-
nvector[0],
|
|
80
|
-
];
|
|
81
|
-
// Clifford Conjugation
|
|
82
|
-
export const conjugate = (nvector) => [
|
|
83
|
-
nvector[0],
|
|
84
|
-
-nvector[1],
|
|
85
|
-
-nvector[2],
|
|
86
|
-
-nvector[3],
|
|
87
|
-
-nvector[4],
|
|
88
|
-
-nvector[5],
|
|
89
|
-
-nvector[6],
|
|
90
|
-
nvector[7],
|
|
91
|
-
];
|
|
92
|
-
// Main involution
|
|
93
|
-
export const involute = (nvector) => [
|
|
94
|
-
nvector[0],
|
|
95
|
-
-nvector[1],
|
|
96
|
-
-nvector[2],
|
|
97
|
-
-nvector[3],
|
|
98
|
-
nvector[4],
|
|
99
|
-
nvector[5],
|
|
100
|
-
nvector[6],
|
|
101
|
-
-nvector[7],
|
|
102
|
-
];
|
|
103
|
-
// Multivector addition
|
|
104
|
-
export const add = (a, b) => {
|
|
105
|
-
if (isNumber(b)) {
|
|
106
|
-
return [a[0] + b, a[1], a[2], a[3], a[4], a[5], a[6], a[7]];
|
|
107
|
-
}
|
|
108
|
-
return [
|
|
109
|
-
a[0] + b[0],
|
|
110
|
-
a[1] + b[1],
|
|
111
|
-
a[2] + b[2],
|
|
112
|
-
a[3] + b[3],
|
|
113
|
-
a[4] + b[4],
|
|
114
|
-
a[5] + b[5],
|
|
115
|
-
a[6] + b[6],
|
|
116
|
-
a[7] + b[7],
|
|
117
|
-
];
|
|
118
|
-
};
|
|
119
|
-
// Multivector subtraction
|
|
120
|
-
export const sub = (a, b) => {
|
|
121
|
-
if (isNumber(b)) {
|
|
122
|
-
return [a[0] - b, a[1], a[2], a[3], a[4], a[5], a[6], a[7]];
|
|
123
|
-
}
|
|
124
|
-
return [
|
|
125
|
-
a[0] - b[0],
|
|
126
|
-
a[1] - b[1],
|
|
127
|
-
a[2] - b[2],
|
|
128
|
-
a[3] - b[3],
|
|
129
|
-
a[4] - b[4],
|
|
130
|
-
a[5] - b[5],
|
|
131
|
-
a[6] - b[6],
|
|
132
|
-
a[7] - b[7],
|
|
133
|
-
];
|
|
134
|
-
};
|
|
135
|
-
// The geometric product.
|
|
136
|
-
export const mul = (a, b) => {
|
|
137
|
-
if (isNumber(b)) {
|
|
138
|
-
return [
|
|
139
|
-
a[0] * b,
|
|
140
|
-
a[1] * b,
|
|
141
|
-
a[2] * b,
|
|
142
|
-
a[3] * b,
|
|
143
|
-
a[4] * b,
|
|
144
|
-
a[5] * b,
|
|
145
|
-
a[6] * b,
|
|
146
|
-
a[7] * b,
|
|
147
|
-
];
|
|
148
|
-
}
|
|
149
|
-
return [
|
|
150
|
-
mulScalar(a, b),
|
|
151
|
-
b[1] * a[0] +
|
|
152
|
-
b[0] * a[1] -
|
|
153
|
-
b[4] * a[2] +
|
|
154
|
-
b[5] * a[3] +
|
|
155
|
-
b[2] * a[4] -
|
|
156
|
-
b[3] * a[5] -
|
|
157
|
-
b[7] * a[6] -
|
|
158
|
-
b[6] * a[7],
|
|
159
|
-
b[2] * a[0] + b[0] * a[2] - b[6] * a[3] + b[3] * a[6],
|
|
160
|
-
b[3] * a[0] + b[6] * a[2] + b[0] * a[3] - b[2] * a[6],
|
|
161
|
-
b[4] * a[0] +
|
|
162
|
-
b[2] * a[1] -
|
|
163
|
-
b[1] * a[2] +
|
|
164
|
-
b[7] * a[3] +
|
|
165
|
-
b[0] * a[4] +
|
|
166
|
-
b[6] * a[5] -
|
|
167
|
-
b[5] * a[6] +
|
|
168
|
-
b[3] * a[7],
|
|
169
|
-
b[5] * a[0] -
|
|
170
|
-
b[3] * a[1] +
|
|
171
|
-
b[7] * a[2] +
|
|
172
|
-
b[1] * a[3] -
|
|
173
|
-
b[6] * a[4] +
|
|
174
|
-
b[0] * a[5] +
|
|
175
|
-
b[4] * a[6] +
|
|
176
|
-
b[2] * a[7],
|
|
177
|
-
b[6] * a[0] + b[3] * a[2] - b[2] * a[3] + b[0] * a[6],
|
|
178
|
-
b[7] * a[0] +
|
|
179
|
-
b[6] * a[1] +
|
|
180
|
-
b[5] * a[2] +
|
|
181
|
-
b[4] * a[3] +
|
|
182
|
-
b[3] * a[4] +
|
|
183
|
-
b[2] * a[5] +
|
|
184
|
-
b[1] * a[6] +
|
|
185
|
-
b[0] * a[7],
|
|
186
|
-
];
|
|
187
|
-
};
|
|
188
|
-
export const mulScalar = (a, b) => b[0] * a[0] + b[2] * a[2] + b[3] * a[3] - b[6] * a[6];
|
|
189
|
-
// The outer/exterior/wedge product.
|
|
190
|
-
export const meet = (a, b) => [
|
|
191
|
-
b[0] * a[0],
|
|
192
|
-
b[1] * a[0] + b[0] * a[1],
|
|
193
|
-
b[2] * a[0] + b[0] * a[2],
|
|
194
|
-
b[3] * a[0] + b[0] * a[3],
|
|
195
|
-
b[4] * a[0] + b[2] * a[1] - b[1] * a[2] + b[0] * a[4],
|
|
196
|
-
b[5] * a[0] - b[3] * a[1] + b[1] * a[3] + b[0] * a[5],
|
|
197
|
-
b[6] * a[0] + b[3] * a[2] - b[2] * a[3] + b[0] * a[6],
|
|
198
|
-
b[7] * a[0] +
|
|
199
|
-
b[6] * a[1] +
|
|
200
|
-
b[5] * a[2] +
|
|
201
|
-
b[4] * a[3] +
|
|
202
|
-
b[3] * a[4] +
|
|
203
|
-
b[2] * a[5] +
|
|
204
|
-
b[1] * a[6],
|
|
205
|
-
];
|
|
206
|
-
// The regressive product.
|
|
207
|
-
export const join = (a, b) => [
|
|
208
|
-
joinScalar(a, b),
|
|
209
|
-
a[1] * b[7] + a[4] * b[5] - a[5] * b[4] + a[7] * b[1],
|
|
210
|
-
a[2] * b[7] - a[4] * b[6] + a[6] * b[4] + a[7] * b[2],
|
|
211
|
-
a[3] * b[7] + a[5] * b[6] - a[6] * b[5] + a[7] * b[3],
|
|
212
|
-
a[4] * b[7] + a[7] * b[4],
|
|
213
|
-
a[5] * b[7] + a[7] * b[5],
|
|
214
|
-
a[6] * b[7] + a[7] * b[6],
|
|
215
|
-
a[7] * b[7],
|
|
216
|
-
];
|
|
217
|
-
export const joinScalar = (a, b) => a[0] * b[7] +
|
|
218
|
-
a[1] * b[6] +
|
|
219
|
-
a[2] * b[5] +
|
|
220
|
-
a[3] * b[4] +
|
|
221
|
-
a[4] * b[3] +
|
|
222
|
-
a[5] * b[2] +
|
|
223
|
-
a[6] * b[1] +
|
|
224
|
-
a[7] * b[0];
|
|
225
|
-
// The inner product.
|
|
226
|
-
export const dot = (a, b) => [
|
|
227
|
-
b[0] * a[0] + b[2] * a[2] + b[3] * a[3] - b[6] * a[6],
|
|
228
|
-
b[1] * a[0] +
|
|
229
|
-
b[0] * a[1] -
|
|
230
|
-
b[4] * a[2] +
|
|
231
|
-
b[5] * a[3] +
|
|
232
|
-
b[2] * a[4] -
|
|
233
|
-
b[3] * a[5] -
|
|
234
|
-
b[7] * a[6] -
|
|
235
|
-
b[6] * a[7],
|
|
236
|
-
b[2] * a[0] + b[0] * a[2] - b[6] * a[3] + b[3] * a[6],
|
|
237
|
-
b[3] * a[0] + b[6] * a[2] + b[0] * a[3] - b[2] * a[6],
|
|
238
|
-
b[4] * a[0] + b[7] * a[3] + b[0] * a[4] + b[3] * a[7],
|
|
239
|
-
b[5] * a[0] + b[7] * a[2] + b[0] * a[5] + b[2] * a[7],
|
|
240
|
-
b[6] * a[0] + b[0] * a[6],
|
|
241
|
-
b[7] * a[0] + b[0] * a[7],
|
|
242
|
-
];
|
|
243
|
-
export const norm = (a) => Math.sqrt(Math.abs(a[0] * a[0] - a[2] * a[2] - a[3] * a[3] + a[6] * a[6]));
|
|
244
|
-
export const inorm = (a) => Math.sqrt(Math.abs(a[7] * a[7] - a[5] * a[5] - a[4] * a[4] + a[1] * a[1]));
|
|
245
|
-
export const normalized = (a) => {
|
|
246
|
-
const n = norm(a);
|
|
247
|
-
if (n === 0 || n === 1) {
|
|
248
|
-
return a;
|
|
249
|
-
}
|
|
250
|
-
const sign = a[6] < 0 ? -1 : 1;
|
|
251
|
-
return mul(a, sign / n);
|
|
252
|
-
};
|
|
253
|
-
export const inormalized = (a) => {
|
|
254
|
-
const n = inorm(a);
|
|
255
|
-
if (n === 0 || n === 1) {
|
|
256
|
-
return a;
|
|
257
|
-
}
|
|
258
|
-
return mul(a, 1 / n);
|
|
259
|
-
};
|
|
260
|
-
const isNumber = (a) => typeof a === "number";
|
|
261
|
-
export const E0 = nvector(1, 1);
|
|
262
|
-
export const E1 = nvector(1, 2);
|
|
263
|
-
export const E2 = nvector(1, 3);
|
|
264
|
-
export const E01 = nvector(1, 4);
|
|
265
|
-
export const E20 = nvector(1, 5);
|
|
266
|
-
export const E12 = nvector(1, 6);
|
|
267
|
-
export const E012 = nvector(1, 7);
|
|
268
|
-
export const I = E012;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Line, Direction, Point } from "ducjs/legacy/v1/utils/math/algebra/ga";
|
|
2
|
-
/**
|
|
3
|
-
* A direction is stored as an array `[0, 0, 0, 0, y, x, 0, 0]` representing
|
|
4
|
-
* vector `(x, y)`.
|
|
5
|
-
*/
|
|
6
|
-
export declare const from: (point: Point) => Point;
|
|
7
|
-
export declare const fromTo: (from: Point, to: Point) => Direction;
|
|
8
|
-
export declare const orthogonal: (direction: Direction) => Direction;
|
|
9
|
-
export declare const orthogonalToLine: (line: Line) => Direction;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import * as GA from "ducjs/legacy/v1/utils/math/algebra/ga";
|
|
2
|
-
/**
|
|
3
|
-
* A direction is stored as an array `[0, 0, 0, 0, y, x, 0, 0]` representing
|
|
4
|
-
* vector `(x, y)`.
|
|
5
|
-
*/
|
|
6
|
-
export const from = (point) => [
|
|
7
|
-
0,
|
|
8
|
-
0,
|
|
9
|
-
0,
|
|
10
|
-
0,
|
|
11
|
-
point[4],
|
|
12
|
-
point[5],
|
|
13
|
-
0,
|
|
14
|
-
0,
|
|
15
|
-
];
|
|
16
|
-
export const fromTo = (from, to) => GA.inormalized([0, 0, 0, 0, to[4] - from[4], to[5] - from[5], 0, 0]);
|
|
17
|
-
export const orthogonal = (direction) => GA.inormalized([0, 0, 0, 0, -direction[5], direction[4], 0, 0]);
|
|
18
|
-
export const orthogonalToLine = (line) => GA.mul(line, GA.I);
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { Line, Point } from "ducjs/legacy/v1/utils/math/algebra/ga";
|
|
2
|
-
/**
|
|
3
|
-
* A line is stored as an array `[0, c, a, b, 0, 0, 0, 0]` representing:
|
|
4
|
-
* c * e0 + a * e1 + b*e2
|
|
5
|
-
*
|
|
6
|
-
* This maps to a standard formula `a * x + b * y + c`.
|
|
7
|
-
*
|
|
8
|
-
* `(-b, a)` corresponds to a 2D vector parallel to the line. The lines
|
|
9
|
-
* have a natural orientation, corresponding to that vector.
|
|
10
|
-
*
|
|
11
|
-
* The magnitude ("norm") of the line is `sqrt(a ^ 2 + b ^ 2)`.
|
|
12
|
-
* `c / norm(line)` is the oriented distance from line to origin.
|
|
13
|
-
*/
|
|
14
|
-
export declare const vector: (x: number, y: number) => Line;
|
|
15
|
-
export declare const equation: (a: number, b: number, c: number) => Line;
|
|
16
|
-
export declare const through: (from: Point, to: Point) => Line;
|
|
17
|
-
export declare const orthogonal: (line: Line, point: Point) => Line;
|
|
18
|
-
export declare const orthogonalThrough: (against: Point, intersection: Point) => Line;
|
|
19
|
-
export declare const parallel: (line: Line, distance: number) => Line;
|
|
20
|
-
export declare const parallelThrough: (line: Line, point: Point) => Line;
|
|
21
|
-
export declare const distance: (line1: Line, line2: Line) => number;
|
|
22
|
-
export declare const angle: (line1: Line, line2: Line) => number;
|
|
23
|
-
export declare const sign: (line: Line) => number;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import * as GA from "ducjs/legacy/v1/utils/math/algebra/ga";
|
|
2
|
-
/**
|
|
3
|
-
* A line is stored as an array `[0, c, a, b, 0, 0, 0, 0]` representing:
|
|
4
|
-
* c * e0 + a * e1 + b*e2
|
|
5
|
-
*
|
|
6
|
-
* This maps to a standard formula `a * x + b * y + c`.
|
|
7
|
-
*
|
|
8
|
-
* `(-b, a)` corresponds to a 2D vector parallel to the line. The lines
|
|
9
|
-
* have a natural orientation, corresponding to that vector.
|
|
10
|
-
*
|
|
11
|
-
* The magnitude ("norm") of the line is `sqrt(a ^ 2 + b ^ 2)`.
|
|
12
|
-
* `c / norm(line)` is the oriented distance from line to origin.
|
|
13
|
-
*/
|
|
14
|
-
// Returns line with direction (x, y) through origin
|
|
15
|
-
export const vector = (x, y) => GA.normalized([0, 0, -y, x, 0, 0, 0, 0]);
|
|
16
|
-
// For equation ax + by + c = 0.
|
|
17
|
-
export const equation = (a, b, c) => GA.normalized([0, c, a, b, 0, 0, 0, 0]);
|
|
18
|
-
export const through = (from, to) => GA.normalized(GA.join(to, from));
|
|
19
|
-
export const orthogonal = (line, point) => GA.dot(line, point);
|
|
20
|
-
// Returns a line perpendicular to the line through `against` and `intersection`
|
|
21
|
-
// going through `intersection`.
|
|
22
|
-
export const orthogonalThrough = (against, intersection) => orthogonal(through(against, intersection), intersection);
|
|
23
|
-
export const parallel = (line, distance) => {
|
|
24
|
-
const result = line.slice();
|
|
25
|
-
result[1] -= distance;
|
|
26
|
-
return result;
|
|
27
|
-
};
|
|
28
|
-
export const parallelThrough = (line, point) => orthogonal(orthogonal(point, line), point);
|
|
29
|
-
export const distance = (line1, line2) => GA.inorm(GA.meet(line1, line2));
|
|
30
|
-
export const angle = (line1, line2) => Math.acos(GA.dot(line1, line2)[0]);
|
|
31
|
-
// The orientation of the line
|
|
32
|
-
export const sign = (line) => Math.sign(line[1]);
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Point, Line } from "ducjs/legacy/v1/utils/math/algebra/ga";
|
|
2
|
-
export declare const from: ([x, y]: readonly [number, number]) => Point;
|
|
3
|
-
export declare const toTuple: (point: Point) => [number, number];
|
|
4
|
-
export declare const abs: (point: Point) => Point;
|
|
5
|
-
export declare const intersect: (line1: Line, line2: Line) => Point;
|
|
6
|
-
export declare const project: (point: Point, line: Line) => Point;
|
|
7
|
-
export declare const distance: (point1: Point, point2: Point) => number;
|
|
8
|
-
export declare const distanceToLine: (point: Point, line: Line) => number;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import * as GA from "ducjs/legacy/v1/utils/math/algebra/ga";
|
|
2
|
-
import * as GALine from "ducjs/legacy/v1/utils/math/algebra/galines";
|
|
3
|
-
import { join } from "ducjs/legacy/v1/utils/math/algebra/ga";
|
|
4
|
-
export const from = ([x, y]) => [
|
|
5
|
-
0,
|
|
6
|
-
0,
|
|
7
|
-
0,
|
|
8
|
-
0,
|
|
9
|
-
y,
|
|
10
|
-
x,
|
|
11
|
-
1,
|
|
12
|
-
0,
|
|
13
|
-
];
|
|
14
|
-
export const toTuple = (point) => [point[5], point[4]];
|
|
15
|
-
export const abs = (point) => [
|
|
16
|
-
0,
|
|
17
|
-
0,
|
|
18
|
-
0,
|
|
19
|
-
0,
|
|
20
|
-
Math.abs(point[4]),
|
|
21
|
-
Math.abs(point[5]),
|
|
22
|
-
1,
|
|
23
|
-
0,
|
|
24
|
-
];
|
|
25
|
-
export const intersect = (line1, line2) => GA.normalized(GA.meet(line1, line2));
|
|
26
|
-
// Projects `point` onto the `line`.
|
|
27
|
-
// The returned point is the closest point on the `line` to the `point`.
|
|
28
|
-
export const project = (point, line) => intersect(GALine.orthogonal(line, point), line);
|
|
29
|
-
export const distance = (point1, point2) => GA.norm(join(point1, point2));
|
|
30
|
-
export const distanceToLine = (point, line) => GA.joinScalar(point, line);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Line, Direction, Point, Transform } from "ducjs/legacy/v1/utils/math/algebra/ga";
|
|
2
|
-
/**
|
|
3
|
-
* TODO: docs
|
|
4
|
-
*/
|
|
5
|
-
export declare const rotation: (pivot: Point, angle: number) => Transform;
|
|
6
|
-
export declare const translation: (direction: Direction) => Transform;
|
|
7
|
-
export declare const translationOrthogonal: (direction: Direction, distance: number) => Transform;
|
|
8
|
-
export declare const translationAlong: (line: Line, distance: number) => Transform;
|
|
9
|
-
export declare const compose: (motor1: Transform, motor2: Transform) => Transform;
|
|
10
|
-
export declare const apply: (motor: Transform, nvector: Point | Direction | Line) => Point | Direction | Line;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import * as GA from "ducjs/legacy/v1/utils/math/algebra/ga";
|
|
2
|
-
import * as GADirection from "ducjs/legacy/v1/utils/math/algebra/gadirections";
|
|
3
|
-
/**
|
|
4
|
-
* TODO: docs
|
|
5
|
-
*/
|
|
6
|
-
export const rotation = (pivot, angle) => GA.add(GA.mul(pivot, Math.sin(angle / 2)), Math.cos(angle / 2));
|
|
7
|
-
export const translation = (direction) => [
|
|
8
|
-
1,
|
|
9
|
-
0,
|
|
10
|
-
0,
|
|
11
|
-
0,
|
|
12
|
-
-(0.5 * direction[5]),
|
|
13
|
-
0.5 * direction[4],
|
|
14
|
-
0,
|
|
15
|
-
0,
|
|
16
|
-
];
|
|
17
|
-
export const translationOrthogonal = (direction, distance) => {
|
|
18
|
-
const scale = 0.5 * distance;
|
|
19
|
-
return [1, 0, 0, 0, scale * direction[4], scale * direction[5], 0, 0];
|
|
20
|
-
};
|
|
21
|
-
export const translationAlong = (line, distance) => GA.add(GA.mul(GADirection.orthogonalToLine(line), 0.5 * distance), 1);
|
|
22
|
-
export const compose = (motor1, motor2) => GA.mul(motor2, motor1);
|
|
23
|
-
export const apply = (motor, nvector) => GA.normalized(GA.mul(GA.mul(motor, nvector), GA.reverse(motor)));
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Bounds, LineSegment } from "ducjs/legacy/v1/types/geometryTypes";
|
|
2
|
-
import { GeometricPoint } from "ducjs/legacy/v1/types/geometryTypes";
|
|
3
|
-
export declare function getBBox(line: LineSegment): Bounds;
|
|
4
|
-
export declare function crossProduct(a: GeometricPoint, b: GeometricPoint): number;
|
|
5
|
-
export declare function doBBoxesIntersect(a: Bounds, b: Bounds): boolean;
|
|
6
|
-
export declare function translate(a: GeometricPoint, b: GeometricPoint): GeometricPoint;
|
|
7
|
-
export declare function isPointOnLine(l: LineSegment, p: GeometricPoint): boolean;
|
|
8
|
-
export declare function isPointRightOfLine(l: LineSegment, p: GeometricPoint): boolean;
|
|
9
|
-
export declare function isLineSegmentTouchingOrCrossingLine(a: LineSegment, b: LineSegment): boolean;
|
|
10
|
-
export declare function doLineSegmentsIntersect(a: LineSegment, b: LineSegment): boolean;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
export function getBBox(line) {
|
|
2
|
-
return [
|
|
3
|
-
Math.min(line[0].x, line[1].x),
|
|
4
|
-
Math.min(line[0].y, line[1].y),
|
|
5
|
-
Math.max(line[0].x, line[1].x),
|
|
6
|
-
Math.max(line[0].y, line[1].y),
|
|
7
|
-
];
|
|
8
|
-
}
|
|
9
|
-
export function crossProduct(a, b) {
|
|
10
|
-
return a.x * b.y - b.x * a.y;
|
|
11
|
-
}
|
|
12
|
-
export function doBBoxesIntersect(a, b) {
|
|
13
|
-
return a[0] <= b[2] && a[2] >= b[0] && a[1] <= b[3] && a[3] >= b[1];
|
|
14
|
-
}
|
|
15
|
-
export function translate(a, b) {
|
|
16
|
-
return { x: a.x - b.x, y: a.y - b.y };
|
|
17
|
-
}
|
|
18
|
-
const EPSILON = 0.000001;
|
|
19
|
-
export function isPointOnLine(l, p) {
|
|
20
|
-
const p1 = translate(l[1], l[0]);
|
|
21
|
-
const p2 = translate(p, l[0]);
|
|
22
|
-
const r = crossProduct(p1, p2);
|
|
23
|
-
return Math.abs(r) < EPSILON;
|
|
24
|
-
}
|
|
25
|
-
export function isPointRightOfLine(l, p) {
|
|
26
|
-
const p1 = translate(l[1], l[0]);
|
|
27
|
-
const p2 = translate(p, l[0]);
|
|
28
|
-
return crossProduct(p1, p2) < 0;
|
|
29
|
-
}
|
|
30
|
-
export function isLineSegmentTouchingOrCrossingLine(a, b) {
|
|
31
|
-
return (isPointOnLine(a, b[0]) ||
|
|
32
|
-
isPointOnLine(a, b[1]) ||
|
|
33
|
-
(isPointRightOfLine(a, b[0])
|
|
34
|
-
? !isPointRightOfLine(a, b[1])
|
|
35
|
-
: isPointRightOfLine(a, b[1])));
|
|
36
|
-
}
|
|
37
|
-
// https://martin-thoma.com/how-to-check-if-two-line-segments-intersect/
|
|
38
|
-
export function doLineSegmentsIntersect(a, b) {
|
|
39
|
-
return (doBBoxesIntersect(getBBox(a), getBBox(b)) &&
|
|
40
|
-
isLineSegmentTouchingOrCrossingLine(a, b) &&
|
|
41
|
-
isLineSegmentTouchingOrCrossingLine(b, a));
|
|
42
|
-
}
|