|
@@ -40,7 +40,16 @@ export class LineSegmentModel extends GeometricObject {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ getDeterminantByLine(lineSegment) {
|
|
|
+ const r = this.getStraight();
|
|
|
+ const s = lineSegment.getStraight();
|
|
|
+ const a1 = r[0];
|
|
|
+ const b1 = r[1];
|
|
|
+ const a2 = s[0];
|
|
|
+ const b2 = s[1];
|
|
|
+ const determinant = a1 * b2 - a2 * b1;
|
|
|
+ return determinant;
|
|
|
+ }
|
|
|
getIntersectionByLine(lineSegment) {
|
|
|
const r = this.getStraight();
|
|
|
const s = lineSegment.getStraight();
|
|
@@ -89,10 +98,14 @@ export class LineSegmentModel extends GeometricObject {
|
|
|
const q = c / a;
|
|
|
|
|
|
const delta = D * D - q;
|
|
|
+
|
|
|
+ const PA = new IntersectionModel(Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, undefined, this, circumference, false, 0);
|
|
|
+ const PB = new IntersectionModel(Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, undefined, this, circumference, false, 1);
|
|
|
+
|
|
|
if (delta < 0) {
|
|
|
return [
|
|
|
- new IntersectionModel(Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, undefined, this, circumference, false, 0),
|
|
|
- new IntersectionModel(Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, undefined, this, circumference, false, 1)
|
|
|
+ PA,
|
|
|
+ PB
|
|
|
];
|
|
|
}
|
|
|
|
|
@@ -103,17 +116,30 @@ export class LineSegmentModel extends GeometricObject {
|
|
|
const y1 = pointA.posY - dy * root1;
|
|
|
|
|
|
if (delta == 0) {
|
|
|
+ PA.bind(x1, y1, undefined, this, circumference, true, 0);
|
|
|
return [
|
|
|
- new IntersectionModel(x1, y1, undefined, this, circumference, true, 0),
|
|
|
- new IntersectionModel(Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, undefined, this, circumference, false, 1)
|
|
|
+ PA,
|
|
|
+ PB
|
|
|
];
|
|
|
}
|
|
|
+
|
|
|
const x2 = pointA.posX - dx * root2;
|
|
|
const y2 = pointA.posY - dy * root2;
|
|
|
|
|
|
+ PA.bind(x1, y1, undefined, this, circumference, true, 0);
|
|
|
+ PB.bind(x2, y2, undefined, this, circumference, true, 1);
|
|
|
+
|
|
|
+ if (this.visible) {
|
|
|
+ if (!this.insideSegment(PA.posX, PA.posY))
|
|
|
+ PA.bind(Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, undefined, this, circumference, false, 0)
|
|
|
+
|
|
|
+ if (!this.insideSegment(PB.posX, PB.posY))
|
|
|
+ PB.bind(Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, undefined, this, circumference, false, 1)
|
|
|
+ }
|
|
|
+
|
|
|
return [
|
|
|
- new IntersectionModel(x1, y1, undefined, this, circumference, true, 0),
|
|
|
- new IntersectionModel(x2, y2, undefined, this, circumference, true, 1)
|
|
|
+ PA,
|
|
|
+ PB
|
|
|
];
|
|
|
|
|
|
}
|