@tscircuit/curvy-trace-solver 0.0.10 → 0.0.11
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/dist/index.d.ts +66 -1
- package/dist/index.js +1387 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -59,4 +59,69 @@ declare class CurvyTraceSolver extends BaseSolver {
|
|
|
59
59
|
visualize(): GraphicsObject;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
declare class AngledTraceSolver extends BaseSolver {
|
|
63
|
+
problem: CurvyTraceProblem;
|
|
64
|
+
outputTraces: OutputTrace[];
|
|
65
|
+
private traces;
|
|
66
|
+
private optimizationStep;
|
|
67
|
+
private readonly maxOptimizationSteps;
|
|
68
|
+
private sampledPoints;
|
|
69
|
+
private traceBounds;
|
|
70
|
+
private obstacleSegments;
|
|
71
|
+
private obstacleNetworkIds;
|
|
72
|
+
private numObstacleSegments;
|
|
73
|
+
private collisionPairs;
|
|
74
|
+
private lastCost;
|
|
75
|
+
private stagnantSteps;
|
|
76
|
+
private effectiveTraceToTraceSpacing;
|
|
77
|
+
constructor(problem: CurvyTraceProblem);
|
|
78
|
+
getConstructorParams(): CurvyTraceProblem;
|
|
79
|
+
/**
|
|
80
|
+
* Get the current solution weights as Array<[number, number, number]>
|
|
81
|
+
*/
|
|
82
|
+
getSolutionWeights(): Array<[number, number, number]>;
|
|
83
|
+
/**
|
|
84
|
+
* Set the solution weights
|
|
85
|
+
*/
|
|
86
|
+
setSolutionWeights(weights: Array<[number, number, number]>): void;
|
|
87
|
+
private precomputeObstacles;
|
|
88
|
+
private initializeTraces;
|
|
89
|
+
private updateTracePoints;
|
|
90
|
+
private updateAllSampledTraces;
|
|
91
|
+
private updateSingleTraceSample;
|
|
92
|
+
private updateCollisionPairs;
|
|
93
|
+
private computeTotalCost;
|
|
94
|
+
private computeCostForTraceFast;
|
|
95
|
+
/**
|
|
96
|
+
* Compute penalty for undesirable trace shapes:
|
|
97
|
+
* - Sharp turns (90 degrees or more)
|
|
98
|
+
* - 45 degree segments shorter than 5% of trace length
|
|
99
|
+
*
|
|
100
|
+
* For 45-degree routing, valid turn angles are:
|
|
101
|
+
* - 0° (straight): dot product = 1
|
|
102
|
+
* - 45° (to/from diagonal): dot product ≈ 0.707
|
|
103
|
+
*
|
|
104
|
+
* Invalid turns:
|
|
105
|
+
* - 90° (perpendicular): dot product = 0
|
|
106
|
+
* - 135° or sharper: dot product < 0
|
|
107
|
+
*/
|
|
108
|
+
private computeShapePenalty;
|
|
109
|
+
private getTraceLength;
|
|
110
|
+
private tracesIntersect;
|
|
111
|
+
private findIntersectingPairs;
|
|
112
|
+
private resolveIntersections;
|
|
113
|
+
private optimizeStep;
|
|
114
|
+
/**
|
|
115
|
+
* Final optimization step using sample-based cost that matches scoreOutputCost
|
|
116
|
+
*/
|
|
117
|
+
private optimizeStepForScore;
|
|
118
|
+
/**
|
|
119
|
+
* Cost function aligned with scoreOutputCost using preferredTraceToTraceSpacing
|
|
120
|
+
*/
|
|
121
|
+
private computeScoreAlignedCost;
|
|
122
|
+
private buildOutputTraces;
|
|
123
|
+
_step(): void;
|
|
124
|
+
visualize(): GraphicsObject;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export { AngledTraceSolver, type CurvyTraceProblem, CurvyTraceSolver, type Obstacle, type OutputTrace, type WaypointPair };
|