|
|
@ -1,6 +1,6 @@ |
|
|
|
class Manager { |
|
|
|
class Manager { |
|
|
|
|
|
|
|
|
|
|
|
pendulums: Pendulum[] = [] |
|
|
|
pendula: Pendulum[] = [] |
|
|
|
|
|
|
|
|
|
|
|
timescale = 1; |
|
|
|
timescale = 1; |
|
|
|
gravity = 9.81; |
|
|
|
gravity = 9.81; |
|
|
@ -16,7 +16,7 @@ class Manager { |
|
|
|
let rad = i / count / 1e3 + p.PI * 1.05; |
|
|
|
let rad = i / count / 1e3 + p.PI * 1.05; |
|
|
|
let hue = i / count * 100; |
|
|
|
let hue = i / count * 100; |
|
|
|
let color = p.color(hue, 100, 100); |
|
|
|
let color = p.color(hue, 100, 100); |
|
|
|
this.pendulums.push( |
|
|
|
this.pendula.push( |
|
|
|
new Pendulum([1, 1, 1, 1, 1, 1, 1, 1], [50, 50, 50, 50, 50, 50, 50, 100 + i / count / 10000], color) |
|
|
|
new Pendulum([1, 1, 1, 1, 1, 1, 1, 1], [50, 50, 50, 50, 50, 50, 50, 100 + i / count / 10000], color) |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
@ -72,6 +72,11 @@ class Manager { |
|
|
|
methods: { |
|
|
|
methods: { |
|
|
|
add() { |
|
|
|
add() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
deleteAll(){ |
|
|
|
|
|
|
|
if (confirm("Delete all pendulums?")){ |
|
|
|
|
|
|
|
manager.pendula.splice(0); |
|
|
|
|
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
resetMasses(){ |
|
|
|
resetMasses(){ |
|
|
|
for (let i = 0; i < this.maxSegmentCount; i++) |
|
|
|
for (let i = 0; i < this.maxSegmentCount; i++) |
|
|
@ -103,14 +108,14 @@ class Manager { |
|
|
|
update(){ |
|
|
|
update(){ |
|
|
|
if (this.playing) { |
|
|
|
if (this.playing) { |
|
|
|
const h = this.timescale / Math.max(p.frameRate(), 1); |
|
|
|
const h = this.timescale / Math.max(p.frameRate(), 1); |
|
|
|
this.pendulums.forEach(p => p.update(h)); |
|
|
|
this.pendula.forEach(p => p.update(h)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
draw(){ |
|
|
|
draw(){ |
|
|
|
p.push() |
|
|
|
p.push() |
|
|
|
p.translate(p.width / 2, p.height / 2); |
|
|
|
p.translate(p.width / 2, p.height / 2); |
|
|
|
this.pendulums.forEach(p => p.draw()); |
|
|
|
this.pendula.forEach(p => p.draw()); |
|
|
|
p.pop(); |
|
|
|
p.pop(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|