-
Notifications
You must be signed in to change notification settings - Fork 0
/
polygonLine.js
57 lines (48 loc) · 1.17 KB
/
polygonLine.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
class PolygonLine {
constructor(x1, y1, x2, y2, polygon) {
this.startX = x1;
this.startY = y1;
this.endX = x2;
this.endY = y2;
if (y2 < y1) {
this.topx = x2;
this.bottomx = x1;
} else {
this.topx = x1;
this.bottomx = x2;
}
this.projection = new Interval(this.startY, this.endY, this);
this.projection.setProjection(polygon.getOrijentation());
this.active = false;
this.procesed = false;
}
getXForY(y) {
if (Math.abs(this.startX - this.endX) < Number.EPSILON) {
return this.startX;
}
var k = (this.endY - this.startY) / (this.endX - this.startX);
var n = this.startY - k * this.startX;
return (y - n) / k;
}
isActive() {
return this.active;
}
setActive(bool) {
this.active = bool;
}
setProcesed(bool) {
this.procesed = bool;
}
isProcesed() {
return this.procesed;
}
getTopx() {
return this.topx;
}
getBottomx() {
return this.bottomx;
}
getProjection() {
return this.projection;
}
}