🚧 Fixed an issue in Point.beamsCross
This commit is contained in:
parent
722bd36839
commit
2ba9b6dc1a
3 changed files with 9 additions and 24 deletions
|
@ -6,7 +6,7 @@ export class Part {
|
||||||
id: string;
|
id: string;
|
||||||
render: boolean;
|
render: boolean;
|
||||||
points: {
|
points: {
|
||||||
[index: string]: Point;
|
[index: string]: Point | boolean;
|
||||||
}
|
}
|
||||||
paths: { [index: string]: Path; } = {};
|
paths: { [index: string]: Path; } = {};
|
||||||
attributes = new Attributes();
|
attributes = new Attributes();
|
||||||
|
|
|
@ -41,7 +41,7 @@ export function beamsCross(a1: Point, a2: Point, b1: Point, b2: Point): Point |
|
||||||
|
|
||||||
// Find intersection
|
// Find intersection
|
||||||
let x = (iB - iA) / (slopeA - slopeB);
|
let x = (iB - iA) / (slopeA - slopeB);
|
||||||
let y = slopeA * x *iA;
|
let y = slopeA * x + iA;
|
||||||
|
|
||||||
return new Point(x, y);
|
return new Point(x, y);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,28 +31,13 @@ it('should return a line intersection', () => {
|
||||||
expect(utils.beamsCross(a,b,c,d)).to.be.false;
|
expect(utils.beamsCross(a,b,c,d)).to.be.false;
|
||||||
|
|
||||||
// Debug
|
// Debug
|
||||||
let e = new Point(0,0);
|
let e = new Point(213,222);
|
||||||
let f = new Point(25,25);
|
let f = new Point(220,214);
|
||||||
let g = new Point(0,60);
|
let g = new Point(213,44);
|
||||||
let h = new Point(25,35);
|
let h = new Point(248,222);
|
||||||
// Should be 30,30, but is 30,0
|
result = utils.beamsCross(e,f,g,h);
|
||||||
console.log(utils.beamsCross(e,f,g,h));
|
expect(result.x).to.equal(241.58);
|
||||||
//$p->newPoint(2,25,25);
|
expect(result.y).to.equal(189.34);
|
||||||
//$p->newPoint(3,0,60);
|
|
||||||
//$p->newPoint(4,25,35);
|
|
||||||
//$this->assertFalse($p->linesCross(1,2,3,4));
|
|
||||||
//$this->assertFalse($p->beamsCross(1,3,2,4));
|
|
||||||
//
|
|
||||||
//$expect = new \Freesewing\Point();
|
|
||||||
//$expect->setX(30);
|
|
||||||
//$expect->setY(30);
|
|
||||||
//$this->assertEquals($p->beamsCross(1,2,3,4), $expect);
|
|
||||||
//
|
|
||||||
//$p->newPoint(4,10,-10);
|
|
||||||
//$expect->setX(7.5);
|
|
||||||
//$expect->setY(7.5);
|
|
||||||
//$this->assertEquals($p->linesCross(1,2,3,4), $expect);
|
|
||||||
//
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a line segment intersection', () => {
|
it('should return a line segment intersection', () => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue