Appearance
@jtopo/core / Point
Class: Point
只是提供了一些操作点和点集合的静态方法
Table of contents
Constructors
Properties
Methods
Constructors
constructor
new Point()
Properties
PointClosestEpsilon
Static PointClosestEpsilon: number
Methods
distance
Static distance(x, y, x2, y2): number
计算两点之间的距离
Parameters
| Name | Type |
|---|---|
x | number |
y | number |
x2 | number |
y2 | number |
Returns
number
getAngle
Static getAngle(x, y, x2, y2): number
Parameters
| Name | Type |
|---|---|
x | number |
y | number |
x2 | number |
y2 | number |
Returns
number
isLikePoint
Static isLikePoint(object): boolean
Parameters
| Name | Type |
|---|---|
object | any |
Returns
boolean
lerp
Static lerp(a, b, t): PointLike
根据给定的比例t,计算出线段上一点
Parameters
| Name | Type | Description |
|---|---|---|
a | PointLike | 第一个点的坐标 |
b | PointLike | 第二个点的坐标 |
t | number | 比例值,公式:(1-t) * a + t*b |
Returns
- 插值点的坐标
lerpOnLines
Static lerpOnLines(points, t, isClosed): PointLike
计算多点线上某一点的坐标
Parameters
| Name | Type | Description |
|---|---|---|
points | PointLike[] | 多点坐标数组 |
t | number | 线上某点的相对位置 [0-1] |
isClosed | boolean | - |
Returns
线上某点的坐标
looksSame
Static looksSame(p1, p2, e): boolean
Parameters
| Name | Type |
|---|---|
p1 | PointLike |
p2 | PointLike |
e | number |
Returns
boolean
mergeClosestPoints
Static mergeClosestPoints(points, epsilon?): PointLike[]
将一系列的点合并成更少的点,使得相邻的点在某方向上变化不大时仅保留一个点,以减少最终结果中点的数量。
Parameters
| Name | Type | Description |
|---|---|---|
points | PointLike[] | |
epsilon? | number | 参数是判断两个方向是否相近的阈值。 |
Returns
middle
Static middle(p1, p2): Object
Parameters
| Name | Type |
|---|---|
p1 | PointLike |
p2 | PointLike |
Returns
Object
| Name | Type |
|---|---|
x | number |
y | number |
rotate
Static rotate(x, y, cx, cy, angle): PointLike
点(x,y) 绕点 (cx,cy) 旋转angle后的坐标
Parameters
| Name | Type |
|---|---|
x | number |
y | number |
cx | number |
cy | number |
angle | number |