|  | @@ -1,4 +1,3 @@
 | 
	
		
			
				|  |  | -import { LineSegmentModel } from "../../line-segment-component/models/line-segment-model";
 | 
	
		
			
				|  |  |  import { ELEMENTS_CLASS } from "../../../core/enums/elements-class-enum";
 | 
	
		
			
				|  |  |  import { GeometricObject } from "../../../core/models/objects/geometric-object";
 | 
	
		
			
				|  |  |  import { IntersectionModel } from "../../intersection-component/models/intersection-model";
 | 
	
	
		
			
				|  | @@ -27,14 +26,10 @@ export class CircumferenceModel extends GeometricObject {
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      getStraight() {
 | 
	
		
			
				|  |  | -        const aX = this.center.posX;
 | 
	
		
			
				|  |  | -        const aY = this.center.posY;
 | 
	
		
			
				|  |  | -        const bX = this.radius.posX;
 | 
	
		
			
				|  |  | -        const bY = this.radius.posY;
 | 
	
		
			
				|  |  | -        const a = bY - aY;
 | 
	
		
			
				|  |  | -        const b = aX - bX;
 | 
	
		
			
				|  |  | -        const c = a * aX + b * aY;
 | 
	
		
			
				|  |  | -        return [a, b, c];
 | 
	
		
			
				|  |  | +        const dx = this.radius.posX - this.center.posX;
 | 
	
		
			
				|  |  | +        const dy = this.radius.posY - this.center.posY;
 | 
	
		
			
				|  |  | +        const c = Math.sqrt((dy * dy) + (dx * dx));
 | 
	
		
			
				|  |  | +        return [dx, dy, c];
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      getDirection() {
 | 
	
	
		
			
				|  | @@ -57,31 +52,69 @@ export class CircumferenceModel extends GeometricObject {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      getIntersectionByCircumference(circumference) {
 | 
	
		
			
				|  |  | -        const rM = new LineSegmentModel(this.center, this.radius);
 | 
	
		
			
				|  |  | -        const sM = new LineSegmentModel(circumference.center, circumference.radius);
 | 
	
		
			
				|  |  | -        const r = rM.getStraight();
 | 
	
		
			
				|  |  | -        const s = sM.getStraight();
 | 
	
		
			
				|  |  | -        const a1 = r[0];
 | 
	
		
			
				|  |  | -        const b1 = r[1];
 | 
	
		
			
				|  |  | -        const c1 = r[2];
 | 
	
		
			
				|  |  | -        const a2 = s[0];
 | 
	
		
			
				|  |  | -        const b2 = s[1];
 | 
	
		
			
				|  |  | -        const c2 = s[2];
 | 
	
		
			
				|  |  | -        const determinant = a1 * b2 - a2 * b1;
 | 
	
		
			
				|  |  | -        if (determinant == 0) {
 | 
	
		
			
				|  |  | -            return new IntersectionModel(
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        const c0 = this.getStraight();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (c0[2] > (this.radius + circumference.radius)) {
 | 
	
		
			
				|  |  | +            return [new IntersectionModel(
 | 
	
		
			
				|  |  |                  Number.MAX_SAFE_INTEGER,
 | 
	
		
			
				|  |  |                  Number.MAX_SAFE_INTEGER,
 | 
	
		
			
				|  |  |                  undefined,
 | 
	
		
			
				|  |  |                  this,
 | 
	
		
			
				|  |  | -                circumference
 | 
	
		
			
				|  |  | -            );
 | 
	
		
			
				|  |  | -        } else {
 | 
	
		
			
				|  |  | -            const x = (b2 * c1 - b1 * c2) / determinant;
 | 
	
		
			
				|  |  | -            const y = (a1 * c2 - a2 * c1) / determinant;
 | 
	
		
			
				|  |  | -            return new IntersectionModel(x, y, undefined, this, circumference);
 | 
	
		
			
				|  |  | +                circumference,
 | 
	
		
			
				|  |  | +                false
 | 
	
		
			
				|  |  | +            ), new IntersectionModel(
 | 
	
		
			
				|  |  | +                Number.MAX_SAFE_INTEGER,
 | 
	
		
			
				|  |  | +                Number.MAX_SAFE_INTEGER,
 | 
	
		
			
				|  |  | +                undefined,
 | 
	
		
			
				|  |  | +                this,
 | 
	
		
			
				|  |  | +                circumference,
 | 
	
		
			
				|  |  | +                false
 | 
	
		
			
				|  |  | +            )];
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (c0[2] < this.radius + circumference.radius) {
 | 
	
		
			
				|  |  | +            return [new IntersectionModel(
 | 
	
		
			
				|  |  | +                Number.MAX_SAFE_INTEGER,
 | 
	
		
			
				|  |  | +                Number.MAX_SAFE_INTEGER,
 | 
	
		
			
				|  |  | +                undefined,
 | 
	
		
			
				|  |  | +                this,
 | 
	
		
			
				|  |  | +                circumference,
 | 
	
		
			
				|  |  | +                false
 | 
	
		
			
				|  |  | +            ), new IntersectionModel(
 | 
	
		
			
				|  |  | +                Number.MAX_SAFE_INTEGER,
 | 
	
		
			
				|  |  | +                Number.MAX_SAFE_INTEGER,
 | 
	
		
			
				|  |  | +                undefined,
 | 
	
		
			
				|  |  | +                this,
 | 
	
		
			
				|  |  | +                circumference,
 | 
	
		
			
				|  |  | +                false
 | 
	
		
			
				|  |  | +            )];
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        return
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        const distance = ((this.radius * this.radius) - (circumference.radius * circumference.radius) + (c0[2] * c0[2])) / (2.0 * c0[2]);
 | 
	
		
			
				|  |  | +        const aX = this.center.posX + (c0[0] * distance / c0[2]);
 | 
	
		
			
				|  |  | +        const aY = this.center.posY + (c0[1] * distance / c0[2]);
 | 
	
		
			
				|  |  | +        const distance2 = Math.sqrt((this.radius * this.radius) - (distance * distance));
 | 
	
		
			
				|  |  | +        const bX = -c0[0] * (distance2 / c0[2]);
 | 
	
		
			
				|  |  | +        const bY = c0[1] * (distance2 / c0[2]);
 | 
	
		
			
				|  |  | +        const intersectionAX = aX + bX;
 | 
	
		
			
				|  |  | +        const intersectionBX = aX - bX;
 | 
	
		
			
				|  |  | +        const intersectionAY = aY + bY;
 | 
	
		
			
				|  |  | +        const intersectionBY = aY - bY;
 | 
	
		
			
				|  |  | +        return [new IntersectionModel(
 | 
	
		
			
				|  |  | +            intersectionAX,
 | 
	
		
			
				|  |  | +            intersectionAY,
 | 
	
		
			
				|  |  | +            undefined,
 | 
	
		
			
				|  |  | +            this,
 | 
	
		
			
				|  |  | +            circumference,
 | 
	
		
			
				|  |  | +            false
 | 
	
		
			
				|  |  | +        ), new IntersectionModel(
 | 
	
		
			
				|  |  | +            intersectionBX,
 | 
	
		
			
				|  |  | +            intersectionBY,
 | 
	
		
			
				|  |  | +            undefined,
 | 
	
		
			
				|  |  | +            this,
 | 
	
		
			
				|  |  | +            circumference,
 | 
	
		
			
				|  |  | +            false
 | 
	
		
			
				|  |  | +        )];
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 |