-
Notifications
You must be signed in to change notification settings - Fork 1
/
integrand.pde
42 lines (32 loc) · 1.23 KB
/
integrand.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
PVector lorenz_attractor(float t, PVector v) {
PVector result = new PVector();
result.x = 10.0 * (v.y - v.x);
result.y = v.x * (28.0 - v.z) - v.y;
result.z = v.x * v.y - (8.0 / 3.0) * v.z;
return result;
}
PVector wire1I = new PVector(0, 0, 40);
PVector wire1P = new PVector(-10, 0, 5);
PVector wire2I = new PVector(0, 0, 40);
PVector wire2P = new PVector(10, 0, 5);
//PVector wire2I = new PVector(0, 0, -40);
//PVector wire2P = new PVector(10, 0, 45);
PVector wire_magnetic_field(float t, PVector v) {
PVector wire1O = PVector.sub(v, wire1P);
PVector wire1B = wire1I.copy().cross(wire1O).normalize().div(min_dist(wire1P, wire1I, v));
PVector wire2O = PVector.sub(v, wire2P);
PVector wire2B = wire2I.copy().cross(wire2O).normalize().div(min_dist(wire2P, wire2I, v));
return PVector.add(wire1B, wire2B);
}
color[] wire_magnetic_field_color(PVector[] points) {
color[] result = new color[points.length];
for (int i = 0; i < points.length; i++)
result[i] = color(int(min(wire_magnetic_field(0, points[i]).mag() * 1000, 255)));
return result;
}
color[] dummy_color(PVector[] points) {
color[] result = new color[points.length];
for (int i = 0; i < points.length; i++)
result[i] = color(255);
return result;
}