-
Notifications
You must be signed in to change notification settings - Fork 4
/
Attractors.js
400 lines (318 loc) · 10.3 KB
/
Attractors.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
// Created by Mikael Hvidtfeldt Christensen, (Twitter: @SyntopiaDK, web: hvidtfeldts.net).
/*
MIT License
Copyright (c) 2018 Mikael Hvidtfeldt Christensen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
// ----------------------------------------------------------------------------
/*
Formulas found in:
http://www.algosome.com/articles/aizawa-attractor-chaos.html
https://www.behance.net/gallery/7618879/Strange-Attractors
*/
// ---------------------------------- Aizawa ----------------------------------
function Aizawa() {
this.a = 0.95;
this.b = 0.7;
this.e = 0.25;
this.c = 0.6;
this.d = 3.5;
this.f = 0.1;
};
Aizawa.prototype = Object.assign(Aizawa.prototype, {
constructor: Aizawa,
getName: function() {
return "Aizawa";
},
advance: function (p, t) {
var dx = (p[2] - this.b) * p[0] - this.d * p[1];
var dy = this.d * p[0] + (p[2] - this.b) * p[1];
var dz = this.c + this.a * p[2] - (p[2] * p[2] * p[2] / 3) - (p[0] * p[0] + p[1] * p[1]) * (1 + this.e * p[2]) + this.f * p[2] * p[0] * p[0] * p[0];
return [p[0] + dx * t, p[1] + dy * t, p[2] + dz * t];
},
});
// ---------------------------- Rucklidge -------------------------------------------
function Rucklidge() {
this.kappa = 2;
this.alpha = 6.7;
};
Rucklidge.prototype = Object.assign(Rucklidge.prototype, {
constructor: Rucklidge,
getName: function() {
return "Rucklidge";
},
advance: function (p, t) {
var dx = -this.kappa * p[0] + this.alpha * p[1] - p[1] * p[2];
var dy = p[0];
var dz = -p[2] + p[1] * p[1];
return [p[0] + dx * t, p[1] + dy * t, p[2] + dz * t];
},
});
// ---------------------------- Lorentz -------------------------------------------
function Lorentz() {
this.a = 10.0;
this.b = 28.0;
this.c = 8.0 / 3.0;
};
Lorentz.prototype = Object.assign(Lorentz.prototype, {
constructor: Lorentz,
getName: function() {
return "Lorentz";
},
advance: function (p, t) {
t = t/5.0;
var dx = this.a * (p[1] - p[0]);
var dy = p[0] * (this.b - p[2]) - p[1];
var dz = p[0] * p[1] - this.c * p[2];
return [p[0] + dx * t, p[1] + dy * t, p[2] + dz * t];
},
});
// ---------------------------- Chen Lee -------------------------------------------
function ChenLee() {
this.a = 5;
this.b = -10;
this.c = -0.38;
};
ChenLee.prototype = Object.assign(ChenLee.prototype, {
constructor: ChenLee,
getName: function() {
return "Chen Lee";
},
advance: function (p, t) {
t = t/10.0;
var dx = this.a * p[0] - p[1]*p[2];
var dy = this.b * p[1] + p[0]*p[2];
var dz = this.c * p[2] + p[0]*p[1];
return [p[0] + dx * t, p[1] + dy * t, p[2] + dz * t];
},
});
// -----------------------------------------------------------------------
function Arneodo() {
this.a = -6.0;
this.b = 4.3;
this.c = -2;
};
Arneodo.prototype = Object.assign(Arneodo.prototype, {
constructor: Arneodo,
getName: function() {
return "Arneodo";
},
advance: function (p, t) {
var dx = p[1];
var dy = p[2];
var dz = -this.a * p[0] - this.b * p[1] - p[2] + this.c * p[0]*p[0]*p[0] ;
return [p[0] + dx * t, p[1] + dy * t, p[2] + dz * t];
},
});
// -----------------------------------------------------------------------
// https://matousstieber.wordpress.com/2016/01/11/lorenz-attractor/
// http://www.3d-meier.de/tut19/plugins/Bouali.cof
function Bouali() {
this.a = 4;
this.b = 1;
this.alfa = 0.3;
this.beta = 0.05;
this.c = 1.5;
this.s = 1;
};
Bouali.prototype = Object.assign(Bouali.prototype, {
constructor: Bouali,
getName: function() {
return "Bouali";
},
advance: function (p, t) {
var dx = p[0]*(this.a-p[1])+this.alfa*p[2];
var dy = -p[1]*(this.b-p[0]*p[0]);
var dz = -p[0]*(this.c-this.s*p[2]) - this.beta*p[2] ;
return [p[0] + dx * t, p[1] + dy * t, p[2] + dz * t];
},
});
// -----------------------------------------------------------------------
// http://3d-meier.de/tut19/Seite9.html
function DequanLi() {
this.a = 40;
this.b = 1.833;
this.d = 0.16;
this.e = 0.65;
this.p = 55;
this.g = 20;
};
DequanLi.prototype = Object.assign(DequanLi.prototype, {
constructor: DequanLi,
getName: function() {
return "Dequan Li";
},
advance: function (p, t) {
t = t/ 10;
var dx = this.a*(p[1]-p[0])+this.d*(p[0]*p[2]);
var dy = this.p*p[0]+this.g*p[1]- p[0]*p[2];
var dz = this.b*p[2]+ p[0]*p[1] - this.e*p[0]*p[0] ;
return [p[0] + dx * t, p[1] + dy * t, p[2] + dz * t];
},
});
// -----------------------------------------------------------------------
// http://www.3d-meier.de/tut19/plugins/Liu-Chen.cof
function LiuChen() {
this.a = 2.4;
this.b = -3.78;
this.c = 14;
this.d = -11;
this.e = 4.0;
this.f = 5.58;
this.g =-1;
};
LiuChen.prototype = Object.assign(LiuChen.prototype, {
constructor: LiuChen,
getName: function() {
return "Liu Chen";
},
advance: function (p, t) {
t = t/ 10;
var dx = this.a*p[1]+this.b*p[0]+this.c*p[1]*p[2];
var dy = this.d * p[1] - p[2] + this.e*p[0]*p[2];
var dz = this.f*p[2]+this.g*p[0]*p[1] ;
return [p[0] + dx * t, p[1] + dy * t, p[2] + dz * t];
},
});
// -----------------------------------------------------------------------
// http://3d-meier.de/tut19/Seite15.html
function NoseHoover() {
this.a = 0.750;
};
NoseHoover.prototype = Object.assign(NoseHoover.prototype, {
constructor: NoseHoover,
getName: function() {
return "Nose-Hoover";
},
advance: function (p, t) {
t = t /5;
var dx = p[1];
var dy = -p[0] + p[1]*p[2];
var dz = this.a - p[1]*p[1] ;
return [p[0] + dx * t, p[1] + dy * t, p[2] + dz * t];
},
});
// -----------------------------------------------------------------------
// http://3d-meier.de/tut19/Seite13.html
function Halvorsen () {
this.a = 1.4;
};
Halvorsen .prototype = Object.assign(Halvorsen .prototype, {
constructor: Halvorsen ,
getName: function() {
return "Halvorsen";
},
advance: function (p, t) {
t = t /5;
var dx = -this.a*p[0] - 4*p[1] - 4*p[2] - p[1]*p[1];
var dy = -this.a*p[1] - 4*p[2] - 4*p[0] - p[2]*p[2];
var dz = -this.a*p[2] - 4*p[0] - 4*p[1] - p[0]*p[0];
return [p[0] + dx * t, p[1] + dy * t, p[2] + dz * t];
},
});
// -----------------------------------------------------------------------
// http://3d-meier.de/tut19/Seite13.html
function Hadley () {
this.a = 0.2;
this.b = 4.0;
this.f = 8.0;
this.g = 1.0;
};
Hadley.prototype = Object.assign(Hadley .prototype, {
constructor: Hadley ,
getName: function() {
return "Hadley";
},
advance: function (p, t) {
t = t/2;
var dx = -p[1]*p[1] - p[2]*p[2] - this.a*p[0] + this.a*this.f;
var dy = p[0]*p[1] - this.b*p[0]*p[2] - p[1] + this.g;
var dz = this.b*p[0]*p[1] + p[0]*p[2] - p[2];
return [p[0] + dx * t, p[1] + dy * t, p[2] + dz * t];
},
});
// -----------------------------------------------------------------------
// http://3d-meier.de/tut19/Seite43.html
function TSUCS2 () {
this.a = 40;
this.b = 55;
this.c = 1.833;
this.d = 0.16;
this.e = 0.65;
this.f = 20;
};
TSUCS2.prototype = Object.assign(TSUCS2 .prototype, {
constructor: TSUCS2 ,
getName: function() {
return "TSUCS2";
},
advance: function (p, t) {
t = t/10;
var dx = this.a*(p[1]-p[0]) + this.d*p[0]*p[2];
var dy = this.b*p[0]*p[0] - p[0]*p[2] + this.f*p[1];
var dz = this.c*p[2] + p[0]*p[1] - this.e*p[0]*p[0];
return [p[0] + dx * t, p[1] + dy * t, p[2] + dz * t];
},
});
// -----------------------------------------------------------------------
// https://en.wikipedia.org/wiki/R%C3%B6ssler_attractor
function Rossler() {
this.a=0.2;
this.b=0.2;
this.c=5.7;
};
Rossler.prototype = Object.assign(Rossler .prototype, {
constructor: Rossler ,
getName: function() {
return "Rössler";
},
advance: function (p, t) {
t = t/10.1;
var dx = -p[1]-p[2];
var dy = p[0]+this.a*p[1];
var dz = this.b + p[2]*(p[0]-this.c);
return [p[0] + dx * t, p[1] + dy * t, p[2] + dz * t];
},
});
// -----------------------------------------------------------------------
// http://3d-meier.de/tut19/Seite43.html
function TSUCS1 () {
this.a=40.0;
this.c=0.833;
this.d=0.5;
this.e=0.65;
this.f=20.0;
};
TSUCS1.prototype = Object.assign(TSUCS1 .prototype, {
constructor: TSUCS1 ,
getName: function() {
return "TSUCS1";
},
advance: function (p, t) {
t = t/100.1;
var dx = this.a*(p[1]-p[0]) + this.d*p[0]*p[2];
var dy = this.f*p[1] - p[0]*p[2];
var dz = this.c*p[2] + p[0]*p[1] - this.e*p[0]*p[0];
return [p[0] + dx * t, p[1] + dy * t, p[2] + dz * t];
},
});
function getAttractors() {
return [new Aizawa(), new ChenLee(), new Lorentz(), new Rucklidge(),
new Arneodo(), new Bouali(), /*new DequanLi(), */new LiuChen(), new NoseHoover(),
new Halvorsen(), new Hadley(), new TSUCS1(), new Rossler()
];
}