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
|
@ -6,6 +6,8 @@ Unreleased:
|
||||||
Fixed:
|
Fixed:
|
||||||
benjamin:
|
benjamin:
|
||||||
- Fix for incorrect length of the ribbon
|
- Fix for incorrect length of the ribbon
|
||||||
|
core:
|
||||||
|
- Fix an edge case in utils.pointOnCurve for perfect horizontal curves
|
||||||
|
|
||||||
2.7.2:
|
2.7.2:
|
||||||
date: 2020-07-29
|
date: 2020-07-29
|
||||||
|
|
|
@ -89,6 +89,14 @@ export function pointOnCurve(start, cp1, cp2, end, check) {
|
||||||
p1: { x: check.x - 1, y: check.y },
|
p1: { x: check.x - 1, y: check.y },
|
||||||
p2: { 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()
|
if (intersections.length > 0) return intersections.shift()
|
||||||
else return false
|
else return false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue