[gs-longan](../README.md) / DGeometryOperators

# Class: DGeometryOperators

常用几何运算函数集合（双精度）

与 `GeometryOperators` 对应，但使用双精度数组 (`Float64Array`) 以提高数值精度。

## Table of contents

### Constructors

- [constructor](DGeometryOperators.md#constructor)

### Methods

- [angleBetween](DGeometryOperators.md#anglebetween)
- [angleBetweenByNormal](DGeometryOperators.md#anglebetweenbynormal)
- [arrangePolygon](DGeometryOperators.md#arrangepolygon)
- [closestPoint](DGeometryOperators.md#closestpoint)
- [createPolylinesBySegments](DGeometryOperators.md#createpolylinesbysegments)
- [createRingPoints](DGeometryOperators.md#createringpoints)
- [distance](DGeometryOperators.md#distance)
- [distancePoint](DGeometryOperators.md#distancepoint)
- [includeAngleBetween](DGeometryOperators.md#includeanglebetween)
- [intersectionLineLine](DGeometryOperators.md#intersectionlineline)
- [intersectionLineLine1](DGeometryOperators.md#intersectionlineline1)
- [intersectionLinePlane](DGeometryOperators.md#intersectionlineplane)
- [intersectionLineSegmentLineSegment](DGeometryOperators.md#intersectionlinesegmentlinesegment)
- [intersectionLineSegmentPlane](DGeometryOperators.md#intersectionlinesegmentplane)
- [inversePolygon](DGeometryOperators.md#inversepolygon)
- [isParallel](DGeometryOperators.md#isparallel)
- [isPerpendicular](DGeometryOperators.md#isperpendicular)
- [isPointInLineSegment](DGeometryOperators.md#ispointinlinesegment)
- [isPointInPolygonXy](DGeometryOperators.md#ispointinpolygonxy)
- [isPointOnPolygonXy](DGeometryOperators.md#ispointonpolygonxy)
- [lineParam](DGeometryOperators.md#lineparam)
- [lineParam1](DGeometryOperators.md#lineparam1)
- [polygonNormal](DGeometryOperators.md#polygonnormal)
- [projectPointToLine](DGeometryOperators.md#projectpointtoline)
- [projectPointToLine1](DGeometryOperators.md#projectpointtoline1)
- [projectPointToLineWithParam](DGeometryOperators.md#projectpointtolinewithparam)
- [projectPointToPlane](DGeometryOperators.md#projectpointtoplane)
- [reversePoints](DGeometryOperators.md#reversepoints)
- [samePoint](DGeometryOperators.md#samepoint)
- [samePointWithTolerance](DGeometryOperators.md#samepointwithtolerance)
- [sameVector](DGeometryOperators.md#samevector)

## Constructors

### constructor

• **new DGeometryOperators**(): [`DGeometryOperators`](DGeometryOperators.md)

#### Returns

[`DGeometryOperators`](DGeometryOperators.md)

## Methods

### angleBetween

▸ **angleBetween**(`v0`, `v1`): `number`

计算两个向量之间的夹角（双精度）

#### Parameters

| Name | Type |
| :------ | :------ |
| `v0` | `Float64Array` |
| `v1` | `Float64Array` |

#### Returns

`number`

___

### angleBetweenByNormal

▸ **angleBetweenByNormal**(`v0`, `v1`, `normal`): `number`

计算两个向量之间的有向夹角，使用法向量确定角度方向

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `v0` | `Float64Array` | 第一个向量，长度为3的Float64Array数组 [x, y, z] |
| `v1` | `Float64Array` | 第二个向量，长度为3的Float64Array数组 [x, y, z] |
| `normal` | `Float64Array` | 法向量，用于确定角度的正负方向，长度为3的Float64Array数组 [x, y, z] |

#### Returns

`number`

返回两个向量之间的有向夹角，单位为弧度，范围在[0, 2π]之间

___

### arrangePolygon

▸ **arrangePolygon**(`polygon`, `tolerance`): `Float64Array`

重构多边形

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `polygon` | `Float64Array` |  |
| `tolerance` | `number` | 容差 |

#### Returns

`Float64Array`

___

### closestPoint

▸ **closestPoint**(`p0`, `v0`, `p1`, `v1`): `any`

计算两条无穷直线之间的最近点对（双精度版本）

#### Parameters

| Name | Type |
| :------ | :------ |
| `p0` | `Float64Array` |
| `v0` | `Float64Array` |
| `p1` | `Float64Array` |
| `v1` | `Float64Array` |

#### Returns

`any`

若平行则返回 null，否则返回 { param0, param1, rp0, rp1 }

___

### createPolylinesBySegments

▸ **createPolylinesBySegments**(`points`): [`List`](List.md)\<`Float64Array`\>

通过线段数组创建多段线集合

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `points` | `ArrayLike`\<`number`\> | 线段端点数组，格式为 [x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4, ...] 每两个连续的点构成一个线段 |

#### Returns

[`List`](List.md)\<`Float64Array`\>

返回一个List，包含多个Float64Array，每个数组表示一条连续的多段线

___

### createRingPoints

▸ **createRingPoints**(`origin`, `x_axis`, `y_axis`, `paramList`, `length`): `Float64Array`

根据参数生成环形上的点集

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `origin` | `Float64Array` | 环的中心点坐标，长度为3的Float32Array数组 [x, y, z] |
| `x_axis` | `Float64Array` | X轴方向向量，长度为3的Float32Array数组，表示环的X轴方向 |
| `y_axis` | `Float64Array` | Y轴方向向量，长度为3的Float32Array数组，表示环的Y轴方向 |
| `paramList` | `Float64Array` | 参数数组，包含角度参数值（弧度制） |
| `length` | `number` | 环的半径长度 |

#### Returns

`Float64Array`

返回一个Float32Array数组，包含所有生成点的坐标，格式为 [x1, y1, z1, x2, y2, z2, ...]

___

### distance

▸ **distance**(`p1`, `p2`): `number`

计算两点之间的欧氏距离（双精度）

#### Parameters

| Name | Type |
| :------ | :------ |
| `p1` | `Float64Array` |
| `p2` | `Float64Array` |

#### Returns

`number`

___

### distancePoint

▸ **distancePoint**(`or`, `dir`, `va`): `Float64Array`

根据原点、方向向量和距离值计算新点的坐标

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `or` | `Float64Array` | 原点坐标，长度为3的Float64Array数组，表示三维空间中的起始点(x, y, z) |
| `dir` | `Float64Array` | 方向向量，长度为3的Float64Array数组，表示移动方向(x, y, z) |
| `va` | `number` | 距离值，标量数值，表示沿方向向量移动的距离 |

#### Returns

`Float64Array`

返回一个新的Float64Array数组，包含计算后的新点坐标(x, y, z)

___

### includeAngleBetween

▸ **includeAngleBetween**(`v0`, `v1`): `number`

计算两个双精度向量之间的包含角（锐角）

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `v0` | `Float64Array` | 第一个双精度向量，长度为3的Float64Array数组 [x, y, z] |
| `v1` | `Float64Array` | 第二个双精度向量，长度为3的Float64Array数组 [x, y, z] |

#### Returns

`number`

返回两个向量之间的包含角，单位为弧度，范围在[0, π/2]之间

___

### intersectionLineLine

▸ **intersectionLineLine**(`line0_p0`, `line0_p1`, `line1_p0`, `line1_p1`): `any`

计算两条直线的交点（若存在唯一交点）

#### Parameters

| Name | Type |
| :------ | :------ |
| `line0_p0` | `Float64Array` |
| `line0_p1` | `Float64Array` |
| `line1_p0` | `Float64Array` |
| `line1_p1` | `Float64Array` |

#### Returns

`any`

___

### intersectionLineLine1

▸ **intersectionLineLine1**(`line0_point`, `line0_direct`, `line1_point`, `line1_direct`): `any`

与 intersectionLineLine 相似，但使用点+方向向量表示直线

#### Parameters

| Name | Type |
| :------ | :------ |
| `line0_point` | `Float64Array` |
| `line0_direct` | `Float64Array` |
| `line1_point` | `Float64Array` |
| `line1_direct` | `Float64Array` |

#### Returns

`any`

___

### intersectionLinePlane

▸ **intersectionLinePlane**(`line_point`, `line_dir`, `plane_point`, `plane_dir`): \{ `param?`: `undefined` = inter\_param; `pos?`: `undefined` = inter\_point; `res`: `boolean` = false } \| \{ `param`: `number` = line\_param; `pos`: `Float64Array` = result; `res`: `boolean` = true }

计算三维空间中直线与平面的相交点

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `line_point` | `Float64Array` | 直线上的一个点坐标，长度为3的数组，表示直线上的参考点(x, y, z) |
| `line_dir` | `Float64Array` | 直线的方向向量，长度为3的F数组，表示直线的方向(x, y, z) |
| `plane_point` | `Float64Array` | 平面上的一个点坐标，长度为3的数组，表示平面上的参考点(x, y, z) |
| `plane_dir` | `Float64Array` | 平面的法向量，长度为3的数组，表示垂直于平面的方向向量(x, y, z) |

#### Returns

\{ `param?`: `undefined` = inter\_param; `pos?`: `undefined` = inter\_point; `res`: `boolean` = false } \| \{ `param`: `number` = line\_param; `pos`: `Float64Array` = result; `res`: `boolean` = true }

返回一个对象，包含相交结果信息
         res: 布尔值，表示是否有相交点 (true=有相交点, false=无相交点)
         param: 相交点在直线上的参数值 (仅当res为true时有效)
         pos: 相交点的坐标数组 (仅当res为true时有效)

___

### intersectionLineSegmentLineSegment

▸ **intersectionLineSegmentLineSegment**(`line0_p0`, `line0_p1`, `line1_p0`, `line1_p1`): `any`

计算两条线段是否相交，若相交返回交点位置，否则返回 null

#### Parameters

| Name | Type |
| :------ | :------ |
| `line0_p0` | `Float64Array` |
| `line0_p1` | `Float64Array` |
| `line1_p0` | `Float64Array` |
| `line1_p1` | `Float64Array` |

#### Returns

`any`

___

### intersectionLineSegmentPlane

▸ **intersectionLineSegmentPlane**(`line_start`, `line_end`, `plane_root`, `plane_normal`): \{ `param?`: `undefined` = inter\_param; `pos?`: `undefined` = inter\_point; `res`: `boolean` = false } \| \{ `param`: `any` = inter\_param; `pos`: `any` = inter\_point; `res`: `boolean` = true }

计算线段与平面的交点，返回包含是否相交与交点的对象

#### Parameters

| Name | Type |
| :------ | :------ |
| `line_start` | `Float64Array` |
| `line_end` | `Float64Array` |
| `plane_root` | `Float64Array` |
| `plane_normal` | `Float64Array` |

#### Returns

\{ `param?`: `undefined` = inter\_param; `pos?`: `undefined` = inter\_point; `res`: `boolean` = false } \| \{ `param`: `any` = inter\_param; `pos`: `any` = inter\_point; `res`: `boolean` = true }

___

### inversePolygon

▸ **inversePolygon**(`polygon`): `void`

将多边形的顶点顺序进行逆序排列

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `polygon` | `Float64Array` | 多边形顶点数组，格式为 [x1, y1, z1, x2, y2, z2, ...] 函数会直接修改原数组，无需返回值 |

#### Returns

`void`

___

### isParallel

▸ **isParallel**(`v1`, `v2`): `boolean`

判断两个向量是否平行（双精度容差）

#### Parameters

| Name | Type |
| :------ | :------ |
| `v1` | `Float64Array` |
| `v2` | `Float64Array` |

#### Returns

`boolean`

___

### isPerpendicular

▸ **isPerpendicular**(`v1`, `v2`): `boolean`

判断两个向量是否垂直（双精度容差）

#### Parameters

| Name | Type |
| :------ | :------ |
| `v1` | `Float64Array` |
| `v2` | `Float64Array` |

#### Returns

`boolean`

___

### isPointInLineSegment

▸ **isPointInLineSegment**(`point`, `line_start`, `line_end`): `boolean`

判断点是否在线段上

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `point` | `Float64Array` | 要检测的点坐标，长度为3的Float32Array数组 [x, y, z] |
| `line_start` | `Float64Array` | 线段的起始点坐标，长度为3的Float32Array数组 [x1, y1, z1] |
| `line_end` | `Float64Array` | 线段的结束点坐标，长度为3的Float32Array数组 [x2, y2, z2] |

#### Returns

`boolean`

返回布尔值，true表示点在线段上，false表示点不在线段上

___

### isPointInPolygonXy

▸ **isPointInPolygonXy**(`point`, `polygon`): `boolean`

判断点是否在多边形内部（在XY平面上进行判断）

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `point` | `Float64Array` | 要检测的点坐标，长度为3的Float32Array数组 [x, y, z] |
| `polygon` | `Float64Array` | 多边形顶点数组，格式为 [x1, y1, z1, x2, y2, z2, ...] |

#### Returns

`boolean`

返回布尔值，true表示点在多边形内部，false表示点在多边形外部

___

### isPointOnPolygonXy

▸ **isPointOnPolygonXy**(`point`, `polygon_points`, `polygon_indexes`): `boolean`

判断点是否在多边形的边界上（在XY平面上进行判断）

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `point` | `Float64Array` | 要检测的点坐标，长度为3的Float32Array数组 [x, y, z] |
| `polygon_points` | `Float64Array` | 多边形的所有顶点坐标数组，格式为 [x1, y1, z1, x2, y2, z2, ...] |
| `polygon_indexes` | `Float64Array` | 多边形索引数组，用于定义多边形的各个子多边形 每个子多边形由一个数字n和n个索引组成，n表示该子多边形的顶点数量 |

#### Returns

`boolean`

返回布尔值，true表示点在多边形边界上，false表示点不在多边形边界上

___

### lineParam

▸ **lineParam**(`point`, `origin`, `direction`): `number`

计算点相对于直线上参考点的位置参数

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `point` | `Float64Array` | 要计算参数的点坐标，长度为3的Float32Array数组 [x, y, z] |
| `origin` | `Float64Array` | 直线上的参考点坐标，长度为3的Float32Array数组 [x0, y0, z0] |
| `direction` | `Float64Array` | 直线的方向向量，长度为3的Float32Array数组 [dx, dy, dz] |

#### Returns

`number`

返回一个数值，表示点在直线上的参数值
         正值表示点在方向向量的同方向上，负值表示在反方向上

___

### lineParam1

▸ **lineParam1**(`point`, `lineStart`, `lineEnd`): `number`

计算点相对于由两个端点定义的直线上的参数值

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `point` | `Float64Array` | 要计算参数的点坐标，长度为3的Float32Array数组 [x, y, z] |
| `lineStart` | `Float64Array` | 直线的起始点坐标，长度为3的Float32Array数组 [x1, y1, z1] |
| `lineEnd` | `Float64Array` | 直线的结束点坐标，长度为3的Float32Array数组 [x2, y2, z2] |

#### Returns

`number`

返回一个数值，表示点在直线上的参数值
         正值表示点在方向向量的同方向上，负值表示在反方向上

___

### polygonNormal

▸ **polygonNormal**(`polygon`): `Float64Array`

计算多边形的法向量

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `polygon` | `Float64Array` | 多边形顶点数组，格式为 [x1, y1, z1, x2, y2, z2, ...] |

#### Returns

`Float64Array`

返回标准化后的法向量数组 [x, y, z]

___

### projectPointToLine

▸ **projectPointToLine**(`point`, `origin`, `direction`): `Float64Array`

将点投影到直线上并返回投影位置（双精度）

#### Parameters

| Name | Type |
| :------ | :------ |
| `point` | `Float64Array` |
| `origin` | `Float64Array` |
| `direction` | `Float64Array` |

#### Returns

`Float64Array`

___

### projectPointToLine1

▸ **projectPointToLine1**(`point`, `lineStart`, `lineEnd`): `Float64Array`

以线段端点表示的直线投影（双精度）

#### Parameters

| Name | Type |
| :------ | :------ |
| `point` | `Float64Array` |
| `lineStart` | `Float64Array` |
| `lineEnd` | `Float64Array` |

#### Returns

`Float64Array`

___

### projectPointToLineWithParam

▸ **projectPointToLineWithParam**(`point`, `origin`, `direction`): `Object`

将点投影到直线上并返回投影点与参数（双精度）

#### Parameters

| Name | Type |
| :------ | :------ |
| `point` | `Float64Array` |
| `origin` | `Float64Array` |
| `direction` | `Float64Array` |

#### Returns

`Object`

| Name | Type |
| :------ | :------ |
| `param` | `number` |
| `point` | `Float64Array` |

___

### projectPointToPlane

▸ **projectPointToPlane**(`point`, `root`, `normal`): `Float64Array`

将点投影到平面上并返回投影点（双精度）

#### Parameters

| Name | Type |
| :------ | :------ |
| `point` | `Float64Array` |
| `root` | `Float64Array` |
| `normal` | `Float64Array` |

#### Returns

`Float64Array`

___

### reversePoints

▸ **reversePoints**(`points`): `number`[]

计算两个双精度向量之间的包含角（锐角）

#### Parameters

| Name | Type |
| :------ | :------ |
| `points` | `ArrayLike`\<`number`\> |

#### Returns

`number`[]

返回两个向量之间的包含角，单位为弧度，范围在[0, π/2]之间

___

### samePoint

▸ **samePoint**(`p0`, `p1`): `boolean`

判断两点是否在双精度容差范围内相等

#### Parameters

| Name | Type |
| :------ | :------ |
| `p0` | `Float64Array` |
| `p1` | `Float64Array` |

#### Returns

`boolean`

___

### samePointWithTolerance

▸ **samePointWithTolerance**(`p0`, `p1`, `tolerance`): `boolean`

判断两点是否在指定容差内相等（双精度）

#### Parameters

| Name | Type |
| :------ | :------ |
| `p0` | `Float64Array` |
| `p1` | `Float64Array` |
| `tolerance` | `number` |

#### Returns

`boolean`

___

### sameVector

▸ **sameVector**(`v0`, `v1`): `boolean`

判断两向量是否在双精度法线容差范围内相等

#### Parameters

| Name | Type |
| :------ | :------ |
| `v0` | `Float64Array` |
| `v1` | `Float64Array` |

#### Returns

`boolean`
