Function bodies 61 total
calculateGradient method · javascript · L186-L214 (29 LOC)more-zeeman/script_unified.js
calculateGradient(angle) {
const R = this.attachmentRadius;
// Coordinates relative to wheel center
const Fx = this.fixedAnchor.x - this.wheelCenter.x;
const Fy = this.fixedAnchor.y - this.wheelCenter.y;
const Cx = this.controlPoint.x - this.wheelCenter.x;
const Cy = this.controlPoint.y - this.wheelCenter.y;
// Attachment point relative to center
const Px = R * Math.cos(angle);
const Py = R * Math.sin(angle);
// Calculate lengths
const L1 = Math.sqrt(Math.pow(Px - Fx, 2) + Math.pow(Py - Fy, 2));
const L2 = Math.sqrt(Math.pow(Px - Cx, 2) + Math.pow(Py - Cy, 2));
let Term1 = 0;
if (L1 > this.L0 && L1 > 0.001) {
Term1 = this.springK * (1 - this.L0 / L1) * (Fx * Math.sin(angle) - Fy * Math.cos(angle));
}
let Term2 = 0;
if (L2 > this.L0 && L2 > 0.001) {
estimateStability method · javascript · L217-L222 (6 LOC)more-zeeman/script_unified.js
estimateStability(angle) {
const dA = 0.01;
const gradientPlus = this.calculateGradient(angle + dA);
const gradientMinus = this.calculateGradient(angle - dA);
return (gradientPlus - gradientMinus) / (2 * dA);
}updateState method · javascript · L225-L265 (41 LOC)more-zeeman/script_unified.js
updateState() {
let newAngle = this.angle;
const learningRate = 0.001;
const maxIterations = 250;
const convergenceThreshold = 0.05;
let stability = 0;
// Gradient descent loop
for (let i = 0; i < maxIterations; i++) {
const gradient = this.calculateGradient(newAngle);
if (Math.abs(gradient) < convergenceThreshold) {
stability = this.estimateStability(newAngle);
if (stability > 0) break; // Found stable minimum
}
let step = learningRate * gradient;
const maxStep = 0.1;
step = Math.max(-maxStep, Math.min(maxStep, step));
newAngle -= step;
newAngle = (newAngle + 4 * Math.PI) % (2 * Math.PI);
}
if (stability <= 0) {
stability = this.estimateStability(newAngle);
}
/update method · javascript · L267-L290 (24 LOC)more-zeeman/script_unified.js
update() {
const wasStable = this.isStable;
const snapped = this.updateState();
// Determine current output character
const currentOutput = (this.angle > Math.PI / 2 && this.angle < 3 * Math.PI / 2) ? 'W' : 'M';
// Check stability
this.isStable = this.currentStability > 0.3;
if (this.isStable) {
this.statusEl.textContent = 'Stable - ' + currentOutput;
// Trigger matrix growth on catastrophe
if (snapped) {
const now = Date.now();
if (now - this._lastGrow > 500) {
this._lastGrow = now;
this.automaton.grow(currentOutput);
}
}
} else {
this.statusEl.textContent = 'Superimposed (Indeterminate)';
}
}draw method · javascript · L292-L377 (86 LOC)more-zeeman/script_unified.js
draw() {
this.ctx.clearRect(0, 0, this.width, this.height);
const P = this.getAttachmentPoint(this.angle);
// Calculate lengths for visualization
const L1 = Math.sqrt(Math.pow(P.x - this.fixedAnchor.x, 2) + Math.pow(P.y - this.fixedAnchor.y, 2));
const L2 = Math.sqrt(Math.pow(P.x - this.controlPoint.x, 2) + Math.pow(P.y - this.controlPoint.y, 2));
// Draw elastic bands
this.ctx.lineWidth = 3;
// Band to fixed anchor
this.ctx.beginPath();
this.ctx.moveTo(this.fixedAnchor.x, this.fixedAnchor.y);
this.ctx.lineTo(P.x, P.y);
if (L1 <= this.L0) {
this.ctx.setLineDash([5, 5]); // Dashed if slack
this.ctx.strokeStyle = '#999';
} else {
this.ctx.setLineDash([]);
this.ctx.strokeStyle = '#c0392b'; // Red
}
this.ctx.stroke();
// Bandloop method · javascript · L379-L383 (5 LOC)more-zeeman/script_unified.js
loop() {
this.update();
this.draw();
requestAnimationFrame(() => this.loop());
}AcousticVisualization class · javascript · L387-L530 (144 LOC)more-zeeman/script_unified.js
class AcousticVisualization {
constructor(zeemanMachine) {
this.zeeman = zeemanMachine;
this.svg = document.getElementById('acoustic-svg');
this.svgNS = "http://www.w3.org/2000/svg";
// Parameters
this.width = 500;
this.height = 300;
this.numParticles = 200;
this.particleRadius = 2;
this.speakerWidth = 40;
this.speakerHeight = 150;
this.speakerX = 60;
this.speakerY = (this.height - this.speakerHeight) / 2;
this.chamberEndX = this.width - 20;
// Wave propagation
this.waveSpeed = 6;
this.historySeconds = 1.5;
this.fps = 60;
this.history = new Array(Math.ceil(this.fps * this.historySeconds)).fill(0);
this.historyIndex = 0;
this.maxDisplacement = 30;
this.sensitivityScale = 15;
this.smoothedDisplacement = 0;
Repobility analyzer · published findings · https://repobility.com
constructor method · javascript · L388-L419 (32 LOC)more-zeeman/script_unified.js
constructor(zeemanMachine) {
this.zeeman = zeemanMachine;
this.svg = document.getElementById('acoustic-svg');
this.svgNS = "http://www.w3.org/2000/svg";
// Parameters
this.width = 500;
this.height = 300;
this.numParticles = 200;
this.particleRadius = 2;
this.speakerWidth = 40;
this.speakerHeight = 150;
this.speakerX = 60;
this.speakerY = (this.height - this.speakerHeight) / 2;
this.chamberEndX = this.width - 20;
// Wave propagation
this.waveSpeed = 6;
this.historySeconds = 1.5;
this.fps = 60;
this.history = new Array(Math.ceil(this.fps * this.historySeconds)).fill(0);
this.historyIndex = 0;
this.maxDisplacement = 30;
this.sensitivityScale = 15;
this.smoothedDisplacement = 0;
this.smoothingFactor = 0.2;
init method · javascript · L421-L484 (64 LOC)more-zeeman/script_unified.js
init() {
this.svg.innerHTML = '';
this.particles = [];
// Draw walls
const drawWall = (y) => {
const wall = document.createElementNS(this.svgNS, 'line');
wall.setAttribute('x1', this.speakerX);
wall.setAttribute('y1', y);
wall.setAttribute('x2', this.chamberEndX);
wall.setAttribute('y2', y);
wall.setAttribute('stroke', '#999');
wall.setAttribute('stroke-width', '2');
this.svg.appendChild(wall);
};
drawWall(this.speakerY);
drawWall(this.speakerY + this.speakerHeight);
// Draw piston
this.pistonRect = document.createElementNS(this.svgNS, 'rect');
this.pistonRect.setAttribute('x', this.speakerX - this.speakerWidth);
this.pistonRect.setAttribute('y', this.speakerY);
this.pistonRect.setAttribute('width', this.speaanimate method · javascript · L486-L529 (44 LOC)more-zeeman/script_unified.js
animate() {
// Calculate angular velocity (change in angle)
let dTheta = this.zeeman.angle - this.zeeman.previousAngle;
while (dTheta > Math.PI) dTheta -= 2 * Math.PI;
while (dTheta < -Math.PI) dTheta += 2 * Math.PI;
// Target displacement based on velocity
const targetDisplacement = this.maxDisplacement * Math.tanh(dTheta * this.sensitivityScale);
// Smooth the displacement
this.smoothedDisplacement += (targetDisplacement - this.smoothedDisplacement) * this.smoothingFactor;
// Store in history for wave propagation
this.history[this.historyIndex] = this.smoothedDisplacement;
this.historyIndex = (this.historyIndex + 1) % this.history.length;
// Move piston
this.pistonRect.setAttribute('x', (this.speakerX - this.speakerWidth + this.smoothedDisplacement).toFixed(2));
// Calculate piston face position
animateAll function · javascript · L538-L541 (4 LOC)more-zeeman/script_unified.js
function animateAll() {
acousticViz.animate();
requestAnimationFrame(animateAll);
}‹ prevpage 2 / 2