-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdouble.pde
executable file
·80 lines (69 loc) · 1.67 KB
/
double.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
float ra;
float rb;
float ma;
float mb;
float alpha;
float beta;
float alpha_dot;
float beta_dot;
float alpha_ddot;
float beta_ddot;
float g;
void setup() {
size(screen.width, screen.height);
frameRate(20);
smooth();
ra = 100.0f;
rb = 100.0f;
ma = 1.0f;
mb = 0.1f;
alpha = (1.5 * PI);
beta = (1.5 * PI);
alpha_dot = 0.0f;
beta_dot = 0.0f;
alpha_ddot = 0.0f;
beta_ddot = 0.1f;
g = 0.5f;
}
void draw() {
background(0);
translate(width / 2, 200);
float xa = -ra * sin(alpha);
float ya = ra * cos(alpha);
float xb = -ra * sin(alpha) - rb * sin(beta);
float yb = ra * cos(alpha) + rb * cos(beta);
stroke(126);
fill(200);
line(0, 0, xa, ya);
stroke(126);
fill(200);
line(xa, ya, xb, yb);
ellipseMode(CENTER);
noStroke();
fill(240);
ellipse(0, 0, 8, 8);
ellipseMode(CENTER);
noStroke();
fill(200);
ellipse(xa, ya, 32, 32);
ellipseMode(CENTER);
noStroke();
fill(200);
ellipse(xb, yb, 16, 16);
alpha_ddot = ((-mb * rb * beta_ddot * cos(alpha - beta)) - (mb * rb * beta_dot * beta_dot * sin(alpha - beta)) - (g * (ma + mb) * sin(alpha))) / ((ma + mb) * ra);
beta_ddot = ((-ra * alpha_ddot * cos(alpha - beta)) + (ra * alpha_dot * alpha_dot * sin(alpha - beta)) - (g * sin(beta))) / (rb);
//alpha_ddot += 0.001f;
//beta_ddot += 0.001f;
alpha_dot += alpha_ddot;
beta_dot += beta_ddot;
alpha += alpha_dot;
beta += beta_dot;
}
void mousePressed() {
alpha = (1.5 * PI) + random(0,0.09);
beta = (1.5 * PI) + random(0,0.09);
alpha_dot = 0.0f;
beta_dot = 0.0f;
alpha_ddot = 0.0f;
beta_ddot = 0.1f;
}