@automovie/recovery 0.0.0 → 0.2.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/lib/compilation/index.d.ts +2 -2
- package/lib/compilation/index.js +16 -5
- package/lib/compilation/index.js.map +1 -1
- package/lib/curves/AutoMovieRecoveryCompactApproximation.d.ts +125 -0
- package/lib/curves/AutoMovieRecoveryCompactApproximation.js +62 -0
- package/lib/curves/AutoMovieRecoveryCompactApproximation.js.map +1 -0
- package/lib/curves/AutoMovieRecoveryConicApproximation.d.ts +218 -0
- package/lib/curves/AutoMovieRecoveryConicApproximation.js +113 -0
- package/lib/curves/AutoMovieRecoveryConicApproximation.js.map +1 -0
- package/lib/curves/approximateAutoMovieRecoveryCompactCurves.d.ts +30 -0
- package/lib/curves/approximateAutoMovieRecoveryCompactCurves.js +303 -0
- package/lib/curves/approximateAutoMovieRecoveryCompactCurves.js.map +1 -0
- package/lib/curves/approximateAutoMovieRecoveryConicsAhn.d.ts +39 -0
- package/lib/curves/approximateAutoMovieRecoveryConicsAhn.js +289 -0
- package/lib/curves/approximateAutoMovieRecoveryConicsAhn.js.map +1 -0
- package/lib/curves/approximateAutoMovieRecoveryConicsGhosh.d.ts +32 -0
- package/lib/curves/approximateAutoMovieRecoveryConicsGhosh.js +350 -0
- package/lib/curves/approximateAutoMovieRecoveryConicsGhosh.js.map +1 -0
- package/lib/curves/findAutoMovieRecoveryCubicCriticalParameters.d.ts +29 -0
- package/lib/curves/findAutoMovieRecoveryCubicCriticalParameters.js +77 -0
- package/lib/curves/findAutoMovieRecoveryCubicCriticalParameters.js.map +1 -0
- package/lib/curves/index.d.ts +6 -1
- package/lib/curves/index.js +20 -3
- package/lib/curves/index.js.map +1 -1
- package/lib/fitting/index.d.ts +2 -2
- package/lib/fitting/index.js +16 -5
- package/lib/fitting/index.js.map +1 -1
- package/lib/index.d.ts +6 -57
- package/lib/index.js +6 -57
- package/lib/index.js.map +1 -1
- package/lib/internal/GhoshConicApproximationBalance.d.ts +25 -0
- package/lib/internal/GhoshConicApproximationBalance.js +177 -0
- package/lib/internal/GhoshConicApproximationBalance.js.map +1 -0
- package/lib/internal/GhoshConicApproximationDisplacement.d.ts +23 -0
- package/lib/internal/GhoshConicApproximationDisplacement.js +77 -0
- package/lib/internal/GhoshConicApproximationDisplacement.js.map +1 -0
- package/lib/internal/index.d.ts +183 -0
- package/lib/internal/index.js +200 -0
- package/lib/internal/index.js.map +1 -0
- package/lib/internal/mesh-observations/index.d.ts +1 -2
- package/lib/internal/mesh-observations/index.js +1 -2
- package/lib/internal/mesh-observations/index.js.map +1 -1
- package/lib/observation/index.d.ts +15 -15
- package/lib/observation/index.js +29 -31
- package/lib/observation/index.js.map +1 -1
- package/lib/reconstruction/index.d.ts +10 -10
- package/lib/reconstruction/index.js +24 -21
- package/lib/reconstruction/index.js.map +1 -1
- package/lib/structures/curve/index.d.ts +15 -15
- package/lib/structures/curve/index.js +29 -0
- package/lib/structures/curve/index.js.map +1 -1
- package/lib/structures/domain/index.d.ts +45 -45
- package/lib/structures/domain/index.js +59 -0
- package/lib/structures/domain/index.js.map +1 -1
- package/lib/structures/image/index.d.ts +45 -45
- package/lib/structures/image/index.js +59 -0
- package/lib/structures/image/index.js.map +1 -1
- package/lib/structures/index.d.ts +1 -0
- package/lib/structures/index.js +1 -0
- package/lib/structures/index.js.map +1 -1
- package/lib/structures/internal/index.d.ts +58 -0
- package/lib/structures/internal/index.js +75 -0
- package/lib/structures/internal/index.js.map +1 -0
- package/lib/structures/mesh/index.d.ts +19 -19
- package/lib/structures/mesh/index.js +33 -0
- package/lib/structures/mesh/index.js.map +1 -1
- package/lib/structures/node/index.d.ts +23 -23
- package/lib/structures/node/index.js +37 -0
- package/lib/structures/node/index.js.map +1 -1
- package/lib/structures/observation/index.d.ts +15 -15
- package/lib/structures/observation/index.js +29 -0
- package/lib/structures/observation/index.js.map +1 -1
- package/lib/structures/operation/index.d.ts +10 -10
- package/lib/structures/operation/index.js +24 -0
- package/lib/structures/operation/index.js.map +1 -1
- package/lib/typings/index.d.ts +6 -6
- package/lib/typings/index.js +20 -0
- package/lib/typings/index.js.map +1 -1
- package/package.json +6 -6
- package/src/compilation/index.ts +2 -2
- package/src/curves/AutoMovieRecoveryCompactApproximation.ts +149 -0
- package/src/curves/AutoMovieRecoveryConicApproximation.ts +282 -0
- package/src/curves/approximateAutoMovieRecoveryCompactCurves.ts +285 -0
- package/src/curves/approximateAutoMovieRecoveryConicsAhn.ts +315 -0
- package/src/curves/approximateAutoMovieRecoveryConicsGhosh.ts +444 -0
- package/src/curves/findAutoMovieRecoveryCubicCriticalParameters.ts +76 -0
- package/src/curves/index.ts +6 -1
- package/src/fitting/index.ts +2 -2
- package/src/index.ts +6 -57
- package/src/internal/GhoshConicApproximationBalance.ts +184 -0
- package/src/internal/GhoshConicApproximationDisplacement.ts +83 -0
- package/src/internal/index.ts +183 -0
- package/src/internal/mesh-observations/index.ts +1 -2
- package/src/observation/index.ts +15 -15
- package/src/reconstruction/index.ts +10 -10
- package/src/structures/curve/index.ts +15 -15
- package/src/structures/domain/index.ts +45 -45
- package/src/structures/image/index.ts +45 -45
- package/src/structures/index.ts +1 -0
- package/src/structures/internal/index.ts +58 -0
- package/src/structures/mesh/index.ts +19 -19
- package/src/structures/node/index.ts +23 -23
- package/src/structures/observation/index.ts +15 -15
- package/src/structures/operation/index.ts +10 -10
- package/src/typings/index.ts +6 -6
package/lib/index.d.ts
CHANGED
|
@@ -1,59 +1,8 @@
|
|
|
1
|
-
export * from "./structures";
|
|
2
|
-
export * from "./typings";
|
|
3
|
-
export * from "./observation";
|
|
4
|
-
export * from "./fitting";
|
|
5
1
|
export * from "./compilation";
|
|
6
|
-
export * from "./reconstruction";
|
|
7
2
|
export * from "./curves";
|
|
8
|
-
export * from "./
|
|
9
|
-
export * from "./
|
|
10
|
-
export * from "./
|
|
11
|
-
export * from "./
|
|
12
|
-
export * from "./structures
|
|
13
|
-
export * from "./
|
|
14
|
-
export * from "./structures/node/IAutoMovieRecoveryArtifactInput";
|
|
15
|
-
export * from "./structures/node/IAutoMovieRecoveryArraySource";
|
|
16
|
-
export * from "./structures/node/IAutoMovieRecoveryByteDigest";
|
|
17
|
-
export * from "./structures/image/IAutoMovieRecoveryImageFiles";
|
|
18
|
-
export * from "./structures/image/IAutoMovieRecoveryCameraFiles";
|
|
19
|
-
export * from "./structures/image/IAutoMovieRecoveryCameraMapFiles";
|
|
20
|
-
export * from "./structures/image/IAutoMovieRecoveryCameraSceneFiles";
|
|
21
|
-
export * from "./observation/observeAutoMovieRecoveryAtlas";
|
|
22
|
-
export * from "./structures/image/IAutoMovieRecoveryCameraFile";
|
|
23
|
-
export * from "./curves/convertAutoMovieRecoveryCurves";
|
|
24
|
-
export * from "./observation/observeAutoMovieRecovery";
|
|
25
|
-
export * from "./observation/prepareAutoMovieRecoveryInput";
|
|
26
|
-
export * from "./reconstruction/reconstructAutoMovieRecoveryModel";
|
|
27
|
-
export * from "./structures/mesh/IAutoMovieRecoveryMeshSections";
|
|
28
|
-
export * from "./typings/AutoMovieRecoveryCurveFormat";
|
|
29
|
-
export * from "./typings/IAutoMovieRecoveryResult";
|
|
30
|
-
export * from "./reconstruction/compileAutoMovieRecoveryAtlas";
|
|
31
|
-
export * from "./observation/estimateAutoMovieRecoveryCameraMap";
|
|
32
|
-
export * from "./observation/estimateAutoMovieRecoveryCameraScene";
|
|
33
|
-
export * from "./observation/estimateAutoMovieRecoveryCameraPair";
|
|
34
|
-
export * from "./compilation/compileAutoMovieRecoveryImageLoft";
|
|
35
|
-
export * from "./compilation/compileAutoMovieRecoverySupportLoft";
|
|
36
|
-
export * from "./fitting/fitAutoMovieRecoveryImageLoft";
|
|
37
|
-
export * from "./fitting/fitAutoMovieRecoveryImageSupportLoft";
|
|
38
|
-
export * from "./observation/observeAutoMovieRecoveryImages";
|
|
39
|
-
export * from "./internal/restoreRecoveryCurveBasis";
|
|
40
|
-
export * from "./reconstruction/applyAutoMovieRecoveryAnalyticPublication";
|
|
41
|
-
export * from "./structures/domain/IAutoMovieRecoveryTensorFamiliesInput";
|
|
42
|
-
export * from "./internal/reconstructRecoveryOpen";
|
|
43
|
-
export * from "./reconstruction/AutoMovieRecoveryOpenContinuation";
|
|
44
|
-
export * from "./structures/node/IAutoMovieRecoveryContourFileMesh";
|
|
45
|
-
export * from "./structures/node/IAutoMovieRecoveryFileReceipt";
|
|
46
|
-
export * from "./structures/node/IAutoMovieRecoveryMeshChunkOwner";
|
|
47
|
-
export * from "./structures/node/IAutoMovieRecoveryMeshSpool";
|
|
48
|
-
export * from "./structures/node/IAutoMovieRecoveryMeshFrontier";
|
|
49
|
-
export * from "./structures/node/IAutoMovieRecoveryMeshFrontierInput";
|
|
50
|
-
export * from "./structures/operation/IAutoMovieRecoveryPublication";
|
|
51
|
-
export * from "./structures/operation/IAutoMovieRecoveryPublicationOptions";
|
|
52
|
-
export * from "./internal/RecoveryLocalRunReport";
|
|
53
|
-
export * from "./internal/describeRecoveryOpenRun";
|
|
54
|
-
export * from "./internal/normalizeRecoveryCourse";
|
|
55
|
-
export * from "./internal/prepareRecoveryLocalContinuation";
|
|
56
|
-
export * from "./internal/reconstructRecovery";
|
|
57
|
-
export * from "./reconstruction/realizeAutoMovieRecoveryAnalyticDomains";
|
|
58
|
-
export * from "./structures/node/IAutoMovieRecoveryLocalBinding";
|
|
59
|
-
export * from "./structures/node/IAutoMovieRecoveryLocalResult";
|
|
3
|
+
export * from "./fitting";
|
|
4
|
+
export * from "./internal";
|
|
5
|
+
export * from "./observation";
|
|
6
|
+
export * from "./reconstruction";
|
|
7
|
+
export * from "./structures";
|
|
8
|
+
export * from "./typings";
|
package/lib/index.js
CHANGED
|
@@ -14,63 +14,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./structures"), exports);
|
|
18
|
-
__exportStar(require("./typings"), exports);
|
|
19
|
-
__exportStar(require("./observation"), exports);
|
|
20
|
-
__exportStar(require("./fitting"), exports);
|
|
21
17
|
__exportStar(require("./compilation"), exports);
|
|
22
|
-
__exportStar(require("./reconstruction"), exports);
|
|
23
18
|
__exportStar(require("./curves"), exports);
|
|
24
|
-
__exportStar(require("./
|
|
25
|
-
__exportStar(require("./
|
|
26
|
-
__exportStar(require("./
|
|
27
|
-
__exportStar(require("./
|
|
28
|
-
__exportStar(require("./structures
|
|
29
|
-
__exportStar(require("./
|
|
30
|
-
__exportStar(require("./structures/node/IAutoMovieRecoveryArtifactInput"), exports);
|
|
31
|
-
__exportStar(require("./structures/node/IAutoMovieRecoveryArraySource"), exports);
|
|
32
|
-
__exportStar(require("./structures/node/IAutoMovieRecoveryByteDigest"), exports);
|
|
33
|
-
__exportStar(require("./structures/image/IAutoMovieRecoveryImageFiles"), exports);
|
|
34
|
-
__exportStar(require("./structures/image/IAutoMovieRecoveryCameraFiles"), exports);
|
|
35
|
-
__exportStar(require("./structures/image/IAutoMovieRecoveryCameraMapFiles"), exports);
|
|
36
|
-
__exportStar(require("./structures/image/IAutoMovieRecoveryCameraSceneFiles"), exports);
|
|
37
|
-
__exportStar(require("./observation/observeAutoMovieRecoveryAtlas"), exports);
|
|
38
|
-
__exportStar(require("./structures/image/IAutoMovieRecoveryCameraFile"), exports);
|
|
39
|
-
__exportStar(require("./curves/convertAutoMovieRecoveryCurves"), exports);
|
|
40
|
-
__exportStar(require("./observation/observeAutoMovieRecovery"), exports);
|
|
41
|
-
__exportStar(require("./observation/prepareAutoMovieRecoveryInput"), exports);
|
|
42
|
-
__exportStar(require("./reconstruction/reconstructAutoMovieRecoveryModel"), exports);
|
|
43
|
-
__exportStar(require("./structures/mesh/IAutoMovieRecoveryMeshSections"), exports);
|
|
44
|
-
__exportStar(require("./typings/AutoMovieRecoveryCurveFormat"), exports);
|
|
45
|
-
__exportStar(require("./typings/IAutoMovieRecoveryResult"), exports);
|
|
46
|
-
__exportStar(require("./reconstruction/compileAutoMovieRecoveryAtlas"), exports);
|
|
47
|
-
__exportStar(require("./observation/estimateAutoMovieRecoveryCameraMap"), exports);
|
|
48
|
-
__exportStar(require("./observation/estimateAutoMovieRecoveryCameraScene"), exports);
|
|
49
|
-
__exportStar(require("./observation/estimateAutoMovieRecoveryCameraPair"), exports);
|
|
50
|
-
__exportStar(require("./compilation/compileAutoMovieRecoveryImageLoft"), exports);
|
|
51
|
-
__exportStar(require("./compilation/compileAutoMovieRecoverySupportLoft"), exports);
|
|
52
|
-
__exportStar(require("./fitting/fitAutoMovieRecoveryImageLoft"), exports);
|
|
53
|
-
__exportStar(require("./fitting/fitAutoMovieRecoveryImageSupportLoft"), exports);
|
|
54
|
-
__exportStar(require("./observation/observeAutoMovieRecoveryImages"), exports);
|
|
55
|
-
__exportStar(require("./internal/restoreRecoveryCurveBasis"), exports);
|
|
56
|
-
__exportStar(require("./reconstruction/applyAutoMovieRecoveryAnalyticPublication"), exports);
|
|
57
|
-
__exportStar(require("./structures/domain/IAutoMovieRecoveryTensorFamiliesInput"), exports);
|
|
58
|
-
__exportStar(require("./internal/reconstructRecoveryOpen"), exports);
|
|
59
|
-
__exportStar(require("./reconstruction/AutoMovieRecoveryOpenContinuation"), exports);
|
|
60
|
-
__exportStar(require("./structures/node/IAutoMovieRecoveryContourFileMesh"), exports);
|
|
61
|
-
__exportStar(require("./structures/node/IAutoMovieRecoveryFileReceipt"), exports);
|
|
62
|
-
__exportStar(require("./structures/node/IAutoMovieRecoveryMeshChunkOwner"), exports);
|
|
63
|
-
__exportStar(require("./structures/node/IAutoMovieRecoveryMeshSpool"), exports);
|
|
64
|
-
__exportStar(require("./structures/node/IAutoMovieRecoveryMeshFrontier"), exports);
|
|
65
|
-
__exportStar(require("./structures/node/IAutoMovieRecoveryMeshFrontierInput"), exports);
|
|
66
|
-
__exportStar(require("./structures/operation/IAutoMovieRecoveryPublication"), exports);
|
|
67
|
-
__exportStar(require("./structures/operation/IAutoMovieRecoveryPublicationOptions"), exports);
|
|
68
|
-
__exportStar(require("./internal/RecoveryLocalRunReport"), exports);
|
|
69
|
-
__exportStar(require("./internal/describeRecoveryOpenRun"), exports);
|
|
70
|
-
__exportStar(require("./internal/normalizeRecoveryCourse"), exports);
|
|
71
|
-
__exportStar(require("./internal/prepareRecoveryLocalContinuation"), exports);
|
|
72
|
-
__exportStar(require("./internal/reconstructRecovery"), exports);
|
|
73
|
-
__exportStar(require("./reconstruction/realizeAutoMovieRecoveryAnalyticDomains"), exports);
|
|
74
|
-
__exportStar(require("./structures/node/IAutoMovieRecoveryLocalBinding"), exports);
|
|
75
|
-
__exportStar(require("./structures/node/IAutoMovieRecoveryLocalResult"), exports);
|
|
19
|
+
__exportStar(require("./fitting"), exports);
|
|
20
|
+
__exportStar(require("./internal"), exports);
|
|
21
|
+
__exportStar(require("./observation"), exports);
|
|
22
|
+
__exportStar(require("./reconstruction"), exports);
|
|
23
|
+
__exportStar(require("./structures"), exports);
|
|
24
|
+
__exportStar(require("./typings"), exports);
|
|
76
25
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,2CAAyB;AACzB,4CAA0B;AAC1B,6CAA2B;AAC3B,gDAA8B;AAC9B,mDAAiC;AACjC,+CAA6B;AAC7B,4CAA0B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Balance a bitangent conic's signed normal extrema with numerical exchange.
|
|
3
|
+
* Initial source nodes bracket witnessed displacement peaks. Golden-section
|
|
4
|
+
* refinement locates each such peak between nodes, then its source coordinate
|
|
5
|
+
* joins the coefficient bisection and the two signed lobes are rebalanced.
|
|
6
|
+
* This implements the extrema/equioscillation criterion of Ghosh et al. (2007),
|
|
7
|
+
* sections 3.2–3.3 and 6, without treating a fixed grid maximum as a supremum.
|
|
8
|
+
*
|
|
9
|
+
* The returned tuple is [rho, refined maximum displacement in millimetres].
|
|
10
|
+
* Finite peak brackets still do not certify that an arbitrary callback has no
|
|
11
|
+
* unwitnessed extrema; exhausted exchange or an invalid normal returns absent.
|
|
12
|
+
* Source endpoints have displacement zero by exact endpoint interpolation.
|
|
13
|
+
*
|
|
14
|
+
* @evidence contracts/development/common.md#meaningful-documentation Explains extrema exchange, compactified weight, physical error, endpoint zeros, finite-bracket limits and absent-result effects.
|
|
15
|
+
* @evidence contracts/development/implementation.md#principled-implementation Ghosh's equioscillation minimizes opposing signed normal lobes; scalar bisection is alternated with bracketed extremum optimization instead of accepting sampled maxima. Golden-section convergence stops at binary64 parameter resolution and invalid normal graphs remain unsupported.
|
|
16
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure The helper owns weight/extremum search while its caller owns differential admission, tangent geometry, independent validation and interval coverage.
|
|
17
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts No sample-count increase, inflated fit tolerance, input smoothing, missing-domain bridge or fixture-specific coefficient is used. New fitting nodes are located extrema and a roundoff allowance only controls search convergence.
|
|
18
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms For E bounded exchanges, N initial/located extrema and G golden iterations, time is O(E*(32*N+N*G)); the caller's depth bounds E and binary64 precision bounds G. Source-coordinate caching avoids repeated callbacks at identical parameters.
|
|
19
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work A call-local parameter map reuses source points/normals throughout weight iterations and peak refinement; source identity and interval are fixed for the call.
|
|
20
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources Fit nodes and cached coordinates are bounded by exchanges and golden iterations, discarded on return, and never appear in the returned coefficients.
|
|
21
|
+
*/
|
|
22
|
+
export declare function GhoshConicApproximationBalance(sample: (t: number) => {
|
|
23
|
+
value: readonly number[];
|
|
24
|
+
normal: readonly number[];
|
|
25
|
+
} | undefined, domain: readonly [number, number], bounds: readonly [number, number], maximumExchanges: number, roundoffMm: number): readonly [number, number] | undefined;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GhoshConicApproximationBalance = GhoshConicApproximationBalance;
|
|
4
|
+
const GhoshConicApproximationDisplacement_1 = require("./GhoshConicApproximationDisplacement");
|
|
5
|
+
/**
|
|
6
|
+
* Balance a bitangent conic's signed normal extrema with numerical exchange.
|
|
7
|
+
* Initial source nodes bracket witnessed displacement peaks. Golden-section
|
|
8
|
+
* refinement locates each such peak between nodes, then its source coordinate
|
|
9
|
+
* joins the coefficient bisection and the two signed lobes are rebalanced.
|
|
10
|
+
* This implements the extrema/equioscillation criterion of Ghosh et al. (2007),
|
|
11
|
+
* sections 3.2–3.3 and 6, without treating a fixed grid maximum as a supremum.
|
|
12
|
+
*
|
|
13
|
+
* The returned tuple is [rho, refined maximum displacement in millimetres].
|
|
14
|
+
* Finite peak brackets still do not certify that an arbitrary callback has no
|
|
15
|
+
* unwitnessed extrema; exhausted exchange or an invalid normal returns absent.
|
|
16
|
+
* Source endpoints have displacement zero by exact endpoint interpolation.
|
|
17
|
+
*
|
|
18
|
+
* @evidence contracts/development/common.md#meaningful-documentation Explains extrema exchange, compactified weight, physical error, endpoint zeros, finite-bracket limits and absent-result effects.
|
|
19
|
+
* @evidence contracts/development/implementation.md#principled-implementation Ghosh's equioscillation minimizes opposing signed normal lobes; scalar bisection is alternated with bracketed extremum optimization instead of accepting sampled maxima. Golden-section convergence stops at binary64 parameter resolution and invalid normal graphs remain unsupported.
|
|
20
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure The helper owns weight/extremum search while its caller owns differential admission, tangent geometry, independent validation and interval coverage.
|
|
21
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts No sample-count increase, inflated fit tolerance, input smoothing, missing-domain bridge or fixture-specific coefficient is used. New fitting nodes are located extrema and a roundoff allowance only controls search convergence.
|
|
22
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms For E bounded exchanges, N initial/located extrema and G golden iterations, time is O(E*(32*N+N*G)); the caller's depth bounds E and binary64 precision bounds G. Source-coordinate caching avoids repeated callbacks at identical parameters.
|
|
23
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work A call-local parameter map reuses source points/normals throughout weight iterations and peak refinement; source identity and interval are fixed for the call.
|
|
24
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources Fit nodes and cached coordinates are bounded by exchanges and golden iterations, discarded on return, and never appear in the returned coefficients.
|
|
25
|
+
*/
|
|
26
|
+
function GhoshConicApproximationBalance(sample, domain, bounds, maximumExchanges, roundoffMm) {
|
|
27
|
+
const cache = new Map();
|
|
28
|
+
const witnesses = [];
|
|
29
|
+
const ratio = (Math.sqrt(5) - 1) / 2;
|
|
30
|
+
const goldenIterations = Math.ceil(53 / Math.log2(1 / ratio));
|
|
31
|
+
const parameterRoundoff = 128 *
|
|
32
|
+
Number.EPSILON *
|
|
33
|
+
Math.max(Math.abs(domain[0]), Math.abs(domain[1]), domain[1] - domain[0]);
|
|
34
|
+
/** Reuse deterministic borrowed callbacks, retaining only call-local snapshots. */
|
|
35
|
+
function coordinate(t) {
|
|
36
|
+
const existing = cache.get(t);
|
|
37
|
+
if (existing !== undefined)
|
|
38
|
+
return existing;
|
|
39
|
+
const value = sample(t);
|
|
40
|
+
if (value !== undefined)
|
|
41
|
+
cache.set(t, value);
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
/** Every candidate uses the same normal graph and triangle-branch admission. */
|
|
45
|
+
function observe(t, rho) {
|
|
46
|
+
const value = coordinate(t);
|
|
47
|
+
return value === undefined ? undefined : (0, GhoshConicApproximationDisplacement_1.GhoshConicApproximationDisplacement)(value, rho);
|
|
48
|
+
}
|
|
49
|
+
/** A signed-lobe sum vanishes precisely at the witnessed equioscillation. */
|
|
50
|
+
function imbalance(rho) {
|
|
51
|
+
let positive = 0;
|
|
52
|
+
let negative = 0;
|
|
53
|
+
for (const witness of witnesses) {
|
|
54
|
+
const d = (0, GhoshConicApproximationDisplacement_1.GhoshConicApproximationDisplacement)(witness.coordinate, rho);
|
|
55
|
+
if (d === undefined)
|
|
56
|
+
return undefined;
|
|
57
|
+
positive = Math.max(positive, d);
|
|
58
|
+
negative = Math.min(negative, d);
|
|
59
|
+
}
|
|
60
|
+
return [positive + negative, Math.max(positive, -negative)];
|
|
61
|
+
}
|
|
62
|
+
/** Refine an observed local absolute maximum without increasing a fixed grid. */
|
|
63
|
+
function peak(a, center, b, rho) {
|
|
64
|
+
let left = a.t;
|
|
65
|
+
let right = b.t;
|
|
66
|
+
let x = right - ratio * (right - left);
|
|
67
|
+
let y = left + ratio * (right - left);
|
|
68
|
+
let dx = observe(x, rho);
|
|
69
|
+
let dy = observe(y, rho);
|
|
70
|
+
if (dx === undefined || dy === undefined)
|
|
71
|
+
return undefined;
|
|
72
|
+
let best = center;
|
|
73
|
+
for (let iteration = 0; iteration < goldenIterations; ++iteration) {
|
|
74
|
+
if (Math.abs(dx) > Math.abs(best.d))
|
|
75
|
+
best = { t: x, d: dx };
|
|
76
|
+
if (Math.abs(dy) > Math.abs(best.d))
|
|
77
|
+
best = { t: y, d: dy };
|
|
78
|
+
if (right - left <= parameterRoundoff)
|
|
79
|
+
break;
|
|
80
|
+
if (Math.abs(dx) < Math.abs(dy)) {
|
|
81
|
+
left = x;
|
|
82
|
+
x = y;
|
|
83
|
+
dx = dy;
|
|
84
|
+
y = left + ratio * (right - left);
|
|
85
|
+
dy = observe(y, rho);
|
|
86
|
+
if (dy === undefined)
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
right = y;
|
|
91
|
+
y = x;
|
|
92
|
+
dy = dx;
|
|
93
|
+
x = right - ratio * (right - left);
|
|
94
|
+
dx = observe(x, rho);
|
|
95
|
+
if (dx === undefined)
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return best;
|
|
100
|
+
}
|
|
101
|
+
for (let i = 1; i < 32; ++i) {
|
|
102
|
+
const t = domain[0] + ((domain[1] - domain[0]) * i) / 32;
|
|
103
|
+
const value = coordinate(t);
|
|
104
|
+
if (value === undefined)
|
|
105
|
+
return undefined;
|
|
106
|
+
witnesses.push({ t, coordinate: value });
|
|
107
|
+
}
|
|
108
|
+
for (let exchange = 0; exchange < maximumExchanges; ++exchange) {
|
|
109
|
+
let left = bounds[0];
|
|
110
|
+
let right = bounds[1];
|
|
111
|
+
const el = imbalance(left);
|
|
112
|
+
const er = imbalance(right);
|
|
113
|
+
if (el === undefined || er === undefined)
|
|
114
|
+
return undefined;
|
|
115
|
+
const numericalConic = Math.max(el[1], er[1]) <= roundoffMm;
|
|
116
|
+
if (!numericalConic && el[0] * er[0] > 0)
|
|
117
|
+
return undefined;
|
|
118
|
+
let rho = (left + right) / 2;
|
|
119
|
+
for (let iteration = 0; !numericalConic && iteration < 32; ++iteration) {
|
|
120
|
+
rho = (left + right) / 2;
|
|
121
|
+
const error = imbalance(rho);
|
|
122
|
+
if (error === undefined)
|
|
123
|
+
return undefined;
|
|
124
|
+
if (error[0] * el[0] > 0)
|
|
125
|
+
left = rho;
|
|
126
|
+
else
|
|
127
|
+
right = rho;
|
|
128
|
+
}
|
|
129
|
+
const measured = imbalance(rho);
|
|
130
|
+
if (measured === undefined)
|
|
131
|
+
return undefined;
|
|
132
|
+
if (measured[1] <= roundoffMm)
|
|
133
|
+
return [rho, measured[1]];
|
|
134
|
+
witnesses.sort((a, b) => a.t - b.t);
|
|
135
|
+
const observations = [{ t: domain[0], d: 0 }];
|
|
136
|
+
for (const witness of witnesses) {
|
|
137
|
+
const d = (0, GhoshConicApproximationDisplacement_1.GhoshConicApproximationDisplacement)(witness.coordinate, rho);
|
|
138
|
+
if (d === undefined)
|
|
139
|
+
return undefined;
|
|
140
|
+
observations.push({ t: witness.t, d });
|
|
141
|
+
}
|
|
142
|
+
observations.push({ t: domain[1], d: 0 });
|
|
143
|
+
let maximum = measured[1];
|
|
144
|
+
const located = [];
|
|
145
|
+
for (let i = 1; i + 1 < observations.length; ++i) {
|
|
146
|
+
const before = observations[i - 1];
|
|
147
|
+
const middle = observations[i];
|
|
148
|
+
const after = observations[i + 1];
|
|
149
|
+
if (Math.abs(middle.d) >= Math.abs(before.d) &&
|
|
150
|
+
Math.abs(middle.d) >= Math.abs(after.d) &&
|
|
151
|
+
(Math.abs(middle.d) > Math.abs(before.d) ||
|
|
152
|
+
Math.abs(middle.d) > Math.abs(after.d))) {
|
|
153
|
+
const found = peak(before, middle, after, rho);
|
|
154
|
+
if (found === undefined)
|
|
155
|
+
return undefined;
|
|
156
|
+
located.push(found);
|
|
157
|
+
maximum = Math.max(maximum, Math.abs(found.d));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (maximum <= measured[1] + roundoffMm)
|
|
161
|
+
return [rho, maximum];
|
|
162
|
+
let added = false;
|
|
163
|
+
for (const found of located) {
|
|
164
|
+
if (witnesses.some((witness) => witness.t === found.t))
|
|
165
|
+
continue;
|
|
166
|
+
const value = coordinate(found.t);
|
|
167
|
+
if (value === undefined)
|
|
168
|
+
return undefined;
|
|
169
|
+
witnesses.push({ t: found.t, coordinate: value });
|
|
170
|
+
added = true;
|
|
171
|
+
}
|
|
172
|
+
if (!added)
|
|
173
|
+
return undefined;
|
|
174
|
+
}
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=GhoshConicApproximationBalance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GhoshConicApproximationBalance.js","sourceRoot":"","sources":["../../src/internal/GhoshConicApproximationBalance.ts"],"names":[],"mappings":";;;AAAA,+FAA4G;AAE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,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;QACD,IAAI,OAAO,IAAI,QAAQ,CAAC,CAAC,CAAC,GAAG,UAAU;YAAE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAC/D,IAAI,KAAK,GAAY,KAAK,CAAC;QAC3B,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC5B,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,OAAgB,EAAW,EAAE,CAAC,OAAO,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC;gBACtE,SAAS;YACX,MAAM,KAAK,GAA2B,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAC1D,IAAI,KAAK,KAAK,SAAS;gBAAE,OAAO,SAAS,CAAC;YAC1C,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;YAClD,KAAK,GAAG,IAAI,CAAC;QACf,CAAC;QACD,IAAI,CAAC,KAAK;YAAE,OAAO,SAAS,CAAC;IAC/B,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Intersect a Euclidean unit normal with a compactified bitangent conic family.
|
|
3
|
+
* The barycentric point and normal use the endpoint tangent triangle; normal
|
|
4
|
+
* coordinates have inverse-millimetre units. For rho=w/(1+w), the implicit
|
|
5
|
+
* conic is (1-rho)^2*l1^2-4*rho^2*l0*l2=0. At rho=1 this is the union of the
|
|
6
|
+
* triangle's two tangent edges, used only as a boundary search limit.
|
|
7
|
+
*
|
|
8
|
+
* A finite normal displacement is returned only for a unique intersection in
|
|
9
|
+
* the positive tangent triangle. Two distinct valid roots remain unsupported;
|
|
10
|
+
* a double algebraic root is one geometric intersection. No shape is emitted.
|
|
11
|
+
*
|
|
12
|
+
* @evidence contracts/development/common.md#meaningful-documentation States barycentric units, compactified conic equation, degenerate search limit, unique-root contract and absent geometry output.
|
|
13
|
+
* @evidence contracts/development/implementation.md#principled-implementation The rational quadratic's barycentric implicit equation is divided by (1+w)^2 before taking its w-to-infinity limit. Stable quadratic roots and determinant-roundoff bounds evaluate the original normal intersection without moving source points.
|
|
14
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure This helper owns only normal/conic arithmetic so the public fitter owns differential admission, search and coverage.
|
|
15
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts No source fallback, artificial displacement, tangent replacement or merged distinct normal intersections is used. Roundoff tolerances scale with their actual arithmetic terms.
|
|
16
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms One quadratic, at most two candidate roots and three barycentric tests have constant time and space.
|
|
17
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work Compactified factors and normalized coefficients are computed once and reused for root and triangle admission.
|
|
18
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The synchronous scalar operation retains no coordinates, callback, state or resources after return.
|
|
19
|
+
*/
|
|
20
|
+
export declare function GhoshConicApproximationDisplacement(coordinate: {
|
|
21
|
+
value: readonly number[];
|
|
22
|
+
normal: readonly number[];
|
|
23
|
+
}, rho: number): number | undefined;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GhoshConicApproximationDisplacement = GhoshConicApproximationDisplacement;
|
|
4
|
+
/**
|
|
5
|
+
* Intersect a Euclidean unit normal with a compactified bitangent conic family.
|
|
6
|
+
* The barycentric point and normal use the endpoint tangent triangle; normal
|
|
7
|
+
* coordinates have inverse-millimetre units. For rho=w/(1+w), the implicit
|
|
8
|
+
* conic is (1-rho)^2*l1^2-4*rho^2*l0*l2=0. At rho=1 this is the union of the
|
|
9
|
+
* triangle's two tangent edges, used only as a boundary search limit.
|
|
10
|
+
*
|
|
11
|
+
* A finite normal displacement is returned only for a unique intersection in
|
|
12
|
+
* the positive tangent triangle. Two distinct valid roots remain unsupported;
|
|
13
|
+
* a double algebraic root is one geometric intersection. No shape is emitted.
|
|
14
|
+
*
|
|
15
|
+
* @evidence contracts/development/common.md#meaningful-documentation States barycentric units, compactified conic equation, degenerate search limit, unique-root contract and absent geometry output.
|
|
16
|
+
* @evidence contracts/development/implementation.md#principled-implementation The rational quadratic's barycentric implicit equation is divided by (1+w)^2 before taking its w-to-infinity limit. Stable quadratic roots and determinant-roundoff bounds evaluate the original normal intersection without moving source points.
|
|
17
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure This helper owns only normal/conic arithmetic so the public fitter owns differential admission, search and coverage.
|
|
18
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts No source fallback, artificial displacement, tangent replacement or merged distinct normal intersections is used. Roundoff tolerances scale with their actual arithmetic terms.
|
|
19
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms One quadratic, at most two candidate roots and three barycentric tests have constant time and space.
|
|
20
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work Compactified factors and normalized coefficients are computed once and reused for root and triangle admission.
|
|
21
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The synchronous scalar operation retains no coordinates, callback, state or resources after return.
|
|
22
|
+
*/
|
|
23
|
+
function GhoshConicApproximationDisplacement(coordinate, rho) {
|
|
24
|
+
const l = coordinate.value;
|
|
25
|
+
const n = coordinate.normal;
|
|
26
|
+
const conic = (1 - rho) ** 2;
|
|
27
|
+
const triangle = 4 * rho ** 2;
|
|
28
|
+
const normalScale = Math.max(Math.abs(n[0]), Math.abs(n[1]), Math.abs(n[2]));
|
|
29
|
+
if (normalScale === 0 || !Number.isFinite(normalScale))
|
|
30
|
+
return undefined;
|
|
31
|
+
// Scale d=L*t so all quadratic coefficients are dimensionless. This keeps
|
|
32
|
+
// coefficient admission unchanged when the caller changes physical units.
|
|
33
|
+
const length = 1 / normalScale;
|
|
34
|
+
const m0 = n[0] * length;
|
|
35
|
+
const m1 = n[1] * length;
|
|
36
|
+
const m2 = n[2] * length;
|
|
37
|
+
const a1 = conic * m1 ** 2;
|
|
38
|
+
const a2 = triangle * m0 * m2;
|
|
39
|
+
const b1 = 2 * conic * l[1] * m1;
|
|
40
|
+
const b2 = triangle * (l[0] * m2 + l[2] * m0);
|
|
41
|
+
const c1 = conic * l[1] ** 2;
|
|
42
|
+
const c2 = triangle * l[0] * l[2];
|
|
43
|
+
const a = a1 - a2;
|
|
44
|
+
const b = b1 - b2;
|
|
45
|
+
const c = c1 - c2;
|
|
46
|
+
const roundoff = 128 * Number.EPSILON;
|
|
47
|
+
let roots;
|
|
48
|
+
if (Math.abs(a) <= roundoff * (Math.abs(a1) + Math.abs(a2))) {
|
|
49
|
+
if (Math.abs(b) <= roundoff * (Math.abs(b1) + Math.abs(b2)))
|
|
50
|
+
return Math.abs(c) <= roundoff * (Math.abs(c1) + Math.abs(c2))
|
|
51
|
+
? 0
|
|
52
|
+
: undefined;
|
|
53
|
+
roots = [-c / b];
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
const discriminant = b * b - 4 * a * c;
|
|
57
|
+
const uncertainty = roundoff * (b * b + 4 * Math.abs(a * c));
|
|
58
|
+
if (discriminant < -uncertainty)
|
|
59
|
+
return undefined;
|
|
60
|
+
if (discriminant <= 0)
|
|
61
|
+
roots = [-b / (2 * a)];
|
|
62
|
+
else {
|
|
63
|
+
const stable = -0.5 * (b + (b < 0 ? -1 : 1) * Math.sqrt(discriminant));
|
|
64
|
+
roots = stable === 0 ? [-b / (2 * a)] : [stable / a, c / stable];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const valid = roots.filter((t) => Number.isFinite(t) &&
|
|
68
|
+
l.every((value, index) => {
|
|
69
|
+
const displacement = t * (index === 0 ? m0 : index === 1 ? m1 : m2);
|
|
70
|
+
return (value + displacement >=
|
|
71
|
+
-roundoff * (1 + Math.abs(value) + Math.abs(displacement)));
|
|
72
|
+
}));
|
|
73
|
+
if (valid.length === 2 && valid[0] === valid[1])
|
|
74
|
+
valid.pop();
|
|
75
|
+
return valid.length === 1 ? valid[0] * length : undefined;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=GhoshConicApproximationDisplacement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GhoshConicApproximationDisplacement.js","sourceRoot":"","sources":["../../src/internal/GhoshConicApproximationDisplacement.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,6CACE,UAAmE,EACnE,GAAW;IAEX,MAAM,CAAC,GAAsB,UAAU,CAAC,KAAK,CAAC;IAC9C,MAAM,CAAC,GAAsB,UAAU,CAAC,MAAM,CAAC;IAC/C,MAAM,KAAK,GAAW,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,QAAQ,GAAW,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;IACtC,MAAM,WAAW,GAAW,IAAI,CAAC,GAAG,CAClC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,EACf,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,EACf,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,CAChB,CAAC;IACF,IAAI,WAAW,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC;QAAE,OAAO,SAAS,CAAC;IAEzE,0EAA0E;IAC1E,0EAA0E;IAC1E,MAAM,MAAM,GAAW,CAAC,GAAG,WAAW,CAAC;IACvC,MAAM,EAAE,GAAW,CAAC,CAAC,CAAC,CAAE,GAAG,MAAM,CAAC;IAClC,MAAM,EAAE,GAAW,CAAC,CAAC,CAAC,CAAE,GAAG,MAAM,CAAC;IAClC,MAAM,EAAE,GAAW,CAAC,CAAC,CAAC,CAAE,GAAG,MAAM,CAAC;IAClC,MAAM,EAAE,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