|
@@ -96,6 +96,19 @@ export class LineSegmentModel extends GeometricObject {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //DEBUG print coordinates of point
|
|
|
+ pp (point) {
|
|
|
+ var px="",py="";
|
|
|
+ try { //D //leo
|
|
|
+ px=""+point.id+":"+point.posX; py=""+point.posY; var aux1="", aux2="";
|
|
|
+ var items = px.split("."); if (items && items.length>1) aux1 = "." + items[1].substr(0,3); px = items[0] + aux1; // pegar apenas 3 digitos
|
|
|
+ var items = py.split("."); if (items && items.length>1) aux2 = "." + items[1].substr(0,3); py = items[0] + aux2; // pegar apenas 3 digitos
|
|
|
+ } catch (e) {
|
|
|
+ console.log("line-segment-model.js!pp(.): erro! " + e); }
|
|
|
+ return "(" + px + "," + py + ")";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
// Intersection with circunference
|
|
|
// @calledby line-model.js!getIntersectionWithCircumference(circ): return super.getIntersectionWithCircumference(circ);
|
|
|
getIntersectionWithCircumference (circumference) { //TODO Nome? Melhor 'getIntersectionWithCircumference'
|
|
@@ -112,7 +125,7 @@ export class LineSegmentModel extends GeometricObject {
|
|
|
}
|
|
|
else
|
|
|
if (pointB.id==radiusP.id) {
|
|
|
- console.log("*** line-segment-model.js!getIntersectionWithCircumference(.): pointA already in intersection!" + aux);
|
|
|
+ console.log("*** line-segment-model.js!getIntersectionWithCircumference(.): pointB already in intersection!" + aux);
|
|
|
existB = 1; //pointB.og1 = this; pointB.og2 = circumference;
|
|
|
}
|
|
|
//D else console.log("xxx line-segment-model.js!getIntersectionWithCircumference(.): pointA or PointB NOT in intersection!" + aux);
|
|
@@ -131,13 +144,18 @@ export class LineSegmentModel extends GeometricObject {
|
|
|
const delta = D * D - q;
|
|
|
|
|
|
var PA, PB;
|
|
|
+ try {
|
|
|
if (existA==-1) PA = new IntersectionModel(Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, undefined, this, circumference, false, 0);
|
|
|
else PA = pointA; // intersection already exist (with point A)
|
|
|
if (existB==-1) PB = new IntersectionModel(Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, undefined, this, circumference, false, 1);
|
|
|
- else PA = pointB; // intersection already exist (with point B)
|
|
|
+ else PB = pointB; // intersection already exist (with point B)
|
|
|
+ } catch (ex) { console.log("*** line-segment-model.js!getIntersectionWithCircumference(.): ERRO 1!"); console.trace(); }
|
|
|
|
|
|
if (delta < 0) { //TODO Verificar? No intersection points
|
|
|
//D console.log("line-segment-model.js: getIntersectionWithCircumference(.): delta<0: " + Number.MAX_SAFE_INTEGER);
|
|
|
+ // app/components/middle-point/drawers/middle-point-drawer.js : pp(point) - funcao para depuracao, imprimir coordenadas do ponto
|
|
|
+ //D console.log("*** line-segment-model.js!getIntersectionWithCircumference(.): delta<0, ponto A: [" + PA.id + " : " + this.pp(PA) + "]");
|
|
|
+ //D console.log("*** line-segment-model.js!getIntersectionWithCircumference(.): delta<0, ponto B: [" + (PB==undefined?"-1":PB.id) + " : " + this.pp(PB) + "]");
|
|
|
return [PA, PB];
|
|
|
}
|
|
|
|
|
@@ -147,22 +165,32 @@ export class LineSegmentModel extends GeometricObject {
|
|
|
const x1 = pointA.posX - dx * root1
|
|
|
const y1 = pointA.posY - dy * root1;
|
|
|
|
|
|
+ try {
|
|
|
if (delta == 0) { //TODO Verificar? Only one point (actually, both with the same coordinates)
|
|
|
//D console.log("line-segment-model.js: getIntersectionWithCircumference(.): delta==0");
|
|
|
if (existA==-1)
|
|
|
PA.bind(x1, y1, undefined, this, circumference, true, 0);
|
|
|
+ // app/components/middle-point/drawers/middle-point-drawer.js : pp(point) - funcao para depuracao, imprimir coordenadas do ponto
|
|
|
+ //D console.log("*** line-segment-model.js!getIntersectionWithCircumference(.): delta==0, ponto A: [" + PA.id + " : " + this.pp(PA) + "]");
|
|
|
+ //D console.log("*** line-segment-model.js!getIntersectionWithCircumference(.): delta==0, ponto B: [" + PB.id + " : " + this.pp(PB) + "]");
|
|
|
return [PA, PB];
|
|
|
}
|
|
|
+ } catch (ex) { console.log("*** line-segment-model.js!getIntersectionWithCircumference(.): ERRO 2!"); console.trace(); }
|
|
|
|
|
|
const x2 = pointA.posX - dx * root2;
|
|
|
const y2 = pointA.posY - dy * root2;
|
|
|
|
|
|
+ try {
|
|
|
if (existA==-1) PA.bind(x1, y1, undefined, this, circumference, true, 0);
|
|
|
if (existB==-1) PB.bind(x2, y2, undefined, this, circumference, true, 1);
|
|
|
-
|
|
|
if (!this.insideSegment(PB.posX, PB.posY)) {
|
|
|
if (existB==-1) PB.bind(Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, undefined, this, circumference, false, 1);
|
|
|
}
|
|
|
+ } catch (ex) { console.log("*** line-segment-model.js!getIntersectionWithCircumference(.): ERRO 2!"); console.trace(); }
|
|
|
+
|
|
|
+ // app/components/middle-point/drawers/middle-point-drawer.js : pp(point) - funcao para depuracao, imprimir coordenadas do ponto
|
|
|
+ //D console.log("*** line-segment-model.js!getIntersectionWithCircumference(.): final, ponto A: [" + PA.id + " : " + this.pp(PA) + "]");
|
|
|
+ //D console.log("*** line-segment-model.js!getIntersectionWithCircumference(.): final, ponto B: [" + PB.id + " : " + this.pp(PB) + "]");
|
|
|
|
|
|
return [PA, PB];
|
|
|
} // getIntersectionWithCircumference(circumference)
|