SYS_Math.contains() method
Determine whether polygon1 completely contains polygon2
Signature
typescript
function contains(polygon1: TSYS_MathPolygonInput, polygon2: TSYS_MathPolygonInput): boolean;1
Parameters
Parameter | Type | Description |
|---|---|---|
polygon1 | Outer polygon | |
polygon2 | Internal polygon |
Returns
boolean
Whether polygon1 completely contains polygon2
Example
javascript
// 1. 小矩形完全落在大矩形内部 → true
const board = [{ x: 0, y: 0 }, { x: 200, y: 0 }, { x: 200, y: 120 }, { x: 0, y: 120 }];
const device = [{ x: 50, y: 40 }, { x: 90, y: 40 }, { x: 90, y: 70 }, { x: 50, y: 70 }];
console.log('板框完全包含器件:', eda.sys_Math.contains(board, device));
// 2. 器件跨越板框边界(部分重叠,不是完全包含)→ false
const overhang = [{ x: 150, y: 40 }, { x: 250, y: 40 }, { x: 250, y: 70 }, { x: 150, y: 70 }];
console.log('板框完全包含越界器件:', eda.sys_Math.contains(board, overhang));
// 3. 只关心区域重叠不关心完全包含时,配合 intersects 使用
console.log('两器件区域有重叠:', eda.sys_Math.intersects(device, overhang));1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11