Commit cef68d97 authored by Christian Winter's avatar Christian Winter

some methods changed to private

parent 71af8460
......@@ -76,11 +76,11 @@ Utilities = new class {
cutLines(cutter, lines, useDrawnLineAsRealLine) {
let intersections = [];
intersections.push(cutter.start);
this.addPointSorted(intersections, cutter.end);
this._addPointSorted(intersections, cutter.end);
let n = lines.length;
for (let i = n - 1; i >= 0; i--) {
let points = this.intersect(cutter, lines[i]);
let points = this._intersect(cutter, lines[i]);
if (points.length == 1) {
if (!points[0].position.equals(lines[i].end.position) && !points[0].position.equals(lines[i].start.position)) {
lines.push(new Line(points[0].position.copy(), lines[i].end.position.copy(), lines[i].color, lines[i].thickness));
......@@ -91,7 +91,7 @@ Utilities = new class {
lines.splice(i, 1);
for (let point of points)
this.addPointSorted(intersections, point);
this._addPointSorted(intersections, point);
}
let origPts = 0;
......@@ -105,8 +105,7 @@ Utilities = new class {
}
}
// TODO make private or extract into own class
addPointSorted(points, point) {
_addPointSorted(points, point) {
for (let i = 0; i < points.length; i++) {
if (this.eq(point.position.y, points[i].position.y) && this.eq(point.position.x, points[i].position.x)) {
if (points[i].line == null)
......@@ -121,9 +120,9 @@ Utilities = new class {
}
points.push(point);
}
// TODO make private or extract into own class
// or make part of line class?
intersect(line1, line2) {
// TODO make part of line class?
_intersect(line1, line2) {
let points = [];
let v1 = line1.end.position.subtractVector(line1.start.position);
let v2 = line2.end.position.subtractVector(line2.start.position);
......@@ -143,9 +142,9 @@ Utilities = new class {
Math.abs(maxY - minY) <= Math.abs(v1.y) + Math.abs(v2.y)) {
points.push(line1.start);
this.addPointSorted(points, line1.end);
this.addPointSorted(points, line2.start);
this.addPointSorted(points, line2.end);
this._addPointSorted(points, line1.end);
this._addPointSorted(points, line2.start);
this._addPointSorted(points, line2.end);
}
return points;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment