-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrossler.js
41 lines (38 loc) · 879 Bytes
/
rossler.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
class Rossler {
constructor() {
this.name = 'Rossler';
this.iterations = 10000;
this.multiplier = 3.0;
this.type = 'line';
this.reset();
}
reset(random = false) {
if (random === false) {
this.x = 0.0;
this.y = 0.0;
this.z = 0.0;
this.a = 0.2;
this.b = 0.2;
this.c = 14;
} else {
this.x = 0.0;
this.y = 0.0;
this.z = 0.0;
this.a = 0.1 + 0.1 * Math.random();
this.b = 0.1 + 0.2 * Math.random();
this.c = 10 + 6 * Math.random();
}
}
getPosition() {
return { x: this.x, y: this.y, z: this.z };
}
next() {
const t = 0.02;
const xt = t * (-this.y - this.z);
const yt = t * (this.x + this.a * this.y);
const zt = t * (this.b + this.z * (this.x - this.c));
this.x = this.x + xt;
this.y = this.y + yt;
this.z = this.z + zt;
}
}