Fix and improve path intersection methods
- Add path.intersectsBeam() method - Add utils.beamIntersectsLine() method - Simplify calculation and improve precision on beam intersections - Document return types properly - beamIntersectsCurve now uses the proper function from Bezier library instead of emulating it by constructing a huge line - docs: path.intersect... methods never return false, they simply return an empty array in case of no intersection
This commit is contained in:
parent
adf83eda8c
commit
4b83212f41
10 changed files with 262 additions and 39 deletions
|
@ -48,6 +48,24 @@ describe('Utils', () => {
|
|||
expect(linesIntersect(a, b, c, d)).to.equal(false)
|
||||
})
|
||||
|
||||
it('Should detect parallel vertical lines', () => {
|
||||
let a = new Point(10, 20.234)
|
||||
let b = new Point(10, 20)
|
||||
let c = new Point(90, 40)
|
||||
let d = new Point(90, 45.123)
|
||||
expect(beamsIntersect(a, b, c, d)).to.equal(false)
|
||||
expect(linesIntersect(a, b, c, d)).to.equal(false)
|
||||
})
|
||||
|
||||
it('Should detect almost parallel vertical lines', () => {
|
||||
let a = new Point(10, 20.234)
|
||||
let b = new Point(10, 20)
|
||||
let c = new Point(360, 40)
|
||||
let d = new Point(360.00000000000006, 45.123)
|
||||
expect(beamsIntersect(a, b, c, d)).to.equal(false)
|
||||
expect(linesIntersect(a, b, c, d)).to.equal(false)
|
||||
})
|
||||
|
||||
it('Should detect vertical lines', () => {
|
||||
let a = new Point(10, 20)
|
||||
let b = new Point(10, 90)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue