fix(core): Fixed edge-case in utils.pointOnCurve
If we were trying to find a point that lied on a part of a curve that was a perfect horizontal line, no intersection would be found. This fixes that. - Fixes https://github.com/freesewing/freesewing.org/issues/898 - Fixes https://github.com/freesewing/freesewing.org/issues/899 - Fixes https://github.com/freesewing/freesewing.org/issues/913
This commit is contained in:
parent
f45b6665b1
commit
75afc2d9c3
2 changed files with 10 additions and 0 deletions
|
@ -89,6 +89,14 @@ export function pointOnCurve(start, cp1, cp2, end, check) {
|
|||
p1: { x: check.x - 1, y: check.y },
|
||||
p2: { x: check.x + 1, y: check.y }
|
||||
})
|
||||
if (intersections.length === 0) {
|
||||
// Handle edge case of a curve that's a perfect horizontal line
|
||||
intersections = curve.intersects({
|
||||
p1: { x: check.x, y: check.y - 1 },
|
||||
p2: { x: check.x, y: check.y + 1 }
|
||||
})
|
||||
}
|
||||
|
||||
if (intersections.length > 0) return intersections.shift()
|
||||
else return false
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue