Skip to content

Commit 02911c6

Browse files
Yuan-ZWDymoneLewis
authored andcommitted
fix(core): 修复因算法错误导致 polyline 与多边形节点的交点不正确的问题
1 parent c61f5b1 commit 02911c6

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

packages/core/__tests__/algorithm/egde.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ describe('algorithm/edge', () => {
105105
y: -10,
106106
},
107107
]
108-
expect(isInSegment(point, line1[0], line2[1])).toBeTruthy()
109-
expect(isInSegment(point, line1[1], line2[0])).toBeTruthy()
110-
expect(isInSegment(point, line2[0], line1[1])).toBeTruthy()
111-
expect(isInSegment(point, line2[1], line1[0])).toBeTruthy()
108+
expect(isInSegment(point, line1[0], line1[1])).toBeTruthy()
109+
expect(isInSegment(point, line1[1], line1[0])).toBeTruthy()
110+
expect(isInSegment(point, line2[0], line2[1])).toBeTruthy()
111+
expect(isInSegment(point, line2[1], line2[0])).toBeTruthy()
112112
})
113113
// not in segment
114114
test('not in segment', () => {

packages/core/src/algorithm/edge.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@ export const isInSegment = (point: Point, start: Point, end: Point) => {
6262
return (
6363
((x >= startX && x <= endX) || (x <= startX && x >= endX)) &&
6464
((y >= startY && y <= endY) || (y <= startY && y >= endY)) &&
65-
Math.abs(y - k * x + b) < Number.EPSILON
65+
Math.abs(y - k * x - b) < Number.EPSILON
6666
)
6767
}

0 commit comments

Comments
 (0)