-
Notifications
You must be signed in to change notification settings - Fork 0
/
APendulumSupport.pde
87 lines (76 loc) · 1.77 KB
/
APendulumSupport.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
void creatingRandomPendulums(int howManySinglePendulum)
{
float a1 = PI / (randa.nextFloat() + 0.5);
singlePend.add(new Pendulum(a1, new PVector(width / 2, height/3)));
for (int i = 1; i < howManySinglePendulum; i++)
{
a1 = PI / (randa.nextFloat() + 0.6);
singlePend.add(new Pendulum(a1, singlePend.get(i - 1).position));
}
}
void creatingRandomDoublePendulums(int howManyDoublePendulum)
{
float length1 = 350, length2 = 200, mas1 = 40, mas2 = 20, a1, a2;
for (int i = 0; i < howManyDoublePendulum; i++)
{
a1 = PI / (randa.nextFloat() + 1);
a2 = PI / (randa.nextFloat() + 3);
doublePend.add(new DoublePendulum( a1, a2, length1, length2, mas1, mas2));
}
}
void creatingRandomNPendulums()
{
for (int i = 0; i < numberOfNpendulum; i++)
{
nPend.add(new NPendulum(degreeOfPendulum));
}
}
void pendulumManagement()
{
if (pendul) {
singlePendulumManagement();
} else {
dublePendulumManagement();
}
}
void singlePendulumManagement()
{
for (int i = 0; i < singlePend.size(); i++)
{
if (singleAction)
{
singlePend.get(i).update();
}
singlePend.get(i).drawing();
}
circle(0, 0, 10);
}
void dublePendulumManagement()
{
for (int i = 0; i < doublePend.size(); i++)
{
if (doubleAction)
{
noFill();
strokeWeight(6);
doublePend.get(i).trace(i, doublePend.size());
}
doublePend.get(i).drawing();
}
//drawing center ball
fill(82, 0, 14);
stroke(153, 0, 26);
circle(0, 0, 20);
}
void nPendulManagement()
{
background(120);
for (int i= 0; i < nPend.size(); i++)
{
if (nPendulumAction)
{
nPend.get(i).trace(i, numberOfNpendulum);
}
nPend.get(i).drawing();
}
}