-
Notifications
You must be signed in to change notification settings - Fork 0
/
clifford.ts
45 lines (35 loc) · 828 Bytes
/
clifford.ts
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
import { Plotter } from "./plotter";
export default class Clifford extends Plotter {
// introduce chaos a little
// a: number = -1.9 + (Math.random()/5) * (Math.random()<0.5?-1:1);
// b: number = -1.9;
// c: number = -1.9;
// d: number = -1;
a: number = 2 + (Math.random()/5) * (Math.random()<0.5?-1:1);
b: number = -2;
c: number = 1;
d: number = -1;
constructor(){
super({
x: 0,
y: 0
})
}
reset(){
super.reset()
// this.a = -1.9 + (Math.random()/5) * (Math.random()<0.5?-1:1);
}
calculate():[number, number]{
const {
x, y, a, b, c, d
} = this
const xt = Math.sin(a * y) + c * Math.cos(a * x);
const yt = Math.sin(b * x) + d * Math.cos(b * y);
this.x = xt;
this.y = yt;
return [
this.x,
this.y
]
}
}