-
Notifications
You must be signed in to change notification settings - Fork 0
/
Line.pde
106 lines (95 loc) · 1.87 KB
/
Line.pde
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
public class Line
{
float x1, x2, y1, y2;
boolean isHorizental = false;
boolean isVertical = false;
public Line(float x11, float y11, float x22, float y22)
{
x1=x11;
y1=y11;
x2=x22;
y2=y22;
if (x1 == x2)
{
isVertical = true;
}
if (y1 == y2)
{
isHorizental = true;
}
}
public void display()
{
stroke(#FF0000);
strokeWeight(2);
line(x1+OFFSETX,y1+OFFSETY,x2+OFFSETX,y2+OFFSETY);
stroke(#000000);
}
public void display(int color2)
{
stroke(color2);
strokeWeight(2);
line(x1+OFFSETX,y1+OFFSETY,x2+OFFSETX,y2+OFFSETY);
stroke(#000000);
}
public void displayLaser(String team)
{
strokeWeight(2);
if (team == "Red")
{
stroke(#FF0000);
}
else if (team == "Green")
{
stroke(#00FF00);
}
else if (team == "Orange")
{
stroke(#ED8A05);
}
else
{
stroke(#0000FF);
}
line(x1+OFFSETX,y1+OFFSETY,x2+OFFSETX,y2+OFFSETY);
stroke(#000000);
}
public float midX()
{
return (x1+x2)/2;
}
public float midY()
{
return (y1+y2)/2;
}
public void display2()
{
line(x1+OFFSETX,y1+OFFSETY,x2+OFFSETX,y2+OFFSETY);
}
public float lerpY(float t)
{
return (1-t)*y1 + t*y2;
}
public float lerpX(float t)
{
return (1-t)*x1 + t*x2;
}
public float slope()
{
return (y2-y1)/(x2-x1);
}
public float radAngle()
{
float rad_angle = atan2((y2-y1), (x2-x1));
rad_angle += PI;
return rad_angle;
}
public boolean equals(Line otherLine)
{
if (otherLine.x1 == this.x1 && otherLine.x2 == this.x2 && otherLine.y1 == this.y1 && otherLine.y2 == this.y2)
{
return true;
}
return false;
}
}