@rxflow/manhattan 0.0.2 → 0.0.3
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/cjs/geometry/Line.d.ts +21 -0
- package/cjs/geometry/Line.d.ts.map +1 -0
- package/cjs/geometry/Line.js +88 -0
- package/cjs/geometry/Point.d.ts +49 -0
- package/cjs/geometry/Point.d.ts.map +1 -0
- package/cjs/geometry/Point.js +94 -0
- package/cjs/geometry/Rectangle.d.ts +41 -0
- package/cjs/geometry/Rectangle.d.ts.map +1 -0
- package/cjs/geometry/Rectangle.js +65 -0
- package/cjs/geometry/collision.d.ts +15 -0
- package/cjs/geometry/collision.d.ts.map +1 -0
- package/cjs/geometry/collision.js +81 -0
- package/cjs/geometry/index.d.ts +5 -0
- package/cjs/geometry/index.d.ts.map +1 -0
- package/cjs/geometry/index.js +45 -0
- package/cjs/getManHattanPath.d.ts +53 -0
- package/cjs/getManHattanPath.d.ts.map +1 -0
- package/cjs/getManHattanPath.js +449 -0
- package/cjs/index.d.ts +16 -0
- package/cjs/index.d.ts.map +1 -0
- package/cjs/index.js +117 -0
- package/cjs/obstacle/ObstacleMap.d.ts +66 -0
- package/cjs/obstacle/ObstacleMap.d.ts.map +1 -0
- package/cjs/obstacle/ObstacleMap.js +328 -0
- package/cjs/obstacle/QuadTree.d.ts +119 -0
- package/cjs/obstacle/QuadTree.d.ts.map +1 -0
- package/cjs/obstacle/QuadTree.js +334 -0
- package/cjs/obstacle/index.d.ts +2 -0
- package/cjs/obstacle/index.d.ts.map +1 -0
- package/cjs/obstacle/index.js +12 -0
- package/cjs/options/defaults.d.ts +16 -0
- package/cjs/options/defaults.d.ts.map +1 -0
- package/cjs/options/defaults.js +39 -0
- package/cjs/options/index.d.ts +4 -0
- package/cjs/options/index.d.ts.map +1 -0
- package/cjs/options/index.js +38 -0
- package/cjs/options/resolver.d.ts +10 -0
- package/cjs/options/resolver.d.ts.map +1 -0
- package/cjs/options/resolver.js +248 -0
- package/cjs/options/types.d.ts +210 -0
- package/cjs/options/types.d.ts.map +1 -0
- package/cjs/options/types.js +5 -0
- package/cjs/pathfinder/PathCache.d.ts +92 -0
- package/cjs/pathfinder/PathCache.d.ts.map +1 -0
- package/cjs/pathfinder/PathCache.js +249 -0
- package/cjs/pathfinder/SortedSet.d.ts +35 -0
- package/cjs/pathfinder/SortedSet.d.ts.map +1 -0
- package/cjs/pathfinder/SortedSet.js +95 -0
- package/cjs/pathfinder/findRoute.d.ts +8 -0
- package/cjs/pathfinder/findRoute.d.ts.map +1 -0
- package/cjs/pathfinder/findRoute.js +395 -0
- package/cjs/pathfinder/index.d.ts +4 -0
- package/cjs/pathfinder/index.d.ts.map +1 -0
- package/cjs/pathfinder/index.js +44 -0
- package/cjs/svg/index.d.ts +3 -0
- package/cjs/svg/index.d.ts.map +1 -0
- package/cjs/svg/index.js +31 -0
- package/cjs/svg/pathConverter.d.ts +23 -0
- package/cjs/svg/pathConverter.d.ts.map +1 -0
- package/cjs/svg/pathConverter.js +285 -0
- package/cjs/svg/pathParser.d.ts +11 -0
- package/cjs/svg/pathParser.d.ts.map +1 -0
- package/cjs/svg/pathParser.js +76 -0
- package/cjs/utils/AdaptiveStepCalculator.d.ts +90 -0
- package/cjs/utils/AdaptiveStepCalculator.d.ts.map +1 -0
- package/cjs/utils/AdaptiveStepCalculator.js +224 -0
- package/cjs/utils/ErrorRecovery.d.ts +182 -0
- package/cjs/utils/ErrorRecovery.d.ts.map +1 -0
- package/cjs/utils/ErrorRecovery.js +413 -0
- package/cjs/utils/GlobalGrid.d.ts +99 -0
- package/cjs/utils/GlobalGrid.d.ts.map +1 -0
- package/cjs/utils/GlobalGrid.js +224 -0
- package/cjs/utils/PerformanceMonitor.d.ts +139 -0
- package/cjs/utils/PerformanceMonitor.d.ts.map +1 -0
- package/cjs/utils/PerformanceMonitor.js +305 -0
- package/cjs/utils/direction.d.ts +24 -0
- package/cjs/utils/direction.d.ts.map +1 -0
- package/cjs/utils/direction.js +54 -0
- package/cjs/utils/getAnchorPoints.d.ts +15 -0
- package/cjs/utils/getAnchorPoints.d.ts.map +1 -0
- package/cjs/utils/getAnchorPoints.js +71 -0
- package/cjs/utils/grid.d.ts +42 -0
- package/cjs/utils/grid.d.ts.map +1 -0
- package/cjs/utils/grid.js +73 -0
- package/cjs/utils/heuristics.d.ts +61 -0
- package/cjs/utils/heuristics.d.ts.map +1 -0
- package/cjs/utils/heuristics.js +141 -0
- package/cjs/utils/index.d.ts +14 -0
- package/cjs/utils/index.d.ts.map +1 -0
- package/cjs/utils/index.js +148 -0
- package/cjs/utils/node.d.ts +27 -0
- package/cjs/utils/node.d.ts.map +1 -0
- package/cjs/utils/node.js +36 -0
- package/cjs/utils/pathProcessing.d.ts +45 -0
- package/cjs/utils/pathProcessing.d.ts.map +1 -0
- package/cjs/utils/pathProcessing.js +270 -0
- package/cjs/utils/pathValidation.d.ts +11 -0
- package/cjs/utils/pathValidation.d.ts.map +1 -0
- package/cjs/utils/pathValidation.js +129 -0
- package/cjs/utils/rect.d.ts +9 -0
- package/cjs/utils/rect.d.ts.map +1 -0
- package/cjs/utils/rect.js +110 -0
- package/cjs/utils/route.d.ts +19 -0
- package/cjs/utils/route.d.ts.map +1 -0
- package/cjs/utils/route.js +92 -0
- package/esm/geometry/Line.d.ts +21 -0
- package/esm/geometry/Line.d.ts.map +1 -0
- package/esm/geometry/Point.d.ts +49 -0
- package/esm/geometry/Point.d.ts.map +1 -0
- package/esm/geometry/Rectangle.d.ts +41 -0
- package/esm/geometry/Rectangle.d.ts.map +1 -0
- package/esm/geometry/collision.d.ts +15 -0
- package/esm/geometry/collision.d.ts.map +1 -0
- package/esm/geometry/index.d.ts +5 -0
- package/esm/geometry/index.d.ts.map +1 -0
- package/esm/getManHattanPath.d.ts +53 -0
- package/esm/getManHattanPath.d.ts.map +1 -0
- package/esm/index.d.ts +16 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/obstacle/ObstacleMap.d.ts +66 -0
- package/esm/obstacle/ObstacleMap.d.ts.map +1 -0
- package/esm/obstacle/QuadTree.d.ts +119 -0
- package/esm/obstacle/QuadTree.d.ts.map +1 -0
- package/esm/obstacle/index.d.ts +2 -0
- package/esm/obstacle/index.d.ts.map +1 -0
- package/esm/options/defaults.d.ts +16 -0
- package/esm/options/defaults.d.ts.map +1 -0
- package/esm/options/index.d.ts +4 -0
- package/esm/options/index.d.ts.map +1 -0
- package/esm/options/resolver.d.ts +10 -0
- package/esm/options/resolver.d.ts.map +1 -0
- package/esm/options/types.d.ts +210 -0
- package/esm/options/types.d.ts.map +1 -0
- package/esm/pathfinder/PathCache.d.ts +92 -0
- package/esm/pathfinder/PathCache.d.ts.map +1 -0
- package/esm/pathfinder/SortedSet.d.ts +35 -0
- package/esm/pathfinder/SortedSet.d.ts.map +1 -0
- package/esm/pathfinder/findRoute.d.ts +8 -0
- package/esm/pathfinder/findRoute.d.ts.map +1 -0
- package/esm/pathfinder/index.d.ts +4 -0
- package/esm/pathfinder/index.d.ts.map +1 -0
- package/esm/svg/index.d.ts +3 -0
- package/esm/svg/index.d.ts.map +1 -0
- package/esm/svg/pathConverter.d.ts +23 -0
- package/esm/svg/pathConverter.d.ts.map +1 -0
- package/esm/svg/pathParser.d.ts +11 -0
- package/esm/svg/pathParser.d.ts.map +1 -0
- package/esm/utils/AdaptiveStepCalculator.d.ts +90 -0
- package/esm/utils/AdaptiveStepCalculator.d.ts.map +1 -0
- package/esm/utils/ErrorRecovery.d.ts +182 -0
- package/esm/utils/ErrorRecovery.d.ts.map +1 -0
- package/esm/utils/GlobalGrid.d.ts +99 -0
- package/esm/utils/GlobalGrid.d.ts.map +1 -0
- package/esm/utils/PerformanceMonitor.d.ts +139 -0
- package/esm/utils/PerformanceMonitor.d.ts.map +1 -0
- package/esm/utils/direction.d.ts +24 -0
- package/esm/utils/direction.d.ts.map +1 -0
- package/esm/utils/getAnchorPoints.d.ts +15 -0
- package/esm/utils/getAnchorPoints.d.ts.map +1 -0
- package/esm/utils/grid.d.ts +42 -0
- package/esm/utils/grid.d.ts.map +1 -0
- package/esm/utils/heuristics.d.ts +61 -0
- package/esm/utils/heuristics.d.ts.map +1 -0
- package/esm/utils/index.d.ts +14 -0
- package/esm/utils/index.d.ts.map +1 -0
- package/esm/utils/node.d.ts +27 -0
- package/esm/utils/node.d.ts.map +1 -0
- package/esm/utils/pathProcessing.d.ts +45 -0
- package/esm/utils/pathProcessing.d.ts.map +1 -0
- package/esm/utils/pathValidation.d.ts +11 -0
- package/esm/utils/pathValidation.d.ts.map +1 -0
- package/esm/utils/rect.d.ts +9 -0
- package/esm/utils/rect.d.ts.map +1 -0
- package/esm/utils/route.d.ts +19 -0
- package/esm/utils/route.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ErrorRecovery - 错误恢复和降级策略
|
|
3
|
+
*
|
|
4
|
+
* 提供路径计算失败时的恢复机制,包括:
|
|
5
|
+
* - 超时检测和处理
|
|
6
|
+
* - 降级路径生成
|
|
7
|
+
* - 错误分类和报告
|
|
8
|
+
*
|
|
9
|
+
* Implements: Requirements 4.2, 3.6
|
|
10
|
+
*/
|
|
11
|
+
import { Point, Rectangle } from '../geometry';
|
|
12
|
+
/**
|
|
13
|
+
* 错误类型枚举
|
|
14
|
+
*/
|
|
15
|
+
export declare enum PathfindingErrorType {
|
|
16
|
+
/** 超时错误 - 计算时间超过限制 */
|
|
17
|
+
TIMEOUT = "TIMEOUT",
|
|
18
|
+
/** 无路径错误 - 无法找到有效路径 */
|
|
19
|
+
NO_PATH = "NO_PATH",
|
|
20
|
+
/** 无效输入错误 - 输入参数无效 */
|
|
21
|
+
INVALID_INPUT = "INVALID_INPUT",
|
|
22
|
+
/** 障碍物阻塞错误 - 起点或终点被障碍物阻塞 */
|
|
23
|
+
BLOCKED = "BLOCKED",
|
|
24
|
+
/** 内部错误 - 算法内部错误 */
|
|
25
|
+
INTERNAL = "INTERNAL"
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 路径计算错误
|
|
29
|
+
*/
|
|
30
|
+
export declare class PathfindingError extends Error {
|
|
31
|
+
readonly type: PathfindingErrorType;
|
|
32
|
+
readonly details?: Record<string, unknown> | undefined;
|
|
33
|
+
constructor(type: PathfindingErrorType, message: string, details?: Record<string, unknown> | undefined);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 恢复策略类型
|
|
37
|
+
*/
|
|
38
|
+
export declare enum RecoveryStrategy {
|
|
39
|
+
/** 直线连接 */
|
|
40
|
+
DIRECT_LINE = "DIRECT_LINE",
|
|
41
|
+
/** L形路径 */
|
|
42
|
+
L_SHAPE = "L_SHAPE",
|
|
43
|
+
/** Z形路径 */
|
|
44
|
+
Z_SHAPE = "Z_SHAPE",
|
|
45
|
+
/** 简化曼哈顿路径 */
|
|
46
|
+
SIMPLE_MANHATTAN = "SIMPLE_MANHATTAN",
|
|
47
|
+
/** 无恢复 */
|
|
48
|
+
NONE = "NONE"
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 恢复结果
|
|
52
|
+
*/
|
|
53
|
+
export interface RecoveryResult {
|
|
54
|
+
/** 是否成功恢复 */
|
|
55
|
+
success: boolean;
|
|
56
|
+
/** 恢复后的路径 */
|
|
57
|
+
path: Point[];
|
|
58
|
+
/** 使用的恢复策略 */
|
|
59
|
+
strategy: RecoveryStrategy;
|
|
60
|
+
/** 原始错误 */
|
|
61
|
+
originalError?: PathfindingError;
|
|
62
|
+
/** 恢复耗时(毫秒) */
|
|
63
|
+
recoveryTime: number;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* 错误恢复配置
|
|
67
|
+
*/
|
|
68
|
+
export interface ErrorRecoveryConfig {
|
|
69
|
+
/** 是否启用自动恢复 */
|
|
70
|
+
enabled: boolean;
|
|
71
|
+
/** 最大恢复尝试次数 */
|
|
72
|
+
maxAttempts: number;
|
|
73
|
+
/** 恢复策略优先级 */
|
|
74
|
+
strategyPriority: RecoveryStrategy[];
|
|
75
|
+
/** 是否记录恢复日志 */
|
|
76
|
+
logRecovery: boolean;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* 默认恢复配置
|
|
80
|
+
*/
|
|
81
|
+
export declare const DEFAULT_RECOVERY_CONFIG: ErrorRecoveryConfig;
|
|
82
|
+
/**
|
|
83
|
+
* 错误恢复类
|
|
84
|
+
*/
|
|
85
|
+
export declare class ErrorRecovery {
|
|
86
|
+
private config;
|
|
87
|
+
private recoveryAttempts;
|
|
88
|
+
constructor(config?: Partial<ErrorRecoveryConfig>);
|
|
89
|
+
/**
|
|
90
|
+
* 尝试恢复路径计算
|
|
91
|
+
*/
|
|
92
|
+
recover(from: Point, to: Point, error: PathfindingError, obstacles?: Rectangle[]): RecoveryResult;
|
|
93
|
+
/**
|
|
94
|
+
* 应用恢复策略
|
|
95
|
+
*/
|
|
96
|
+
private applyStrategy;
|
|
97
|
+
/**
|
|
98
|
+
* 直线连接策略
|
|
99
|
+
*/
|
|
100
|
+
private directLine;
|
|
101
|
+
/**
|
|
102
|
+
* L形路径策略
|
|
103
|
+
*/
|
|
104
|
+
private lShape;
|
|
105
|
+
/**
|
|
106
|
+
* Z形路径策略
|
|
107
|
+
*/
|
|
108
|
+
private zShape;
|
|
109
|
+
/**
|
|
110
|
+
* 简化曼哈顿路径策略
|
|
111
|
+
*/
|
|
112
|
+
private simpleManhattan;
|
|
113
|
+
/**
|
|
114
|
+
* 检查路径是否与障碍物相交
|
|
115
|
+
*/
|
|
116
|
+
private pathIntersectsObstacles;
|
|
117
|
+
/**
|
|
118
|
+
* 检查线段是否与矩形相交
|
|
119
|
+
*/
|
|
120
|
+
private lineIntersectsRect;
|
|
121
|
+
/**
|
|
122
|
+
* 检查点是否在矩形内部
|
|
123
|
+
*/
|
|
124
|
+
private pointInRect;
|
|
125
|
+
/**
|
|
126
|
+
* 检查两条线段是否相交
|
|
127
|
+
*/
|
|
128
|
+
private lineIntersectsLine;
|
|
129
|
+
/**
|
|
130
|
+
* 计算叉积方向
|
|
131
|
+
*/
|
|
132
|
+
private direction;
|
|
133
|
+
/**
|
|
134
|
+
* 检查点是否在线段上
|
|
135
|
+
*/
|
|
136
|
+
private onSegment;
|
|
137
|
+
/**
|
|
138
|
+
* 创建超时错误
|
|
139
|
+
*/
|
|
140
|
+
static createTimeoutError(iterations: number, maxIterations: number): PathfindingError;
|
|
141
|
+
/**
|
|
142
|
+
* 创建无路径错误
|
|
143
|
+
*/
|
|
144
|
+
static createNoPathError(from: Point, to: Point): PathfindingError;
|
|
145
|
+
/**
|
|
146
|
+
* 创建无效输入错误
|
|
147
|
+
*/
|
|
148
|
+
static createInvalidInputError(message: string): PathfindingError;
|
|
149
|
+
/**
|
|
150
|
+
* 创建阻塞错误
|
|
151
|
+
*/
|
|
152
|
+
static createBlockedError(point: Point, type: 'source' | 'target'): PathfindingError;
|
|
153
|
+
/**
|
|
154
|
+
* 创建内部错误
|
|
155
|
+
*/
|
|
156
|
+
static createInternalError(message: string, cause?: Error): PathfindingError;
|
|
157
|
+
/**
|
|
158
|
+
* 生成回退路径(静态方法)
|
|
159
|
+
*/
|
|
160
|
+
static generateFallbackPath(source: Point, target: Point): Point[];
|
|
161
|
+
/**
|
|
162
|
+
* 验证并修复配置选项
|
|
163
|
+
*/
|
|
164
|
+
static validateAndFixOptions<T extends Record<string, unknown>>(options: T, defaults: T): T;
|
|
165
|
+
/**
|
|
166
|
+
* 获取恢复尝试次数
|
|
167
|
+
*/
|
|
168
|
+
getRecoveryAttempts(): number;
|
|
169
|
+
/**
|
|
170
|
+
* 重置恢复状态
|
|
171
|
+
*/
|
|
172
|
+
reset(): void;
|
|
173
|
+
/**
|
|
174
|
+
* 更新配置
|
|
175
|
+
*/
|
|
176
|
+
updateConfig(config: Partial<ErrorRecoveryConfig>): void;
|
|
177
|
+
/**
|
|
178
|
+
* 获取当前配置
|
|
179
|
+
*/
|
|
180
|
+
getConfig(): ErrorRecoveryConfig;
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=ErrorRecovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorRecovery.d.ts","sourceRoot":"","sources":["../../src/utils/ErrorRecovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE9C;;GAEG;AACH,oBAAY,oBAAoB;IAC9B,sBAAsB;IACtB,OAAO,YAAY;IACnB,uBAAuB;IACvB,OAAO,YAAY;IACnB,sBAAsB;IACtB,aAAa,kBAAkB;IAC/B,4BAA4B;IAC5B,OAAO,YAAY;IACnB,oBAAoB;IACpB,QAAQ,aAAa;CACtB;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;aAEvB,IAAI,EAAE,oBAAoB;aAE1B,OAAO,CAAC;gBAFR,IAAI,EAAE,oBAAoB,EAC1C,OAAO,EAAE,MAAM,EACC,OAAO,CAAC,qCAAyB;CAKpD;AAED;;GAEG;AACH,oBAAY,gBAAgB;IAC1B,WAAW;IACX,WAAW,gBAAgB;IAC3B,WAAW;IACX,OAAO,YAAY;IACnB,WAAW;IACX,OAAO,YAAY;IACnB,cAAc;IACd,gBAAgB,qBAAqB;IACrC,UAAU;IACV,IAAI,SAAS;CACd;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,aAAa;IACb,OAAO,EAAE,OAAO,CAAA;IAChB,aAAa;IACb,IAAI,EAAE,KAAK,EAAE,CAAA;IACb,cAAc;IACd,QAAQ,EAAE,gBAAgB,CAAA;IAC1B,WAAW;IACX,aAAa,CAAC,EAAE,gBAAgB,CAAA;IAChC,eAAe;IACf,YAAY,EAAE,MAAM,CAAA;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,eAAe;IACf,OAAO,EAAE,OAAO,CAAA;IAChB,eAAe;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc;IACd,gBAAg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BAAgB;IAQnB;;OAEG;IACH,MAAM,CAAC,mBAAmB,CACxB,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,KAAK,GACZ,gBAAgB;IAMnB;;OAEG;IACH,MAAM,CAAC,oBAAoB,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,GAAG,KAAK,EAAE;IAKlE;;OAEG;IACH,MAAM,CAAC,qBAAqB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5D,OAAO,EAAE,CAAC,EACV,QAAQ,EAAE,CAAC,GACV,CAAC;IAoBJ;;OAEG;IACH,mBAAmB,IAAI,MAAM;IAI7B;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACH,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,mBAAmB,CAAC,GAAG,IAAI;IAIxD;;OAEG;IACH,SAAS,IAAI,mBAAmB;CAGjC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GlobalGrid class for consistent path alignment
|
|
3
|
+
* Feature: manhattan-optimization
|
|
4
|
+
*
|
|
5
|
+
* This class ensures all paths align to a unified global grid,
|
|
6
|
+
* solving the path overlap problem where paths should share segments.
|
|
7
|
+
*/
|
|
8
|
+
import { Point } from '../geometry';
|
|
9
|
+
/**
|
|
10
|
+
* Global grid configuration
|
|
11
|
+
*/
|
|
12
|
+
export interface GlobalGridConfig {
|
|
13
|
+
/** Grid step size in X direction */
|
|
14
|
+
stepX: number;
|
|
15
|
+
/** Grid step size in Y direction */
|
|
16
|
+
stepY: number;
|
|
17
|
+
/** Grid origin point (default: (0, 0)) */
|
|
18
|
+
origin?: Point;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* GlobalGrid class for managing grid alignment
|
|
22
|
+
*
|
|
23
|
+
* Key features:
|
|
24
|
+
* - Uses a fixed global origin (0, 0) for consistent alignment across all paths
|
|
25
|
+
* - Supports configurable step sizes
|
|
26
|
+
* - Provides methods for snapping points to grid
|
|
27
|
+
* - Ensures path segments can properly overlap when they should
|
|
28
|
+
*/
|
|
29
|
+
export declare class GlobalGrid {
|
|
30
|
+
/** Grid origin point */
|
|
31
|
+
readonly origin: Point;
|
|
32
|
+
/** Grid step size in X direction */
|
|
33
|
+
readonly stepX: number;
|
|
34
|
+
/** Grid step size in Y direction */
|
|
35
|
+
readonly stepY: number;
|
|
36
|
+
constructor(config: GlobalGridConfig);
|
|
37
|
+
/**
|
|
38
|
+
* Create a GlobalGrid with uniform step size
|
|
39
|
+
*/
|
|
40
|
+
static uniform(step: number, origin?: Point): GlobalGrid;
|
|
41
|
+
/**
|
|
42
|
+
* Snap a single value to the grid
|
|
43
|
+
*/
|
|
44
|
+
snapValue(value: number, step: number, originOffset?: number): number;
|
|
45
|
+
/**
|
|
46
|
+
* Snap a point to the global grid
|
|
47
|
+
*/
|
|
48
|
+
snapToGrid(point: Point): Point;
|
|
49
|
+
/**
|
|
50
|
+
* Snap a point to grid and apply precision rounding
|
|
51
|
+
*/
|
|
52
|
+
snapToGridWithPrecision(point: Point, precision: number): Point;
|
|
53
|
+
/**
|
|
54
|
+
* Check if a point is on the grid (within tolerance)
|
|
55
|
+
*/
|
|
56
|
+
isOnGrid(point: Point, tolerance?: number): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Get the nearest grid point in a specific direction
|
|
59
|
+
*/
|
|
60
|
+
getNearestGridPoint(point: Point, direction: 'up' | 'down' | 'left' | 'right' | 'nearest'): Point;
|
|
61
|
+
/**
|
|
62
|
+
* Get all grid points within a rectangle
|
|
63
|
+
*/
|
|
64
|
+
getGridPointsInRect(minX: number, minY: number, maxX: number, maxY: number): Point[];
|
|
65
|
+
/**
|
|
66
|
+
* Calculate the grid distance between two points
|
|
67
|
+
* (number of grid steps, not actual distance)
|
|
68
|
+
*/
|
|
69
|
+
gridDistance(p1: Point, p2: Point): {
|
|
70
|
+
x: number;
|
|
71
|
+
y: number;
|
|
72
|
+
total: number;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Snap an array of points to the grid
|
|
76
|
+
*/
|
|
77
|
+
snapPathToGrid(points: Point[]): Point[];
|
|
78
|
+
/**
|
|
79
|
+
* Snap path to grid and remove duplicate consecutive points
|
|
80
|
+
*/
|
|
81
|
+
snapAndSimplifyPath(points: Point[], tolerance?: number): Point[];
|
|
82
|
+
/**
|
|
83
|
+
* Get grid offset for a direction
|
|
84
|
+
*/
|
|
85
|
+
getDirectionOffset(direction: 'up' | 'down' | 'left' | 'right'): Point;
|
|
86
|
+
/**
|
|
87
|
+
* Clone this grid with optional overrides
|
|
88
|
+
*/
|
|
89
|
+
clone(overrides?: Partial<GlobalGridConfig>): GlobalGrid;
|
|
90
|
+
/**
|
|
91
|
+
* Create a string representation for debugging
|
|
92
|
+
*/
|
|
93
|
+
toString(): string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Default global grid instance with step size 10
|
|
97
|
+
*/
|
|
98
|
+
export declare const defaultGlobalGrid: GlobalGrid;
|
|
99
|
+
//# sourceMappingURL=GlobalGrid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GlobalGrid.d.ts","sourceRoot":"","sources":["../../src/utils/GlobalGrid.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAEnC;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAA;IACb,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAA;IACb,0CAA0C;IAC1C,MAAM,CAAC,EAAE,KAAK,CAAA;CACf;AAED;;;;;;;;GAQG;AACH,qBAAa,UAAU;IACrB,wBAAwB;IACxB,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAA;IAEtB,oCAAoC;IACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IAEtB,oCAAoC;IACpC,Q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G,KAAK;IAatE;;OAEG;IACH,KAAK,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,UAAU;IAQxD;;OAEG;IACH,QAAQ,IAAI,MAAM;CAGnB;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,YAAyB,CAAA"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PerformanceMonitor - 性能监控器
|
|
3
|
+
*
|
|
4
|
+
* 提供路径计算的性能监控和调试信息
|
|
5
|
+
* - 计时功能
|
|
6
|
+
* - 指标收集(迭代次数、查询次数等)
|
|
7
|
+
* - 指标导出和日志
|
|
8
|
+
*
|
|
9
|
+
* Feature: manhattan-optimization
|
|
10
|
+
* Requirements: 3.5, 5.5
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* 性能指标接口
|
|
14
|
+
*/
|
|
15
|
+
export interface PerformanceMetrics {
|
|
16
|
+
/** 路径查找耗时(毫秒) */
|
|
17
|
+
pathfindingTime: number;
|
|
18
|
+
/** A* 迭代次数 */
|
|
19
|
+
iterations: number;
|
|
20
|
+
/** 障碍物查询次数 */
|
|
21
|
+
obstacleQueries: number;
|
|
22
|
+
/** 缓存命中率 */
|
|
23
|
+
cacheHitRate: number;
|
|
24
|
+
/** 路径点数量 */
|
|
25
|
+
pathPointCount: number;
|
|
26
|
+
/** 开始时间戳 */
|
|
27
|
+
startTime?: number;
|
|
28
|
+
/** 结束时间戳 */
|
|
29
|
+
endTime?: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 日志级别
|
|
33
|
+
*/
|
|
34
|
+
export type LogLevel = 'error' | 'warn' | 'info' | 'debug';
|
|
35
|
+
/**
|
|
36
|
+
* 性能监控配置
|
|
37
|
+
*/
|
|
38
|
+
export interface PerformanceMonitorConfig {
|
|
39
|
+
/** 是否启用日志 */
|
|
40
|
+
enableLogging: boolean;
|
|
41
|
+
/** 是否启用指标收集 */
|
|
42
|
+
enableMetrics: boolean;
|
|
43
|
+
/** 日志级别 */
|
|
44
|
+
logLevel: LogLevel;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* 默认性能监控配置
|
|
48
|
+
*/
|
|
49
|
+
export declare const DEFAULT_PERFORMANCE_MONITOR_CONFIG: PerformanceMonitorConfig;
|
|
50
|
+
/**
|
|
51
|
+
* 性能监控器
|
|
52
|
+
*/
|
|
53
|
+
export declare class PerformanceMonitor {
|
|
54
|
+
private config;
|
|
55
|
+
private metrics;
|
|
56
|
+
private activeTimers;
|
|
57
|
+
private globalCounters;
|
|
58
|
+
constructor(config?: Partial<PerformanceMonitorConfig>);
|
|
59
|
+
/**
|
|
60
|
+
* 开始监控
|
|
61
|
+
*/
|
|
62
|
+
startMonitoring(label: string): void;
|
|
63
|
+
/**
|
|
64
|
+
* 结束监控并记录
|
|
65
|
+
*/
|
|
66
|
+
endMonitoring(label: string): PerformanceMetrics;
|
|
67
|
+
/**
|
|
68
|
+
* 记录迭代次数
|
|
69
|
+
*/
|
|
70
|
+
recordIterations(label: string, count: number): void;
|
|
71
|
+
/**
|
|
72
|
+
* 增加障碍物查询计数
|
|
73
|
+
*/
|
|
74
|
+
incrementObstacleQueries(label: string, count?: number): void;
|
|
75
|
+
/**
|
|
76
|
+
* 记录路径点数量
|
|
77
|
+
*/
|
|
78
|
+
recordPathPointCount(label: string, count: number): void;
|
|
79
|
+
/**
|
|
80
|
+
* 记录缓存命中
|
|
81
|
+
*/
|
|
82
|
+
recordCacheHit(): void;
|
|
83
|
+
/**
|
|
84
|
+
* 记录缓存未命中
|
|
85
|
+
*/
|
|
86
|
+
recordCacheMiss(): void;
|
|
87
|
+
/**
|
|
88
|
+
* 计算缓存命中率
|
|
89
|
+
*/
|
|
90
|
+
private calculateCacheHitRate;
|
|
91
|
+
/**
|
|
92
|
+
* 获取指定标签的指标
|
|
93
|
+
*/
|
|
94
|
+
getMetrics(label: string): PerformanceMetrics | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* 获取所有指标
|
|
97
|
+
*/
|
|
98
|
+
getAllMetrics(): Map<string, PerformanceMetrics>;
|
|
99
|
+
/**
|
|
100
|
+
* 清除指标
|
|
101
|
+
*/
|
|
102
|
+
clearMetrics(): void;
|
|
103
|
+
/**
|
|
104
|
+
* 导出为日志字符串
|
|
105
|
+
*/
|
|
106
|
+
exportToLog(): string;
|
|
107
|
+
/**
|
|
108
|
+
* 获取摘要统计
|
|
109
|
+
*/
|
|
110
|
+
getSummary(): {
|
|
111
|
+
totalTime: number;
|
|
112
|
+
avgTime: number;
|
|
113
|
+
maxTime: number;
|
|
114
|
+
minTime: number;
|
|
115
|
+
totalIterations: number;
|
|
116
|
+
cacheHitRate: number;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* 内部日志方法
|
|
120
|
+
*/
|
|
121
|
+
private log;
|
|
122
|
+
/**
|
|
123
|
+
* 更新配置
|
|
124
|
+
*/
|
|
125
|
+
updateConfig(config: Partial<PerformanceMonitorConfig>): void;
|
|
126
|
+
/**
|
|
127
|
+
* 获取当前配置
|
|
128
|
+
*/
|
|
129
|
+
getConfig(): PerformanceMonitorConfig;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* 获取全局性能监控器
|
|
133
|
+
*/
|
|
134
|
+
export declare function getGlobalPerformanceMonitor(): PerformanceMonitor;
|
|
135
|
+
/**
|
|
136
|
+
* 重置全局性能监控器
|
|
137
|
+
*/
|
|
138
|
+
export declare function resetGlobalPerformanceMonitor(): void;
|
|
139
|
+
//# sourceMappingURL=PerformanceMonitor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PerformanceMonitor.d.ts","sourceRoot":"","sources":["../../src/utils/PerformanceMonitor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,iBAAiB;IACjB,eAAe,EAAE,MAAM,CAAA;IACvB,cAAc;IACd,UAAU,E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OAEG;IACH,OAAO,CAAC,qBAAqB;IAK7B;;OAEG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAIzD;;OAEG;IACH,aAAa,IAAI,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC;IAIhD;;OAEG;IACH,YAAY,IAAI,IAAI;IASpB;;OAEG;IACH,WAAW,IAAI,MAAM;IAoBrB;;OAEG;IACH,UAAU,IAAI;QACZ,SAAS,EAAE,MAAM,CAAA;QACjB,OAAO,EAAE,MAAM,CAAA;QACf,OAAO,EAAE,MAAM,CAAA;QACf,OAAO,EAAE,MAAM,CAAA;QACf,eAAe,EAAE,MAAM,CAAA;QACvB,YAAY,EAAE,MAAM,CAAA;KACrB;IAwBD;;OAEG;IACH,OAAO,CAAC,GAAG;IAyBX;;OAEG;IACH,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,wBAAwB,CAAC,GAAG,IAAI;IAI7D;;OAEG;IACH,SAAS,IAAI,wBAAwB;CAGtC;AAOD;;GAEG;AACH,wBAAgB,2BAA2B,IAAI,kBAAkB,CAKhE;AAED;;GAEG;AACH,wBAAgB,6BAA6B,IAAI,IAAI,CAEpD"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Point } from '../geometry';
|
|
2
|
+
import type { ResolvedOptions } from '../options';
|
|
3
|
+
import type { Grid } from './grid';
|
|
4
|
+
/**
|
|
5
|
+
* Get direction angle from start point to end point
|
|
6
|
+
* Corrects for grid deformation between start and end
|
|
7
|
+
*/
|
|
8
|
+
export declare function getDirectionAngle(start: Point, end: Point, directionCount: number, grid: Grid, options: ResolvedOptions): number;
|
|
9
|
+
/**
|
|
10
|
+
* Get the change in direction between two direction angles
|
|
11
|
+
*/
|
|
12
|
+
export declare function getDirectionChange(angle1: number, angle2: number): number;
|
|
13
|
+
/**
|
|
14
|
+
* Fix direction offsets according to current grid
|
|
15
|
+
*/
|
|
16
|
+
export declare function getGridOffsets(grid: Grid, options: ResolvedOptions): {
|
|
17
|
+
cost: number;
|
|
18
|
+
offsetX: number;
|
|
19
|
+
offsetY: number;
|
|
20
|
+
angle?: number | undefined;
|
|
21
|
+
gridOffsetX?: number | undefined;
|
|
22
|
+
gridOffsetY?: number | undefined;
|
|
23
|
+
}[];
|
|
24
|
+
//# sourceMappingURL=direction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"direction.d.ts","sourceRoot":"","sources":["../../src/utils/direction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEjD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAyBlC;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,KAAK,EACV,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,eAAe,GACvB,MAAM,CAKR;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAGzE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,eAAe;;;;;;;IASlE"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Point } from '../geometry';
|
|
2
|
+
import type { ObstacleMap } from '../obstacle';
|
|
3
|
+
import type { Direction } from '../options';
|
|
4
|
+
/**
|
|
5
|
+
* Get accessible anchor points using binary search optimization
|
|
6
|
+
*
|
|
7
|
+
* @param anchor - The anchor point (on node edge)
|
|
8
|
+
* @param position - The position/direction (right, left, top, bottom)
|
|
9
|
+
* @param extensionDistance - The preferred extension distance
|
|
10
|
+
* @param step - The step size for binary search
|
|
11
|
+
* @param obstacleMap - The obstacle map for accessibility checking
|
|
12
|
+
* @returns Array of accessible points, prioritized by distance
|
|
13
|
+
*/
|
|
14
|
+
export declare function getAnchorPoints(anchor: Point, position: Direction, extensionDistance: number, step: number, obstacleMap: ObstacleMap): Point[];
|
|
15
|
+
//# sourceMappingURL=getAnchorPoints.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getAnchorPoints.d.ts","sourceRoot":"","sources":["../../src/utils/getAnchorPoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAE3C;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,KAAK,EACb,QAAQ,EAAE,SAAS,EACnB,iBAAiB,EAAE,MAAM,EACzB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,WAAW,GACvB,KAAK,EAAE,CAsDT"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Point } from '../geometry';
|
|
2
|
+
import { GlobalGrid } from './GlobalGrid';
|
|
3
|
+
/**
|
|
4
|
+
* Grid interface for dynamic grid system
|
|
5
|
+
*/
|
|
6
|
+
export interface Grid {
|
|
7
|
+
source: Point;
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Get grid size in x and y dimensions, adapted to source and target positions
|
|
13
|
+
* Uses global grid system with origin at (0, 0) for path alignment
|
|
14
|
+
*
|
|
15
|
+
* @param step - The grid step size
|
|
16
|
+
* @param source - Source point (used for reference, not as origin)
|
|
17
|
+
* @param target - Target point (used for reference, not as origin)
|
|
18
|
+
* @returns Grid configuration with global origin
|
|
19
|
+
*/
|
|
20
|
+
export declare function getGrid(step: number, source: Point, target: Point): Grid;
|
|
21
|
+
/**
|
|
22
|
+
* Create a GlobalGrid instance from step size
|
|
23
|
+
* This is the preferred way to create grids for new code
|
|
24
|
+
*/
|
|
25
|
+
export declare function createGlobalGrid(step: number): GlobalGrid;
|
|
26
|
+
/**
|
|
27
|
+
* Snap a value to grid
|
|
28
|
+
*/
|
|
29
|
+
export declare function snapToGrid(value: number, gridSize: number): number;
|
|
30
|
+
/**
|
|
31
|
+
* Snap a point to grid using global origin
|
|
32
|
+
*/
|
|
33
|
+
export declare function snapPointToGrid(point: Point, grid: Grid): Point;
|
|
34
|
+
/**
|
|
35
|
+
* Align point to grid and apply precision
|
|
36
|
+
*/
|
|
37
|
+
export declare function align(point: Point, grid: Grid, precision: number): Point;
|
|
38
|
+
/**
|
|
39
|
+
* Round point coordinates
|
|
40
|
+
*/
|
|
41
|
+
export declare function round(point: Point, precision: number): Point;
|
|
42
|
+
//# sourceMappingURL=grid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../src/utils/grid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,MAAM,EAAE,KAAK,CAAA;IACb,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,GAAG,IAAI,CAMxE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAEzD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAElE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,GAAG,KAAK,CAK/D;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,GAAG,KAAK,CAExE;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,GAAG,KAAK,CAE5D"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Heuristics - 启发式函数模块
|
|
3
|
+
*
|
|
4
|
+
* 提供多种启发式函数用于 A* 算法:
|
|
5
|
+
* - Manhattan: 曼哈顿距离(默认)
|
|
6
|
+
* - Euclidean: 欧几里得距离
|
|
7
|
+
* - Octile: 八方向距离
|
|
8
|
+
*
|
|
9
|
+
* Implements: Requirements 3.1
|
|
10
|
+
*/
|
|
11
|
+
import { Point } from '../geometry';
|
|
12
|
+
/**
|
|
13
|
+
* 启发式函数类型
|
|
14
|
+
*/
|
|
15
|
+
export type HeuristicType = 'manhattan' | 'euclidean' | 'octile';
|
|
16
|
+
/**
|
|
17
|
+
* 启发式函数配置
|
|
18
|
+
*/
|
|
19
|
+
export interface HeuristicConfig {
|
|
20
|
+
/** 启发式函数类型 */
|
|
21
|
+
type: HeuristicType;
|
|
22
|
+
/** 启发式权重(> 1 加速但可能不是最优) */
|
|
23
|
+
weight: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 默认启发式配置
|
|
27
|
+
*/
|
|
28
|
+
export declare const DEFAULT_HEURISTIC_CONFIG: HeuristicConfig;
|
|
29
|
+
/**
|
|
30
|
+
* 计算曼哈顿距离
|
|
31
|
+
* 适用于只能水平或垂直移动的场景
|
|
32
|
+
*/
|
|
33
|
+
export declare function manhattanDistance(from: Point, to: Point): number;
|
|
34
|
+
/**
|
|
35
|
+
* 计算欧几里得距离
|
|
36
|
+
* 适用于可以任意方向移动的场景
|
|
37
|
+
*/
|
|
38
|
+
export declare function euclideanDistance(from: Point, to: Point): number;
|
|
39
|
+
/**
|
|
40
|
+
* 计算八方向距离(Octile/Chebyshev)
|
|
41
|
+
* 适用于可以对角移动的场景
|
|
42
|
+
*/
|
|
43
|
+
export declare function octileDistance(from: Point, to: Point): number;
|
|
44
|
+
/**
|
|
45
|
+
* 根据配置计算启发式值
|
|
46
|
+
*/
|
|
47
|
+
export declare function calculateHeuristic(from: Point, to: Point, config?: HeuristicConfig): number;
|
|
48
|
+
/**
|
|
49
|
+
* 计算到多个目标点的最小启发式值
|
|
50
|
+
*/
|
|
51
|
+
export declare function calculateMinHeuristic(from: Point, targets: Point[], config?: HeuristicConfig): number;
|
|
52
|
+
/**
|
|
53
|
+
* 方向优先级计算
|
|
54
|
+
* 优先考虑与目标方向一致的移动
|
|
55
|
+
*/
|
|
56
|
+
export declare function calculateDirectionPriority(current: Point, neighbor: Point, target: Point, weight?: number): number;
|
|
57
|
+
/**
|
|
58
|
+
* 创建启发式函数
|
|
59
|
+
*/
|
|
60
|
+
export declare function createHeuristicFunction(config?: HeuristicConfig): (from: Point, targets: Point[]) => number;
|
|
61
|
+
//# sourceMappingURL=heuristics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heuristics.d.ts","sourceRoot":"","sources":["../../src/utils/heuristics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAEnC;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,WAAW,GAAG,QAAQ,CAAA;AAEhE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,cAAc;IACd,IAAI,EAAE,aAAa,CAAA;IACnB,2BAA2B;IAC3B,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;GAEG;AACH,eAAO,MAAM,wBAAwB,EAAE,eAGtC,CAAA;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,GAAG,MAAM,CAEhE;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,GAAG,MAAM,CAIhE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,GAAG,MAAM,CAO7D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,KAAK,EACX,EAAE,EAAE,KAAK,EACT,MAAM,GAAE,eAA0C,GACjD,MAAM,CAiBR;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,KAAK,EACX,OAAO,EAAE,KAAK,EAAE,EAChB,MAAM,GAAE,eAA0C,GACjD,MAAM,CAWR;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,KAAK,EACd,QAAQ,EAAE,KAAK,EACf,MAAM,EAAE,KAAK,EACb,MAAM,GAAE,MAAY,GACnB,MAAM,CAuBR;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,GAAE,eAA0C,GACjD,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,MAAM,CAI3C"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from './grid';
|
|
2
|
+
export * from './GlobalGrid';
|
|
3
|
+
export * from './direction';
|
|
4
|
+
export * from './rect';
|
|
5
|
+
export * from './route';
|
|
6
|
+
export * from './node';
|
|
7
|
+
export * from './pathValidation';
|
|
8
|
+
export * from './getAnchorPoints';
|
|
9
|
+
export * from './AdaptiveStepCalculator';
|
|
10
|
+
export * from './PerformanceMonitor';
|
|
11
|
+
export * from './ErrorRecovery';
|
|
12
|
+
export * from './heuristics';
|
|
13
|
+
export * from './pathProcessing';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,QAAQ,CAAA;AACtB,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA;AACtB,cAAc,kBAAkB,CAAA;AAChC,cAAc,mBAAmB,CAAA;AACjC,cAAc,0BAA0B,CAAA;AACxC,cAAc,sBAAsB,CAAA;AACpC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { InternalNode } from '../options';
|
|
2
|
+
/**
|
|
3
|
+
* Node dimensions interface
|
|
4
|
+
*/
|
|
5
|
+
export interface NodeDimensions {
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Get node dimensions following ReactFlow's internal logic
|
|
11
|
+
* Priority: measured > direct property > initialWidth/Height > 0
|
|
12
|
+
*
|
|
13
|
+
* @param node - ReactFlow internal node
|
|
14
|
+
* @returns Node dimensions with width and height
|
|
15
|
+
*/
|
|
16
|
+
export declare function getNodeDimensions(node: InternalNode): NodeDimensions;
|
|
17
|
+
/**
|
|
18
|
+
* Get node absolute position from internals
|
|
19
|
+
*
|
|
20
|
+
* @param node - ReactFlow internal node
|
|
21
|
+
* @returns Absolute position { x, y }
|
|
22
|
+
*/
|
|
23
|
+
export declare function getNodePosition(node: InternalNode): {
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/utils/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,YAAY,GAAG,cAAc,CAKpE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,YAAY,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAE5E"}
|