@ccpc/math 0.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/LICENSE +21 -0
- package/README.md +21 -0
- package/dist/constants/geom_type.d.ts +13 -0
- package/dist/constants/geom_type.d.ts.map +1 -0
- package/dist/constants/geom_type.js +17 -0
- package/dist/constants/math_const.d.ts +9 -0
- package/dist/constants/math_const.d.ts.map +1 -0
- package/dist/constants/math_const.js +12 -0
- package/dist/core/box2.d.ts +71 -0
- package/dist/core/box2.d.ts.map +1 -0
- package/dist/core/box2.js +243 -0
- package/dist/core/coord2d.d.ts +62 -0
- package/dist/core/coord2d.d.ts.map +1 -0
- package/dist/core/coord2d.js +155 -0
- package/dist/core/geom_base.d.ts +19 -0
- package/dist/core/geom_base.d.ts.map +1 -0
- package/dist/core/geom_base.js +18 -0
- package/dist/core/mat3.d.ts +101 -0
- package/dist/core/mat3.d.ts.map +1 -0
- package/dist/core/mat3.js +290 -0
- package/dist/core/vec2.d.ts +138 -0
- package/dist/core/vec2.d.ts.map +1 -0
- package/dist/core/vec2.js +297 -0
- package/dist/curves/arc2.d.ts +49 -0
- package/dist/curves/arc2.d.ts.map +1 -0
- package/dist/curves/arc2.js +265 -0
- package/dist/curves/bspline2.d.ts +150 -0
- package/dist/curves/bspline2.d.ts.map +1 -0
- package/dist/curves/bspline2.js +793 -0
- package/dist/curves/circle2.d.ts +42 -0
- package/dist/curves/circle2.d.ts.map +1 -0
- package/dist/curves/circle2.js +135 -0
- package/dist/curves/circle_curve2.d.ts +38 -0
- package/dist/curves/circle_curve2.d.ts.map +1 -0
- package/dist/curves/circle_curve2.js +112 -0
- package/dist/curves/curve2.d.ts +214 -0
- package/dist/curves/curve2.d.ts.map +1 -0
- package/dist/curves/curve2.js +238 -0
- package/dist/curves/ellipse2.d.ts +42 -0
- package/dist/curves/ellipse2.d.ts.map +1 -0
- package/dist/curves/ellipse2.js +125 -0
- package/dist/curves/ellipse_arc2.d.ts +49 -0
- package/dist/curves/ellipse_arc2.d.ts.map +1 -0
- package/dist/curves/ellipse_arc2.js +184 -0
- package/dist/curves/ellipse_curve2.d.ts +56 -0
- package/dist/curves/ellipse_curve2.d.ts.map +1 -0
- package/dist/curves/ellipse_curve2.js +262 -0
- package/dist/curves/interval.d.ts +112 -0
- package/dist/curves/interval.d.ts.map +1 -0
- package/dist/curves/interval.js +200 -0
- package/dist/curves/line2.d.ts +64 -0
- package/dist/curves/line2.d.ts.map +1 -0
- package/dist/curves/line2.js +193 -0
- package/dist/curves/period_interval.d.ts +129 -0
- package/dist/curves/period_interval.d.ts.map +1 -0
- package/dist/curves/period_interval.js +240 -0
- package/dist/discretize/discretize_defaults.d.ts +12 -0
- package/dist/discretize/discretize_defaults.d.ts.map +1 -0
- package/dist/discretize/discretize_defaults.js +12 -0
- package/dist/discretize/discretize_engine.d.ts +33 -0
- package/dist/discretize/discretize_engine.d.ts.map +1 -0
- package/dist/discretize/discretize_engine.js +347 -0
- package/dist/discretize/discretize_errors.d.ts +15 -0
- package/dist/discretize/discretize_errors.d.ts.map +1 -0
- package/dist/discretize/discretize_errors.js +30 -0
- package/dist/discretize/discretize_options.d.ts +18 -0
- package/dist/discretize/discretize_options.d.ts.map +1 -0
- package/dist/discretize/discretize_options.js +19 -0
- package/dist/discretize/discretize_types.d.ts +36 -0
- package/dist/discretize/discretize_types.d.ts.map +1 -0
- package/dist/discretize/discretize_types.js +1 -0
- package/dist/discretize/internal/curve_guards.d.ts +35 -0
- package/dist/discretize/internal/curve_guards.d.ts.map +1 -0
- package/dist/discretize/internal/curve_guards.js +62 -0
- package/dist/discretize/internal/postprocess.d.ts +5 -0
- package/dist/discretize/internal/postprocess.d.ts.map +1 -0
- package/dist/discretize/internal/postprocess.js +109 -0
- package/dist/discretize/internal/sampling_utils.d.ts +8 -0
- package/dist/discretize/internal/sampling_utils.d.ts.map +1 -0
- package/dist/discretize/internal/sampling_utils.js +36 -0
- package/dist/discretize/register_builtin_strategies.d.ts +3 -0
- package/dist/discretize/register_builtin_strategies.d.ts.map +1 -0
- package/dist/discretize/register_builtin_strategies.js +10 -0
- package/dist/discretize/strategies/bspline_strategy.d.ts +4 -0
- package/dist/discretize/strategies/bspline_strategy.d.ts.map +1 -0
- package/dist/discretize/strategies/bspline_strategy.js +115 -0
- package/dist/discretize/strategies/circle_strategy.d.ts +7 -0
- package/dist/discretize/strategies/circle_strategy.d.ts.map +1 -0
- package/dist/discretize/strategies/circle_strategy.js +55 -0
- package/dist/discretize/strategies/ellipse_strategy.d.ts +7 -0
- package/dist/discretize/strategies/ellipse_strategy.d.ts.map +1 -0
- package/dist/discretize/strategies/ellipse_strategy.js +86 -0
- package/dist/discretize/strategies/line_strategy.d.ts +4 -0
- package/dist/discretize/strategies/line_strategy.d.ts.map +1 -0
- package/dist/discretize/strategies/line_strategy.js +40 -0
- package/dist/discretize/strategy_registry.d.ts +9 -0
- package/dist/discretize/strategy_registry.d.ts.map +1 -0
- package/dist/discretize/strategy_registry.js +34 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/intersections/analytic_x_algorithm.d.ts +10 -0
- package/dist/intersections/analytic_x_algorithm.d.ts.map +1 -0
- package/dist/intersections/analytic_x_algorithm.js +83 -0
- package/dist/intersections/curve_x_engine.d.ts +9 -0
- package/dist/intersections/curve_x_engine.d.ts.map +1 -0
- package/dist/intersections/curve_x_engine.js +27 -0
- package/dist/intersections/index.d.ts +5 -0
- package/dist/intersections/index.d.ts.map +1 -0
- package/dist/intersections/index.js +11 -0
- package/dist/intersections/internal/certification.d.ts +34 -0
- package/dist/intersections/internal/certification.d.ts.map +1 -0
- package/dist/intersections/internal/certification.js +238 -0
- package/dist/intersections/internal/interval_clipping.d.ts +29 -0
- package/dist/intersections/internal/interval_clipping.d.ts.map +1 -0
- package/dist/intersections/internal/interval_clipping.js +123 -0
- package/dist/intersections/internal/kind.d.ts +4 -0
- package/dist/intersections/internal/kind.d.ts.map +1 -0
- package/dist/intersections/internal/kind.js +16 -0
- package/dist/intersections/internal/pair.d.ts +9 -0
- package/dist/intersections/internal/pair.d.ts.map +1 -0
- package/dist/intersections/internal/pair.js +14 -0
- package/dist/intersections/internal/result.d.ts +20 -0
- package/dist/intersections/internal/result.d.ts.map +1 -0
- package/dist/intersections/internal/result.js +125 -0
- package/dist/intersections/internal/sampling.d.ts +15 -0
- package/dist/intersections/internal/sampling.d.ts.map +1 -0
- package/dist/intersections/internal/sampling.js +131 -0
- package/dist/intersections/internal/segment.d.ts +32 -0
- package/dist/intersections/internal/segment.d.ts.map +1 -0
- package/dist/intersections/internal/segment.js +137 -0
- package/dist/intersections/internal/tolerance.d.ts +10 -0
- package/dist/intersections/internal/tolerance.d.ts.map +1 -0
- package/dist/intersections/internal/tolerance.js +20 -0
- package/dist/intersections/intersector.d.ts +6 -0
- package/dist/intersections/intersector.d.ts.map +1 -0
- package/dist/intersections/intersector.js +1 -0
- package/dist/intersections/numeric_x_algorithm.d.ts +10 -0
- package/dist/intersections/numeric_x_algorithm.d.ts.map +1 -0
- package/dist/intersections/numeric_x_algorithm.js +73 -0
- package/dist/intersections/solvers/bspline_self_solver.d.ts +7 -0
- package/dist/intersections/solvers/bspline_self_solver.d.ts.map +1 -0
- package/dist/intersections/solvers/bspline_self_solver.js +308 -0
- package/dist/intersections/solvers/line_line_pair_solver.d.ts +7 -0
- package/dist/intersections/solvers/line_line_pair_solver.d.ts.map +1 -0
- package/dist/intersections/solvers/line_line_pair_solver.js +35 -0
- package/dist/intersections/solvers/pair_solvers.d.ts +94 -0
- package/dist/intersections/solvers/pair_solvers.d.ts.map +1 -0
- package/dist/intersections/solvers/pair_solvers.js +1078 -0
- package/dist/intersections/solvers/polyline_pair_intersector.d.ts +51 -0
- package/dist/intersections/solvers/polyline_pair_intersector.d.ts.map +1 -0
- package/dist/intersections/solvers/polyline_pair_intersector.js +731 -0
- package/dist/intersections/types.d.ts +11 -0
- package/dist/intersections/types.d.ts.map +1 -0
- package/dist/intersections/types.js +1 -0
- package/dist/serialize/dump_types.d.ts +101 -0
- package/dist/serialize/dump_types.d.ts.map +1 -0
- package/dist/serialize/dump_types.js +5 -0
- package/dist/serialize/geom_mgr.d.ts +24 -0
- package/dist/serialize/geom_mgr.d.ts.map +1 -0
- package/dist/serialize/geom_mgr.js +30 -0
- package/dist/types/type_define.d.ts +29 -0
- package/dist/types/type_define.d.ts.map +1 -0
- package/dist/types/type_define.js +10 -0
- package/dist/types/type_guard.d.ts +46 -0
- package/dist/types/type_guard.d.ts.map +1 -0
- package/dist/types/type_guard.js +5 -0
- package/dist/utils/math_error.d.ts +16 -0
- package/dist/utils/math_error.d.ts.map +1 -0
- package/dist/utils/math_error.js +35 -0
- package/dist/utils/math_utils.d.ts +9 -0
- package/dist/utils/math_utils.d.ts.map +1 -0
- package/dist/utils/math_utils.js +25 -0
- package/dist/utils/precision.d.ts +29 -0
- package/dist/utils/precision.d.ts.map +1 -0
- package/dist/utils/precision.js +44 -0
- package/package.json +38 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Linea Math - Core
|
|
3
|
+
* 几何基类:统一序列化协议
|
|
4
|
+
*/
|
|
5
|
+
export class GeomBase {
|
|
6
|
+
/** 获取实例类型标识 */
|
|
7
|
+
getType() {
|
|
8
|
+
const ctor = this.constructor;
|
|
9
|
+
return ctor.type;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 运行时类型守卫:判断当前实例是否为目标构造器类型。
|
|
13
|
+
* 使用后可触发 TypeScript 类型收窄。
|
|
14
|
+
*/
|
|
15
|
+
isType(ctor) {
|
|
16
|
+
return this instanceof ctor;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { GeomBase } from './geom_base';
|
|
2
|
+
import { EN_GEO_TYPE } from '../constants/geom_type';
|
|
3
|
+
import type { IDBMat3 } from '../serialize/dump_types';
|
|
4
|
+
import { Vec2 } from './vec2';
|
|
5
|
+
import type { Num3x3 } from '../types/type_guard';
|
|
6
|
+
import type { IMat3 } from '../types/type_define';
|
|
7
|
+
export declare class Mat3 extends GeomBase implements IMat3 {
|
|
8
|
+
/** 序列化类型标识 */
|
|
9
|
+
static readonly type = EN_GEO_TYPE.Mat3;
|
|
10
|
+
/**
|
|
11
|
+
* 矩阵元素(列主序存储)
|
|
12
|
+
* 对外输入/输出使用行主序
|
|
13
|
+
*/
|
|
14
|
+
elements: Num3x3;
|
|
15
|
+
/** 创建一个 3x3 矩阵(对外行主序输入,内部列主序存储) */
|
|
16
|
+
constructor(m00?: number, m01?: number, m02?: number, m10?: number, m11?: number, m12?: number, m20?: number, m21?: number, m22?: number);
|
|
17
|
+
/** 行主序 -> 列主序 */
|
|
18
|
+
private static toColumnMajor;
|
|
19
|
+
/** 列主序 -> 行主序 */
|
|
20
|
+
private static toRowMajor;
|
|
21
|
+
/** 使用行主序数组设置矩阵 */
|
|
22
|
+
private setFromRowMajor;
|
|
23
|
+
/** 取行列元素(row/col 从 0 开始) */
|
|
24
|
+
private at;
|
|
25
|
+
/** 单位矩阵 */
|
|
26
|
+
static identity(): Mat3;
|
|
27
|
+
/** 平移矩阵 */
|
|
28
|
+
static translation(tx: number, ty: number): Mat3;
|
|
29
|
+
/** 旋转矩阵(弧度) */
|
|
30
|
+
static rotation(rad: number): Mat3;
|
|
31
|
+
/** 缩放矩阵 */
|
|
32
|
+
static scaling(sx: number, sy: number): Mat3;
|
|
33
|
+
/** 克隆 */
|
|
34
|
+
clone(): Mat3;
|
|
35
|
+
/** 右乘:this * m(就地修改) */
|
|
36
|
+
multiply(m: Mat3): this;
|
|
37
|
+
/** 右乘:this * m(返回新对象) */
|
|
38
|
+
multiplied(m: Mat3): Mat3;
|
|
39
|
+
/** 左乘:m * this(就地修改) */
|
|
40
|
+
premultiply(m: Mat3): this;
|
|
41
|
+
/** 左乘:m * this(返回新对象) */
|
|
42
|
+
premultiplied(m: Mat3): Mat3;
|
|
43
|
+
/** 平移(右乘,就地修改) */
|
|
44
|
+
translate(tx: number, ty: number): this;
|
|
45
|
+
/** 平移(右乘,返回新对象) */
|
|
46
|
+
translated(tx: number, ty: number): Mat3;
|
|
47
|
+
/** 旋转(右乘,就地修改) */
|
|
48
|
+
rotate(rad: number): this;
|
|
49
|
+
/** 旋转(右乘,返回新对象) */
|
|
50
|
+
rotated(rad: number): Mat3;
|
|
51
|
+
/** 缩放(右乘,就地修改) */
|
|
52
|
+
scale(sx: number, sy: number): this;
|
|
53
|
+
/** 缩放(右乘,返回新对象) */
|
|
54
|
+
scaled(sx: number, sy: number): Mat3;
|
|
55
|
+
/** 变换点(就地修改) */
|
|
56
|
+
transformPoint(v: Vec2): Vec2;
|
|
57
|
+
/** 变换点(返回新对象) */
|
|
58
|
+
transformedPoint(v: Vec2): Vec2;
|
|
59
|
+
/** 变换向量(就地修改,不含平移) */
|
|
60
|
+
transformVector(v: Vec2): Vec2;
|
|
61
|
+
/** 变换向量(返回新对象,不含平移) */
|
|
62
|
+
transformedVector(v: Vec2): Vec2;
|
|
63
|
+
/** 行列式 */
|
|
64
|
+
determinant(): number;
|
|
65
|
+
/** 逆矩阵(就地修改,不可逆抛错) */
|
|
66
|
+
invert(eps?: number): this;
|
|
67
|
+
/** 逆矩阵(返回新对象) */
|
|
68
|
+
inverted(eps?: number): Mat3;
|
|
69
|
+
/** 近似相等 */
|
|
70
|
+
equals(m: Mat3, eps?: number): boolean;
|
|
71
|
+
/** 转为数组(行主序) */
|
|
72
|
+
toArray(): readonly [number, number, number, number, number, number, number, number, number];
|
|
73
|
+
/**
|
|
74
|
+
* 分解为平移/旋转/缩放
|
|
75
|
+
* - 假定矩阵不包含剪切
|
|
76
|
+
* - 旋转角为弧度
|
|
77
|
+
*/
|
|
78
|
+
decompose(): {
|
|
79
|
+
translation: Vec2;
|
|
80
|
+
rotation: number;
|
|
81
|
+
scale: Vec2;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* 判断矩阵是否为二维相似变换。
|
|
85
|
+
* 对线性部分 A 的要求:
|
|
86
|
+
* - 在容差内满足 A^T A = s^2 I
|
|
87
|
+
* - s > 0
|
|
88
|
+
* 允许镜像(det(A) < 0)。
|
|
89
|
+
*/
|
|
90
|
+
isSimilarity2D(eps?: number): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* 返回二维相似变换的统一缩放系数。
|
|
93
|
+
* 若矩阵不是二维相似变换则抛错。
|
|
94
|
+
*/
|
|
95
|
+
getSimilarityScale2D(eps?: number): number;
|
|
96
|
+
/** 序列化为结构对象 */
|
|
97
|
+
dump(): IDBMat3;
|
|
98
|
+
/** 从结构对象反序列化 */
|
|
99
|
+
static load(data: IDBMat3): Mat3;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=mat3.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mat3.d.ts","sourceRoot":"","sources":["../../src/core/mat3.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAIjD,qBACa,IAAK,SAAQ,QAAS,YAAW,KAAK;IAC/C,cAAc;IACd,gBAAuB,IAAI,oBAAmB;IAE9C;;;OAGG;IACI,QAAQ,EAAE,MAAM,CAAA;IAEvB,mCAAmC;gBAE/B,GAAG,SAAI,EAAE,GAAG,SAAI,EAAE,GAAG,SAAI,EACzB,GAAG,SAAI,EAAE,GAAG,SAAI,EAAE,GAAG,SAAI,EACzB,GAAG,SAAI,EAAE,GAAG,SAAI,EAAE,GAAG,S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CAAC,EAAE,IAAI;IAOhC,UAAU;IACH,WAAW;IAOlB,sBAAsB;IACf,MAAM,CAAC,GAAG,SAAoB;IA2BrC,iBAAiB;IACV,QAAQ,CAAC,GAAG,SAAoB;IAIvC,WAAW;IACJ,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,SAAgB;IAgB1C,gBAAgB;IACT,OAAO;IAId;;;;OAIG;IACI,SAAS;;;;;IAyBhB;;;;;;OAMG;IACI,cAAc,CAAC,GAAG,SAA4B;IAoBrD;;;OAGG;IACI,oBAAoB,CAAC,GAAG,SAA4B;IAQ3D,eAAe;IACR,IAAI,IAAI,OAAO;IAOtB,gBAAgB;WACF,IAAI,CAAC,IAAI,EAAE,OAAO;CAQnC"}
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Linea Math - Core
|
|
3
|
+
* Mat3:二维仿射矩阵,列向量 + 右乘约定
|
|
4
|
+
*/
|
|
5
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
6
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
7
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
8
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
9
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10
|
+
};
|
|
11
|
+
var Mat3_1;
|
|
12
|
+
import { GeomBase } from './geom_base';
|
|
13
|
+
import { EN_GEO_TYPE } from '../constants/geom_type';
|
|
14
|
+
import { RegisterGeom } from '../serialize/geom_mgr';
|
|
15
|
+
import { Vec2 } from './vec2';
|
|
16
|
+
import { Precision } from '../utils/precision';
|
|
17
|
+
import { MathError } from '../utils/math_error';
|
|
18
|
+
let Mat3 = Mat3_1 = class Mat3 extends GeomBase {
|
|
19
|
+
/** 创建一个 3x3 矩阵(对外行主序输入,内部列主序存储) */
|
|
20
|
+
constructor(m00 = 1, m01 = 0, m02 = 0, m10 = 0, m11 = 1, m12 = 0, m20 = 0, m21 = 0, m22 = 1) {
|
|
21
|
+
super();
|
|
22
|
+
this.elements = Mat3_1.toColumnMajor([
|
|
23
|
+
m00, m01, m02,
|
|
24
|
+
m10, m11, m12,
|
|
25
|
+
m20, m21, m22,
|
|
26
|
+
]);
|
|
27
|
+
}
|
|
28
|
+
/** 行主序 -> 列主序 */
|
|
29
|
+
static toColumnMajor(e) {
|
|
30
|
+
return [
|
|
31
|
+
e[0], e[3], e[6],
|
|
32
|
+
e[1], e[4], e[7],
|
|
33
|
+
e[2], e[5], e[8],
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
/** 列主序 -> 行主序 */
|
|
37
|
+
static toRowMajor(e) {
|
|
38
|
+
return [
|
|
39
|
+
e[0], e[3], e[6],
|
|
40
|
+
e[1], e[4], e[7],
|
|
41
|
+
e[2], e[5], e[8],
|
|
42
|
+
];
|
|
43
|
+
}
|
|
44
|
+
/** 使用行主序数组设置矩阵 */
|
|
45
|
+
setFromRowMajor(e) {
|
|
46
|
+
this.elements = Mat3_1.toColumnMajor(e);
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
/** 取行列元素(row/col 从 0 开始) */
|
|
50
|
+
at(row, col) {
|
|
51
|
+
return this.elements[col * 3 + row];
|
|
52
|
+
}
|
|
53
|
+
/** 单位矩阵 */
|
|
54
|
+
static identity() {
|
|
55
|
+
return new Mat3_1();
|
|
56
|
+
}
|
|
57
|
+
/** 平移矩阵 */
|
|
58
|
+
static translation(tx, ty) {
|
|
59
|
+
return new Mat3_1(1, 0, tx, 0, 1, ty, 0, 0, 1);
|
|
60
|
+
}
|
|
61
|
+
/** 旋转矩阵(弧度) */
|
|
62
|
+
static rotation(rad) {
|
|
63
|
+
const c = Math.cos(rad);
|
|
64
|
+
const s = Math.sin(rad);
|
|
65
|
+
return new Mat3_1(c, -s, 0, s, c, 0, 0, 0, 1);
|
|
66
|
+
}
|
|
67
|
+
/** 缩放矩阵 */
|
|
68
|
+
static scaling(sx, sy) {
|
|
69
|
+
return new Mat3_1(sx, 0, 0, 0, sy, 0, 0, 0, 1);
|
|
70
|
+
}
|
|
71
|
+
/** 克隆 */
|
|
72
|
+
clone() {
|
|
73
|
+
const e = Mat3_1.toRowMajor(this.elements);
|
|
74
|
+
return new Mat3_1(e[0], e[1], e[2], e[3], e[4], e[5], e[6], e[7], e[8]);
|
|
75
|
+
}
|
|
76
|
+
/** 右乘:this * m(就地修改) */
|
|
77
|
+
multiply(m) {
|
|
78
|
+
const a00 = this.at(0, 0) * m.at(0, 0) + this.at(0, 1) * m.at(1, 0) + this.at(0, 2) * m.at(2, 0);
|
|
79
|
+
const a01 = this.at(0, 0) * m.at(0, 1) + this.at(0, 1) * m.at(1, 1) + this.at(0, 2) * m.at(2, 1);
|
|
80
|
+
const a02 = this.at(0, 0) * m.at(0, 2) + this.at(0, 1) * m.at(1, 2) + this.at(0, 2) * m.at(2, 2);
|
|
81
|
+
const a10 = this.at(1, 0) * m.at(0, 0) + this.at(1, 1) * m.at(1, 0) + this.at(1, 2) * m.at(2, 0);
|
|
82
|
+
const a11 = this.at(1, 0) * m.at(0, 1) + this.at(1, 1) * m.at(1, 1) + this.at(1, 2) * m.at(2, 1);
|
|
83
|
+
const a12 = this.at(1, 0) * m.at(0, 2) + this.at(1, 1) * m.at(1, 2) + this.at(1, 2) * m.at(2, 2);
|
|
84
|
+
const a20 = this.at(2, 0) * m.at(0, 0) + this.at(2, 1) * m.at(1, 0) + this.at(2, 2) * m.at(2, 0);
|
|
85
|
+
const a21 = this.at(2, 0) * m.at(0, 1) + this.at(2, 1) * m.at(1, 1) + this.at(2, 2) * m.at(2, 1);
|
|
86
|
+
const a22 = this.at(2, 0) * m.at(0, 2) + this.at(2, 1) * m.at(1, 2) + this.at(2, 2) * m.at(2, 2);
|
|
87
|
+
return this.setFromRowMajor([a00, a01, a02, a10, a11, a12, a20, a21, a22]);
|
|
88
|
+
}
|
|
89
|
+
/** 右乘:this * m(返回新对象) */
|
|
90
|
+
multiplied(m) {
|
|
91
|
+
return this.clone().multiply(m);
|
|
92
|
+
}
|
|
93
|
+
/** 左乘:m * this(就地修改) */
|
|
94
|
+
premultiply(m) {
|
|
95
|
+
const a00 = m.at(0, 0) * this.at(0, 0) + m.at(0, 1) * this.at(1, 0) + m.at(0, 2) * this.at(2, 0);
|
|
96
|
+
const a01 = m.at(0, 0) * this.at(0, 1) + m.at(0, 1) * this.at(1, 1) + m.at(0, 2) * this.at(2, 1);
|
|
97
|
+
const a02 = m.at(0, 0) * this.at(0, 2) + m.at(0, 1) * this.at(1, 2) + m.at(0, 2) * this.at(2, 2);
|
|
98
|
+
const a10 = m.at(1, 0) * this.at(0, 0) + m.at(1, 1) * this.at(1, 0) + m.at(1, 2) * this.at(2, 0);
|
|
99
|
+
const a11 = m.at(1, 0) * this.at(0, 1) + m.at(1, 1) * this.at(1, 1) + m.at(1, 2) * this.at(2, 1);
|
|
100
|
+
const a12 = m.at(1, 0) * this.at(0, 2) + m.at(1, 1) * this.at(1, 2) + m.at(1, 2) * this.at(2, 2);
|
|
101
|
+
const a20 = m.at(2, 0) * this.at(0, 0) + m.at(2, 1) * this.at(1, 0) + m.at(2, 2) * this.at(2, 0);
|
|
102
|
+
const a21 = m.at(2, 0) * this.at(0, 1) + m.at(2, 1) * this.at(1, 1) + m.at(2, 2) * this.at(2, 1);
|
|
103
|
+
const a22 = m.at(2, 0) * this.at(0, 2) + m.at(2, 1) * this.at(1, 2) + m.at(2, 2) * this.at(2, 2);
|
|
104
|
+
return this.setFromRowMajor([a00, a01, a02, a10, a11, a12, a20, a21, a22]);
|
|
105
|
+
}
|
|
106
|
+
/** 左乘:m * this(返回新对象) */
|
|
107
|
+
premultiplied(m) {
|
|
108
|
+
return this.clone().premultiply(m);
|
|
109
|
+
}
|
|
110
|
+
/** 平移(右乘,就地修改) */
|
|
111
|
+
translate(tx, ty) {
|
|
112
|
+
return this.multiply(Mat3_1.translation(tx, ty));
|
|
113
|
+
}
|
|
114
|
+
/** 平移(右乘,返回新对象) */
|
|
115
|
+
translated(tx, ty) {
|
|
116
|
+
return this.clone().translate(tx, ty);
|
|
117
|
+
}
|
|
118
|
+
/** 旋转(右乘,就地修改) */
|
|
119
|
+
rotate(rad) {
|
|
120
|
+
return this.multiply(Mat3_1.rotation(rad));
|
|
121
|
+
}
|
|
122
|
+
/** 旋转(右乘,返回新对象) */
|
|
123
|
+
rotated(rad) {
|
|
124
|
+
return this.clone().rotate(rad);
|
|
125
|
+
}
|
|
126
|
+
/** 缩放(右乘,就地修改) */
|
|
127
|
+
scale(sx, sy) {
|
|
128
|
+
return this.multiply(Mat3_1.scaling(sx, sy));
|
|
129
|
+
}
|
|
130
|
+
/** 缩放(右乘,返回新对象) */
|
|
131
|
+
scaled(sx, sy) {
|
|
132
|
+
return this.clone().scale(sx, sy);
|
|
133
|
+
}
|
|
134
|
+
/** 变换点(就地修改) */
|
|
135
|
+
transformPoint(v) {
|
|
136
|
+
const x = this.at(0, 0) * v.x + this.at(0, 1) * v.y + this.at(0, 2);
|
|
137
|
+
const y = this.at(1, 0) * v.x + this.at(1, 1) * v.y + this.at(1, 2);
|
|
138
|
+
v.x = x;
|
|
139
|
+
v.y = y;
|
|
140
|
+
return v;
|
|
141
|
+
}
|
|
142
|
+
/** 变换点(返回新对象) */
|
|
143
|
+
transformedPoint(v) {
|
|
144
|
+
return v.clone().applyMat3(this);
|
|
145
|
+
}
|
|
146
|
+
/** 变换向量(就地修改,不含平移) */
|
|
147
|
+
transformVector(v) {
|
|
148
|
+
const x = this.at(0, 0) * v.x + this.at(0, 1) * v.y;
|
|
149
|
+
const y = this.at(1, 0) * v.x + this.at(1, 1) * v.y;
|
|
150
|
+
v.x = x;
|
|
151
|
+
v.y = y;
|
|
152
|
+
return v;
|
|
153
|
+
}
|
|
154
|
+
/** 变换向量(返回新对象,不含平移) */
|
|
155
|
+
transformedVector(v) {
|
|
156
|
+
return new Vec2(this.at(0, 0) * v.x + this.at(0, 1) * v.y, this.at(1, 0) * v.x + this.at(1, 1) * v.y);
|
|
157
|
+
}
|
|
158
|
+
/** 行列式 */
|
|
159
|
+
determinant() {
|
|
160
|
+
const a = this.at(0, 0), b = this.at(0, 1), c = this.at(0, 2);
|
|
161
|
+
const d = this.at(1, 0), e = this.at(1, 1), f = this.at(1, 2);
|
|
162
|
+
const g = this.at(2, 0), h = this.at(2, 1), i = this.at(2, 2);
|
|
163
|
+
return a * e * i + b * f * g + c * d * h - c * e * g - b * d * i - a * f * h;
|
|
164
|
+
}
|
|
165
|
+
/** 逆矩阵(就地修改,不可逆抛错) */
|
|
166
|
+
invert(eps = Precision.LEN_EPS) {
|
|
167
|
+
const det = this.determinant();
|
|
168
|
+
if (Math.abs(det) <= eps) {
|
|
169
|
+
MathError.throw('Mat3.invert: matrix is not invertible');
|
|
170
|
+
}
|
|
171
|
+
const a = this.at(0, 0), b = this.at(0, 1), c = this.at(0, 2);
|
|
172
|
+
const d = this.at(1, 0), e = this.at(1, 1), f = this.at(1, 2);
|
|
173
|
+
const g = this.at(2, 0), h = this.at(2, 1), i = this.at(2, 2);
|
|
174
|
+
const A = e * i - f * h;
|
|
175
|
+
const B = c * h - b * i;
|
|
176
|
+
const C = b * f - c * e;
|
|
177
|
+
const D = f * g - d * i;
|
|
178
|
+
const E = a * i - c * g;
|
|
179
|
+
const F = c * d - a * f;
|
|
180
|
+
const G = d * h - e * g;
|
|
181
|
+
const H = b * g - a * h;
|
|
182
|
+
const I = a * e - b * d;
|
|
183
|
+
const invDet = 1 / det;
|
|
184
|
+
return this.setFromRowMajor([
|
|
185
|
+
A * invDet, B * invDet, C * invDet,
|
|
186
|
+
D * invDet, E * invDet, F * invDet,
|
|
187
|
+
G * invDet, H * invDet, I * invDet,
|
|
188
|
+
]);
|
|
189
|
+
}
|
|
190
|
+
/** 逆矩阵(返回新对象) */
|
|
191
|
+
inverted(eps = Precision.LEN_EPS) {
|
|
192
|
+
return this.clone().invert(eps);
|
|
193
|
+
}
|
|
194
|
+
/** 近似相等 */
|
|
195
|
+
equals(m, eps = Precision.EPS) {
|
|
196
|
+
const a = this.elements;
|
|
197
|
+
const b = m.elements;
|
|
198
|
+
return (Precision.equal(a[0], b[0], eps) &&
|
|
199
|
+
Precision.equal(a[1], b[1], eps) &&
|
|
200
|
+
Precision.equal(a[2], b[2], eps) &&
|
|
201
|
+
Precision.equal(a[3], b[3], eps) &&
|
|
202
|
+
Precision.equal(a[4], b[4], eps) &&
|
|
203
|
+
Precision.equal(a[5], b[5], eps) &&
|
|
204
|
+
Precision.equal(a[6], b[6], eps) &&
|
|
205
|
+
Precision.equal(a[7], b[7], eps) &&
|
|
206
|
+
Precision.equal(a[8], b[8], eps));
|
|
207
|
+
}
|
|
208
|
+
/** 转为数组(行主序) */
|
|
209
|
+
toArray() {
|
|
210
|
+
return Mat3_1.toRowMajor(this.elements);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* 分解为平移/旋转/缩放
|
|
214
|
+
* - 假定矩阵不包含剪切
|
|
215
|
+
* - 旋转角为弧度
|
|
216
|
+
*/
|
|
217
|
+
decompose() {
|
|
218
|
+
const e = this.toArray();
|
|
219
|
+
const m00 = e[0], m01 = e[1], m02 = e[2];
|
|
220
|
+
const m10 = e[3], m11 = e[4], m12 = e[5];
|
|
221
|
+
const tx = m02;
|
|
222
|
+
const ty = m12;
|
|
223
|
+
const sx = Math.hypot(m00, m10);
|
|
224
|
+
let sy = Math.hypot(m01, m11);
|
|
225
|
+
const det = m00 * m11 - m01 * m10;
|
|
226
|
+
if (det < 0) {
|
|
227
|
+
sy = -sy;
|
|
228
|
+
}
|
|
229
|
+
const rotation = Math.atan2(m10, m00);
|
|
230
|
+
return {
|
|
231
|
+
translation: new Vec2(tx, ty),
|
|
232
|
+
rotation,
|
|
233
|
+
scale: new Vec2(sx, sy),
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* 判断矩阵是否为二维相似变换。
|
|
238
|
+
* 对线性部分 A 的要求:
|
|
239
|
+
* - 在容差内满足 A^T A = s^2 I
|
|
240
|
+
* - s > 0
|
|
241
|
+
* 允许镜像(det(A) < 0)。
|
|
242
|
+
*/
|
|
243
|
+
isSimilarity2D(eps = Precision.CURVE_PARAM_EPS) {
|
|
244
|
+
const e = this.toArray();
|
|
245
|
+
if (!Precision.nearlyZero(e[6], eps) || !Precision.nearlyZero(e[7], eps) || !Precision.equal(e[8], 1, eps)) {
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
const a = e[0];
|
|
249
|
+
const b = e[1];
|
|
250
|
+
const c = e[3];
|
|
251
|
+
const d = e[4];
|
|
252
|
+
const col0Sq = a * a + c * c;
|
|
253
|
+
const col1Sq = b * b + d * d;
|
|
254
|
+
const colDot = a * b + c * d;
|
|
255
|
+
if (col0Sq <= eps * eps || col1Sq <= eps * eps)
|
|
256
|
+
return false;
|
|
257
|
+
if (!Precision.nearlyZero(colDot, eps))
|
|
258
|
+
return false;
|
|
259
|
+
return Precision.equal(col0Sq, col1Sq, eps);
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* 返回二维相似变换的统一缩放系数。
|
|
263
|
+
* 若矩阵不是二维相似变换则抛错。
|
|
264
|
+
*/
|
|
265
|
+
getSimilarityScale2D(eps = Precision.CURVE_PARAM_EPS) {
|
|
266
|
+
MathError.assert(this.isSimilarity2D(eps), 'Mat3.getSimilarityScale2D: matrix is not a 2D similarity transform');
|
|
267
|
+
const e = this.toArray();
|
|
268
|
+
const col0Sq = e[0] * e[0] + e[3] * e[3];
|
|
269
|
+
const col1Sq = e[1] * e[1] + e[4] * e[4];
|
|
270
|
+
return Math.sqrt((col0Sq + col1Sq) * 0.5);
|
|
271
|
+
}
|
|
272
|
+
/** 序列化为结构对象 */
|
|
273
|
+
dump() {
|
|
274
|
+
return {
|
|
275
|
+
type: Mat3_1.type,
|
|
276
|
+
elements: this.toArray(),
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
/** 从结构对象反序列化 */
|
|
280
|
+
static load(data) {
|
|
281
|
+
const e = data.elements;
|
|
282
|
+
return new Mat3_1(e[0], e[1], e[2], e[3], e[4], e[5], e[6], e[7], e[8]);
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
/** 序列化类型标识 */
|
|
286
|
+
Mat3.type = EN_GEO_TYPE.Mat3;
|
|
287
|
+
Mat3 = Mat3_1 = __decorate([
|
|
288
|
+
RegisterGeom
|
|
289
|
+
], Mat3);
|
|
290
|
+
export { Mat3 };
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { GeomBase } from './geom_base';
|
|
2
|
+
import { EN_GEO_TYPE } from '../constants/geom_type';
|
|
3
|
+
import type { IDBVec2 } from '../serialize/dump_types';
|
|
4
|
+
import type { IVec2 } from '../types/type_define';
|
|
5
|
+
import type { Mat3 } from './mat3';
|
|
6
|
+
export declare class Vec2 extends GeomBase implements IVec2 {
|
|
7
|
+
/** 序列化类型标识 */
|
|
8
|
+
static readonly type = EN_GEO_TYPE.Vec2;
|
|
9
|
+
/** X 分量 */
|
|
10
|
+
x: number;
|
|
11
|
+
/** Y 分量 */
|
|
12
|
+
y: number;
|
|
13
|
+
/** 创建一个向量实例 */
|
|
14
|
+
constructor();
|
|
15
|
+
constructor(x: number, y: number);
|
|
16
|
+
constructor(obj: IVec2);
|
|
17
|
+
/** 零向量 */
|
|
18
|
+
static zero(): Vec2;
|
|
19
|
+
/** 单位向量 X */
|
|
20
|
+
static unitX(): Vec2;
|
|
21
|
+
/** 单位向量 Y */
|
|
22
|
+
static unitY(): Vec2;
|
|
23
|
+
/** 克隆当前向量 */
|
|
24
|
+
clone(): Vec2;
|
|
25
|
+
/** 返回替换 X 分量的新向量 */
|
|
26
|
+
withX(x: number): Vec2;
|
|
27
|
+
/** 返回替换 Y 分量的新向量 */
|
|
28
|
+
withY(y: number): Vec2;
|
|
29
|
+
/** 设置 X 分量(就地修改) */
|
|
30
|
+
setX(x: number): this;
|
|
31
|
+
/** 设置 Y 分量(就地修改) */
|
|
32
|
+
setY(y: number): this;
|
|
33
|
+
/** 向量相加(就地修改) */
|
|
34
|
+
add(v: Vec2): this;
|
|
35
|
+
/** 向量相加(返回新对象) */
|
|
36
|
+
added(v: Vec2): Vec2;
|
|
37
|
+
/** 向量相减(就地修改) */
|
|
38
|
+
subtract(v: Vec2): this;
|
|
39
|
+
/** 向量相减(返回新对象) */
|
|
40
|
+
subtracted(v: Vec2): Vec2;
|
|
41
|
+
/**
|
|
42
|
+
* 向量线性叠加:this + v * s
|
|
43
|
+
* - 常用于积分、插值、偏移等计算
|
|
44
|
+
*/
|
|
45
|
+
addScaled(v: Vec2, s: number): this;
|
|
46
|
+
/** 向量线性叠加(返回新对象) */
|
|
47
|
+
addScaleded(v: Vec2, s: number): Vec2;
|
|
48
|
+
/** 反向量(取相反方向) */
|
|
49
|
+
negate(): this;
|
|
50
|
+
/** 反向量(返回新对象) */
|
|
51
|
+
negated(): Vec2;
|
|
52
|
+
/**
|
|
53
|
+
* 绕原点旋转(弧度)
|
|
54
|
+
* - 逆时针为正方向
|
|
55
|
+
*/
|
|
56
|
+
rotate(rad: number): this;
|
|
57
|
+
/** 绕原点旋转(返回新对象) */
|
|
58
|
+
rotated(rad: number): Vec2;
|
|
59
|
+
/**
|
|
60
|
+
* 绕指定点旋转(弧度)
|
|
61
|
+
* - 先平移到原点旋转,再平移回去
|
|
62
|
+
*/
|
|
63
|
+
rotateAround(center: Vec2, rad: number): this;
|
|
64
|
+
/**
|
|
65
|
+
* 垂直向量(默认逆时针 90°)
|
|
66
|
+
* - (x, y) -> (-y, x)
|
|
67
|
+
* - 若需顺时针方向,可对结果取反
|
|
68
|
+
*/
|
|
69
|
+
perp(): this;
|
|
70
|
+
/** 垂直向量(返回新对象) */
|
|
71
|
+
perped(): Vec2;
|
|
72
|
+
/** 标量缩放 */
|
|
73
|
+
scale(s: number): this;
|
|
74
|
+
/** 标量缩放(返回新对象) */
|
|
75
|
+
scaled(s: number): Vec2;
|
|
76
|
+
/** 点积 */
|
|
77
|
+
dot(v: Vec2): number;
|
|
78
|
+
/** 叉积(返回标量) */
|
|
79
|
+
cross(v: Vec2): number;
|
|
80
|
+
/** 长度平方 */
|
|
81
|
+
lenSq(): number;
|
|
82
|
+
/** 向量长度 */
|
|
83
|
+
len(): number;
|
|
84
|
+
/**
|
|
85
|
+
* 设置向量长度(保持方向)
|
|
86
|
+
* - 零向量返回零向量
|
|
87
|
+
*/
|
|
88
|
+
setLength(len: number, eps?: number): this;
|
|
89
|
+
/** 设置向量长度(返回新对象) */
|
|
90
|
+
setLengthed(len: number, eps?: number): Vec2;
|
|
91
|
+
/** 归一化,极短向量返回零向量 */
|
|
92
|
+
normalize(eps?: number): this;
|
|
93
|
+
/** 归一化(返回新对象) */
|
|
94
|
+
normalized(eps?: number): Vec2;
|
|
95
|
+
/**
|
|
96
|
+
* 应用 Mat3 变换(就地修改)
|
|
97
|
+
*/
|
|
98
|
+
applyMat3(m: Mat3): Vec2;
|
|
99
|
+
/** 应用 Mat3 变换(返回新对象) */
|
|
100
|
+
appliedMat3(m: Mat3): Vec2;
|
|
101
|
+
/** 到目标向量的距离 */
|
|
102
|
+
distanceTo(v: Vec2): number;
|
|
103
|
+
/** 到目标向量的距离平方(避免开方,更高效) */
|
|
104
|
+
distanceToSq(v: Vec2): number;
|
|
105
|
+
/**
|
|
106
|
+
* 向量投影(投影到目标向量上)
|
|
107
|
+
* - 若目标向量为零向量,则返回零向量
|
|
108
|
+
* - 结果与目标向量共线
|
|
109
|
+
*/
|
|
110
|
+
project(on: Vec2, eps?: number): this;
|
|
111
|
+
/** 向量投影(返回新对象) */
|
|
112
|
+
projected(on: Vec2, eps?: number): Vec2;
|
|
113
|
+
/**
|
|
114
|
+
* 返回向量的方向角(弧度)
|
|
115
|
+
* - 相对于 +X 轴的角度
|
|
116
|
+
* - 结果范围为 [-PI, PI]
|
|
117
|
+
*/
|
|
118
|
+
angle(): number;
|
|
119
|
+
/** 线性插值 */
|
|
120
|
+
lerp(v: Vec2, t: number): Vec2;
|
|
121
|
+
/**
|
|
122
|
+
* 计算当前向量到目标向量的夹角(弧度)
|
|
123
|
+
* - 结果范围为 [-PI, PI]
|
|
124
|
+
* - 使用 atan2(cross, dot),保留方向(顺时针/逆时针)
|
|
125
|
+
*/
|
|
126
|
+
angleTo(v: Vec2): number;
|
|
127
|
+
/** 判断分量是否为有限数 */
|
|
128
|
+
isFinite(): boolean;
|
|
129
|
+
/** 判断是否近似相等 */
|
|
130
|
+
equals(v: Vec2, eps?: number): boolean;
|
|
131
|
+
/** 转为元组 */
|
|
132
|
+
toArray(): readonly [number, number];
|
|
133
|
+
/** 序列化为结构对象 */
|
|
134
|
+
dump(): IDBVec2;
|
|
135
|
+
/** 从结构对象反序列化 */
|
|
136
|
+
static load(data: IDBVec2): Vec2;
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=vec2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vec2.d.ts","sourceRoot":"","sources":["../../src/core/vec2.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAEtD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAElC,qBACa,IAAK,SAAQ,QAAS,YAAW,KAAK;IAC/C,cAAc;IACd,gBAAuB,IAAI,oBAAmB;IAE9C,WAAW;IACJ,CAAC,EAAE,MAAM,CAAA;IAEhB,WAAW;IACJ,CAAC,EAAE,MAAM,CAAA;IAEhB,eAAe;;gBAGH,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