-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheathoundary.pde
98 lines (80 loc) · 1.69 KB
/
heathoundary.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
88
89
90
91
92
93
94
95
96
97
//Heat Differential Equations Visualization
//Currently shows thermalization of a block with originally randomly generated internal temperatures. Can be later altered to follow a given distribution.
// Ben Horowitz ([email protected])
int bh = 300; //# of boxes in height direction
int bw = 300; //# of boxes in width direction
int[][] temp = new int[bh][bw]; // updated array
int[][] temp1 = new int[bh][bw]; // old array
int mint=0;
int maxt=100;
float k = 0.5; // "heat transfer coefficient"-like thing
void setup()
{
size(600,600);
fill(255);
frameRate(80);
noStroke();
colorMode(HSB, 255);
intcond();
}
int t;
void intcond()
{
float h;
h= height/bh;
float w;
w= width/bw;
for(int i=0; i < bw; i+=1)
{
for(int j=0; j < bh; j+=1)
{
if(i==0 || i==bw-1 || j==0 || j==bh-1)
{
temp[i][j]=10;
temp1[i][j]=10;
}
else
{
temp[i][j] = int(random(256));
temp1[i][j]= temp[i][j];
}
}
}
}
void draw()
{
int[][] adjust;
float h;
h= height/bh;
float w;
w= width/bw;
t=t+1;
for(int i=0; i*w < width; i+=1)
{
for(int j=0; j*h < height; j+=1)
{
int x;
int a;
if(i==0 || i==bw-1 || j==0 || j==bh-1)
{
a=temp[i][j];
}
else
{
a= (temp1[i+1][j]+temp1[i-1][j]+temp1[i][j+1]+temp1[i][j-1])/4;
}
x = temp[i][j] - a;
temp[i][j] = int(temp[i][j] - k*x);
float value = temp[i][j];
fill(value, 255, 255);
rect(i*w,j*h,w,h);
}
}
for(int i=0; i*w < width; i+=1)
{
for(int j=0; j*h < height; j+=1)
{
temp1[i][j]=temp[i][j]; //updating array
}
}
}