Skip to content

Commit 7de17a0

Browse files
committed
added comments
1 parent 28952b0 commit 7de17a0

File tree

2 files changed

+21
-25
lines changed

2 files changed

+21
-25
lines changed

heathoundary.pde

+18-23
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
// Ben Horowitz ([email protected])
55

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;
1111
int maxt=100;
12-
float k = 0.5;
12+
float k = 0.5; // "heat transfer coefficient"-like thing
1313

1414

1515

@@ -30,29 +30,24 @@ int t;
3030

3131
void intcond()
3232
{
33-
34-
3533
float h;
3634
h= height/bh;
3735
float w;
3836
w= width/bw;
39-
4037
for(int i=0; i < bw; i+=1)
4138
{
4239
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+
}
5651
}
5752
}
5853
}
@@ -96,7 +91,7 @@ void draw()
9691
{
9792
for(int j=0; j*h < height; j+=1)
9893
{
99-
temp1[i][j]=temp[i][j];
94+
temp1[i][j]=temp[i][j]; //updating array
10095
}
10196
}
10297
}

nbody.pde

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
int bh = 100;
66
int bw = 100;
77
int n = 60;
8-
float a = 0.0000000002*10;
8+
float a = 0.0000000002*10; //transfer coefficient
99
float[] pos_x = new float[n];
1010
float[] pos_y = new float[n];
1111
float[] vel_x = new float[n];
1212
float[] vel_y = new float[n];
1313
float[] mass = new float[n];
14-
float k = 0.5;
14+
float k = 0.5; //collision radius
1515

1616

1717

@@ -71,6 +71,7 @@ void draw()
7171
pos_y[i] = pos_y[i] + vel_y[i]/20;
7272
vel_x[i] = vel_x[i] + dv_x;
7373
vel_y[i] = vel_y[i] + dv_y;
74+
\\collisions
7475
if(pos_x[i]-pos_x[j] < mass[i]/2 & pos_x[i]-pos_x[j]>0){
7576
if(pos_y[i]-pos_y[j] < mass[i]/2 & pos_y[i]-pos_y[j]>0){
7677
mass[i]=mass[i]+mass[j];

0 commit comments

Comments
 (0)