-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path3Dsimulation.js
84 lines (64 loc) · 1.25 KB
/
3Dsimulation.js
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
let x = 0.01;
let y = 0;
let z = 0;
let x1 = 0.011;
let y1 = 0;
let z1 = 0;
let sigma = 10;
let rho = 28;
let beta = 8.0 / 3.0;
let points = new Array();
let points1 = new Array();
function setup() {
createCanvas(800, 600, WEBGL);
}
function draw() {
background(0);
let dt = 0.01;
let dx = sigma * (y - x) * dt;
let dy = (x * (rho - z) - y) * dt;
let dz = (x * y - beta * z) * dt;
x = x + dx;
y = y + dy;
z = z + dz;
let dx1 = sigma * (y1 - x1) * dt;
let dy1 = (x1 * (rho - z1) - y1) * dt;
let dz1 = (x1 * y1 - beta * z1) * dt;
x1 = x1 + dx1;
y1 = y1 + dy1;
z1 = z1 + dz1;
points.push(new p5.Vector(x, y, z));
points1.push(new p5.Vector(x1, y1, z1));
push();
translate(0, 0, -80);
scale(5);
stroke(255);
noFill();
beginShape();
for (let v of points) {
stroke(50, 200, 50);
vertex(v.x, v.y, v.z);
}
endShape();
stroke(10, 255, 10);
fill(10, 255, 10);
translate(x, y, z);
sphere(1);
pop();
push();
translate(0, 0, -80);
scale(5);
stroke(255);
noFill();
beginShape();
for (let v of points1) {
stroke(200, 50, 50);
vertex(v.x, v.y, v.z);
}
endShape();
stroke(255, 10, 10);
fill(255, 10, 10);
translate(x1, y1, z1);
sphere(1);
pop();
}