-
Notifications
You must be signed in to change notification settings - Fork 0
/
emittingLine.java
39 lines (33 loc) · 1.02 KB
/
emittingLine.java
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
import static processing.core.PApplet.cos;
import static processing.core.PApplet.sin;
public class emittingLine {
float rx, ry, x1, y1, x2, y2;
float radius = 0;
float lineLength;
float theta;
float radspeed;
float thetaspeed;
public emittingLine(float rx, float ry, float lineLength, float theta, float radspeed, float thetaspeed) {
this.rx = rx;
this.ry = ry;
this.lineLength = lineLength;
this.theta = theta;
this.radspeed = radspeed;
this.thetaspeed = thetaspeed;
}
public void updateLine() {
radius += radspeed;
theta += thetaspeed;
if (radius < lineLength) {
x1 = rx;
y1 = rx;
x2 = rx + radius * cos(theta);
y2 = ry + radius * sin(theta);
} else {
x1 = rx + (radius - lineLength) * cos(theta);
y1 = ry + (radius - lineLength) * sin(theta);
x2 = rx + radius * cos(theta);
y2 = ry + radius * sin(theta);
}
}
}