File tree 2 files changed +21
-25
lines changed
2 files changed +21
-25
lines changed Original file line number Diff line number Diff line change 3
3
4
4
// Ben Horowitz ([email protected] )
5
5
6
- int bh = 300 ;
7
- int bw = 300 ;
8
- int [][] temp = new int [bh][bw];
9
- int [][] temp1 = new int [bh][bw];
10
- int mint= 0 ;
6
+ int bh = 300 ; // # of boxes in height direction
7
+ int bw = 300 ; // # of boxes in width direction
8
+ int [][] temp = new int [bh][bw]; // updated array
9
+ int [][] temp1 = new int [bh][bw]; // old array
10
+ int mint= 0 ;
11
11
int maxt= 100 ;
12
- float k = 0.5 ;
12
+ float k = 0.5 ; // "heat transfer coefficient"-like thing
13
13
14
14
15
15
@@ -30,29 +30,24 @@ int t;
30
30
31
31
void intcond()
32
32
{
33
-
34
-
35
33
float h;
36
34
h= height / bh;
37
35
float w;
38
36
w= width / bw;
39
-
40
37
for (int i= 0 ; i < bw; i+= 1 )
41
38
{
42
39
for (int j= 0 ; j < bh; j+= 1 )
43
- {
44
-
45
-
46
- if (i== 0 || i== bw- 1 || j== 0 || j== bh- 1 )
47
- {
48
- temp[i][j]= 10 ;
49
- temp1[i][j]= 10 ;
50
- }
51
- else
52
- {
53
- temp[i][j] = int (random (256 ));
54
- temp1[i][j]= temp[i][j];
55
- }
40
+ {
41
+ if (i== 0 || i== bw- 1 || j== 0 || j== bh- 1 )
42
+ {
43
+ temp[i][j]= 10 ;
44
+ temp1[i][j]= 10 ;
45
+ }
46
+ else
47
+ {
48
+ temp[i][j] = int (random (256 ));
49
+ temp1[i][j]= temp[i][j];
50
+ }
56
51
}
57
52
}
58
53
}
@@ -96,7 +91,7 @@ void draw()
96
91
{
97
92
for (int j= 0 ; j* h < height ; j+= 1 )
98
93
{
99
- temp1[i][j]= temp[i][j];
94
+ temp1[i][j]= temp[i][j]; // updating array
100
95
}
101
96
}
102
97
}
Original file line number Diff line number Diff line change 5
5
int bh = 100 ;
6
6
int bw = 100 ;
7
7
int n = 60 ;
8
- float a = 0.0000000002 * 10 ;
8
+ float a = 0.0000000002 * 10 ; // transfer coefficient
9
9
float [] pos_x = new float [n];
10
10
float [] pos_y = new float [n];
11
11
float [] vel_x = new float [n];
12
12
float [] vel_y = new float [n];
13
13
float [] mass = new float [n];
14
- float k = 0.5 ;
14
+ float k = 0.5 ; // collision radius
15
15
16
16
17
17
@@ -71,6 +71,7 @@ void draw()
71
71
pos_y[i] = pos_y[i] + vel_y[i]/ 20 ;
72
72
vel_x[i] = vel_x[i] + dv_x;
73
73
vel_y[i] = vel_y[i] + dv_y;
74
+ \\collisions
74
75
if (pos_x[i]- pos_x[j] < mass[i]/ 2 & pos_x[i]- pos_x[j]> 0 ){
75
76
if (pos_y[i]- pos_y[j] < mass[i]/ 2 & pos_y[i]- pos_y[j]> 0 ){
76
77
mass[i]= mass[i]+ mass[j];
You can’t perform that action at this time.
0 commit comments