Reiman_Hypothesis / gemini-code-barridofull.html
sjhallo07's picture
Upload gemini-code-barridofull.html
c05247a verified
Raw History Blame Contribute Delete
45.9 kB
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Null Fock Theory & Relatividad Algebraica 26D - Secuencia Vectorial y Reversal</title>
<!-- Three.js y OrbitControls desde CDN -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/three@0.128.0/examples/js/controls/OrbitControls.js"></script>
<style>
* { box-sizing: border-box; }
body {
margin: 0;
overflow: hidden;
background-color: #02040a;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
color: #e2e8f0;
}
#canvas-container {
width: 100vw;
height: 100vh;
display: block;
}
.hud-panel {
position: absolute;
background: rgba(15, 23, 42, 0.92);
border: 1px solid rgba(56, 189, 248, 0.3);
backdrop-filter: blur(12px);
padding: 12px 16px;
border-radius: 10px;
box-shadow: 0 10px 30px rgba(0,0,0,0.8);
z-index: 10;
}
#header-panel {
top: 10px; left: 10px; right: 10px;
display: flex; justify-content: space-between; align-items: center;
}
#control-panel {
top: 70px; left: 10px;
width: 380px; max-height: calc(100vh - 85px);
overflow-y: auto;
}
#right-top-panel {
top: 70px; right: 10px;
width: 360px;
}
#right-bottom-panel {
bottom: 10px; right: 10px;
width: 400px; max-height: 220px; overflow: auto;
}
h1 { font-size: 1rem; color: #38bdf8; margin: 0; }
.subtitle { font-size: 0.7rem; color: #94a3b8; margin-top: 2px; }
.control-group { margin-bottom: 10px; }
label { display: flex; justify-content: space-between; font-size: 0.72rem; color: #38bdf8; margin-bottom: 3px; }
select, input[type=range], button { width: 100%; }
select {
background: #030712; color: #00f0ff; border: 1px solid rgba(0, 240, 255, 0.4);
padding: 6px; border-radius: 6px; font-size: 0.75rem; margin-top: 2px;
}
input[type=range] { accent-color: #0ea5e9; cursor: pointer; }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }
button {
background: #0284c7; color: white; border: none; padding: 7px;
border-radius: 6px; font-size: 0.7rem; font-weight: bold; cursor: pointer;
transition: background 0.2s, transform 0.1s;
}
button:hover { background: #0ea5e9; }
button.secondary { background: #334155; }
button.secondary:hover { background: #475569; }
.btn-dirac { background: #7c2d12; border: 1px solid #f97316; color: #ffedd5; }
.btn-dirac:hover { background: #9a3412; }
.btn-fock { background: #1e3a8a; border: 1px solid #3b82f6; color: #bfdbfe; }
.btn-fock:hover { background: #1d4ed8; }
.btn-vector { background: #065f46; border: 1px solid #10b981; color: #d1fae5; }
.btn-vector:hover { background: #047857; }
.btn-seq-forward { background: #0284c7; border: 1px solid #38bdf8; color: #e0f2fe; }
.btn-seq-forward:hover { background: #0369a1; }
.btn-seq-reversal { background: #be123c; border: 1px solid #f43f5e; color: #ffe4e6; }
.btn-seq-reversal:hover { background: #9f1239; }
.stats-panel {
font-size: 0.72rem; background: rgba(3, 7, 18, 0.95);
padding: 8px 10px; border-radius: 6px; border: 1px solid #1e293b; margin-top: 8px;
}
.stat-row { display: flex; justify-content: space-between; margin-bottom: 3px; }
.dim-highlight { color: #fbbf24; font-weight: bold; }
.matter-val { color: #38bdf8; font-weight: bold; }
.antimatter-val { color: #f43f5e; font-weight: bold; }
.fock-val { color: #22c55e; font-weight: bold; }
#algebra-log {
font-family: monospace; font-size: 0.68rem; color: #38bdf8;
background: rgba(2, 6, 23, 0.95); padding: 8px; border-radius: 6px;
border: 1px solid #1e293b; margin-bottom: 8px; max-height: 90px; overflow-y: auto;
}
canvas.chart-canvas { width: 100%; height: 70px; background: rgba(0,0,0,0.5); border-radius: 4px; margin-top: 4px; }
table.matrix-table { width: 100%; border-collapse: collapse; color: #a5f3fc; font-family: monospace; font-size: 0.65rem; }
table.matrix-table td { padding: 2px; text-align: center; border: 1px solid rgba(0, 240, 255, 0.15); }
.status-badge { font-size: 0.7rem; font-weight: bold; padding: 3px 8px; border-radius: 4px; background: rgba(0,240,255,0.1); }
.vector-container {
margin-top: 10px;
background: rgba(3, 7, 18, 0.95);
padding: 8px;
border-radius: 6px;
border: 1px solid #1e293b;
}
canvas.vector-canvas {
width: 100%;
height: 190px;
background: #020617;
border-radius: 4px;
display: block;
}
</style>
</head>
<body>
<div id="canvas-container"></div>
<!-- ENCABEZADO SUPERIOR -->
<div id="header-panel" class="hud-panel">
<div>
<h1>Null Fock & Relatividad Algebraica: Matriz Fuente &rho;₂₆_D⁽²⁾</h1>
<div class="subtitle">Modelo Hiperdimensional | Secuencia Vectorial ONDAR 5D-26D & Reversal 26D $\rightarrow$ 1D = 0</div>
</div>
<div>
<span id="status-badge" class="status-badge" style="color: #f59e0b;">Fase: Telemetría Activa</span>
</div>
</div>
<!-- PANEL DE CONTROL IZQUIERDO -->
<div id="control-panel" class="hud-panel">
<div class="control-group">
<label><span>Estadio Dimensional Dinámico:</span></label>
<select id="menu-dim" onchange="cambiarDimensionManual(this.value)">
<option value="1D">1D - Punto Singularity / Nulo (1x1)</option>
<option value="5D">5D - Matriz Factorial Reducida</option>
<option value="11D">11D - Cavidad Ceros de Riemann</option>
<option value="15D">15D - Transición Topológica</option>
<option value="26D" selected>26D - Matriz Fuente Plena &rho;₂₆_D⁽²⁾</option>
</select>
</div>
<div class="control-group">
<label>
<span>Parámetro Secuencial (r):</span>
<span id="lblValR">0.000</span>
</label>
<input type="range" id="rangeSweep" min="-0.5" max="0.0" step="0.001" value="0.0">
</div>
<!-- MACRO-SECUENCIAS VECTORIALES -->
<div style="font-size:0.7rem; font-weight:bold; color:#00f0ff; margin-top:8px; margin-bottom:4px;">
Macro-Secuencias de Onda y Vector:
</div>
<div class="btn-grid">
<button class="btn-seq-forward" onclick="iniciarSecuenciaForward()">▶ Secuencia 5D → 26D</button>
<button class="btn-seq-reversal" onclick="iniciarSecuenciaReversal()">◀ Reversal 26D → 1D = 0</button>
</div>
<div class="btn-grid" style="margin-top: 6px;">
<button id="btnAuto">Barrido r (Auto)</button>
<button id="btnReset" class="secondary">Reiniciar Todo</button>
</div>
<div style="margin-top: 10px;" class="control-group">
<button class="btn-dirac" onclick="ejecutarDiracCero()">1. Anular Campo Dirac (Dirac = 0)</button>
<button class="btn-fock" onclick="ejecutarFusionFock()" style="margin-top: 4px;">2. Fusionar con Espacio de Fock</button>
<button class="btn-vector" onclick="ejecutarAlgebraNoLineal()" style="margin-top: 4px;">3. Ejecutar Álgebra No Lineal f(&rho;)</button>
<button onclick="toggleRotacionAutomatica()" class="secondary" style="margin-top: 4px;">⚡ Conmutar Giro 3D</button>
</div>
<div class="stats-panel">
<div class="stat-row">
<span>Estado Dimensional:</span>
<span id="valDim" class="dim-highlight">26D - Cierre Bosónico</span>
</div>
<div class="stat-row">
<span>Energía Materia (&cosh;):</span>
<span id="valMatter" class="matter-val">1.2517</span>
</div>
<div class="stat-row">
<span>Energía Antimateria (&sinh;):</span>
<span id="valAntimatter" class="antimatter-val">1.0278</span>
</div>
<div class="stat-row">
<span>Campo de Fock (F):</span>
<span id="valFock" class="fock-val">Equilibrio Dinámico</span>
</div>
</div>
<!-- ANALIZADOR VECTORIAL POLAR -->
<div class="vector-container">
<div style="font-weight:bold; font-size: 0.72rem; color:#38bdf8; display:flex; justify-content:space-between; margin-bottom: 4px;">
<span>Analizador Vectorial Fasorial</span>
<span style="color: #00f0ff;" id="vector-hud-tag">26 Canales</span>
</div>
<canvas id="vectorCanvas26" class="vector-canvas"></canvas>
<div style="font-size: 0.63rem; color: #94a3b8; margin-top: 4px; display: flex; justify-content: space-between;">
<span style="color: #38bdf8;">■ Par: Materia (&cosh;)</span>
<span style="color: #f43f5e;">■ Impar: Antimateria (&sinh;)</span>
</div>
</div>
</div>
<!-- PANEL DERECHO SUPERIOR -->
<div id="right-top-panel" class="hud-panel">
<div style="font-weight:bold; font-size: 0.75rem; color:#fff; margin-bottom:4px; border-bottom: 1px solid rgba(0,240,255,0.2); padding-bottom:2px;">
Telemetría Analítica:
</div>
<div id="algebra-log">[Bob-Node-26D] Matriz Fuente &rho;₂₆_D⁽²⁾ cargada correctamente.</div>
<div style="font-weight:bold; font-size: 0.72rem; color:#fff; display:flex; justify-content:space-between; margin-top: 6px;">
<span>Espacio de Fase & Frecuencia Matriz</span>
<span style="color: #00f0ff;" id="chart-tag">Freq: -- Hz</span>
</div>
<canvas id="spectralChart" class="chart-canvas"></canvas>
</div>
<!-- PANEL DERECHO INFERIOR -->
<div id="right-bottom-panel" class="hud-panel">
<div style="font-weight:bold; margin-bottom:4px; color:#fff; display:flex; justify-content:space-between; font-size: 0.75rem;">
<span id="hud-title">Inspección Factorial Fuente (26D)</span>
<span style="color: #00f0ff;" id="hud-dim-tag">26x26 Grid</span>
</div>
<table class="matrix-table" id="matrix-grid"></table>
</div>
<script>
// --- 1. CONFIGURACIÓN Y TELEMETRÍA ---
const TELEMETRY_CONFIG = {
globalEnergyInvariant: 3.5189,
harmonicConstant: 7,
targetNode: "Bob-Node-26D"
};
let currentDimSize = 26;
let selectedDimKey = '26D';
let pipelinePhase = 'PREVIEW';
let isAutoRotating = true;
let isAutoSweep = false;
let autoSweepDir = 1;
let matrixStates = [];
// Modos de secuencia vectorial automatizada
let autoSequenceMode = 'NONE'; // 'FORWARD_5D_26D', 'REVERSAL_26D_1D'
let sequenceProgress = 0;
let reversalZeroFactor = 1.0; // Factor de atenuación al colapsar a 1D = 0
const channelFrequencies = new Float32Array(26);
function calcularFactorial(n) {
if (n === 0 || n === 1) return 1;
let res = 1;
for (let i = 2; i <= n; i++) res *= i;
return res;
}
function generarMatrizFactorialReal(size) {
let matrizReal = [];
for (let i = 0; i < size; i++) {
let fila = [];
for (let j = 0; j < size; j++) {
if ((i + j) % 2 === 0) {
let f1 = calcularFactorial(i);
let f2 = calcularFactorial(j);
fila.push(1.0 / (f1 * f2));
} else {
fila.push(0.0);
}
}
matrizReal.push(fila);
}
return matrizReal;
}
function generarMatrizHTML(size) {
const matrizData = generarMatrizFactorialReal(size);
const tabla = document.getElementById('matrix-grid');
let html = '';
for (let i = 0; i < size; i++) {
html += '<tr>';
for (let j = 0; j < size; j++) {
let val = matrizData[i][j];
let displayVal = val === 0 ? "0" : (val === 1 ? "1" : `1/${i === 0 ? 1 : i + '!'}${j === 0 ? 1 : j + '!'}`);
if (size > 12) {
displayVal = val === 0 ? "0" : val.toExponential(0);
}
html += `<td>${displayVal}</td>`;
}
html += '</tr>';
}
tabla.innerHTML = html;
}
// --- 2. ESCENA WEBGL CON THREE.JS ---
const container = document.getElementById('canvas-container');
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x02040a);
scene.fog = new THREE.FogExp2(0x02040a, 0.015);
const camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.position.set(26, 26, 34);
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(window.devicePixelRatio);
container.appendChild(renderer.domElement);
const controls = new THREE.OrbitControls(camera, renderer.domElement);
controls.enableDamping = true;
controls.dampingFactor = 0.05;
// Iluminación
scene.add(new THREE.AmbientLight(0xffffff, 0.75));
const lightA = new THREE.PointLight(0x38bdf8, 2, 60);
lightA.position.set(-12, 22, 12);
scene.add(lightA);
const lightB = new THREE.PointLight(0xf43f5e, 2, 60);
lightB.position.set(12, 22, -12);
scene.add(lightB);
const gridHelper = new THREE.GridHelper(36, 18, 0x38bdf8, 0x1e293b);
gridHelper.position.y = -3.4;
scene.add(gridHelper);
const master3DGroup = new THREE.Group();
scene.add(master3DGroup);
let matrixGroup = new THREE.Group();
let stringsGroup = new THREE.Group();
let channelsGroup = new THREE.Group();
master3DGroup.add(matrixGroup);
master3DGroup.add(stringsGroup);
master3DGroup.add(channelsGroup);
// --- 3. RECONSTRUCCIÓN DINÁMICA DE LA RETÍCULA 3D ---
function reconstruirEscena3D(size) {
while(matrixGroup.children.length > 0) matrixGroup.remove(matrixGroup.children[0]);
while(stringsGroup.children.length > 0) stringsGroup.remove(stringsGroup.children[0]);
while(channelsGroup.children.length > 0) channelsGroup.remove(channelsGroup.children[0]);
const matrizData = generarMatrizFactorialReal(size);
const scaleFactor = Math.max(size, 4);
const barGeo = new THREE.BoxGeometry(0.55 * (22/scaleFactor), 1, 0.55 * (22/scaleFactor));
barGeo.translate(0, 0.5, 0);
matrixStates = [];
for (let i = 0; i < size; i++) {
for (let j = 0; j < size; j++) {
let densidad = matrizData[i][j];
let isEven = (i + j) % 2 === 0;
let baseH = isEven ? Math.max(0.15, Math.log10(1 / (densidad + 1e-12) + 1) * 0.35) : 0.05;
if (i === j) baseH *= 1.3;
let colorMat = i === j ? 0xffb703 : (isEven ? 0x38bdf8 : 0xf43f5e);
let material = new THREE.MeshStandardMaterial({
color: colorMat,
roughness: 0.25,
metalness: 0.75,
emissive: colorMat,
emissiveIntensity: 0.2
});
let mesh = new THREE.Mesh(barGeo, material);
let posX = (i - size / 2 + 0.5) * (22 / scaleFactor);
let posZ = (j - size / 2 + 0.5) * (22 / scaleFactor);
mesh.position.set(posX, -3.2, posZ);
mesh.userData = {
isEven: isEven,
baseX: posX,
baseZ: posZ,
baseHeight: baseH,
density: densidad,
indexI: i,
indexJ: j,
phase: Math.random() * Math.PI
};
matrixGroup.add(mesh);
matrixStates.push(mesh);
// Conexión canal diagonal
if (i === j && i < size - 1) {
let nextPosX = ((i+1) - size/2 + 0.5) * (22/scaleFactor);
let nextPosZ = ((j+1) - size/2 + 0.5) * (22/scaleFactor);
let geomLine = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(posX, -3.1, posZ),
new THREE.Vector3(nextPosX, -3.1, nextPosZ)
]);
let lineMat = new THREE.LineBasicMaterial({ color: 0xffb703, linewidth: 2 });
channelsGroup.add(new THREE.Line(geomLine, lineMat));
}
}
}
// Cuerdas de solitones
const stringMat = new THREE.LineBasicMaterial({ color: 0xf43f5e, linewidth: 2 });
let stringCount = Math.max(1, Math.min(size, 12));
for (let s = 0; s < stringCount; s++) {
let points = [];
let zCoord = (s - size/2) * (18 / size);
for (let p = -10; p <= 10; p += 1) {
points.push(new THREE.Vector3(p, Math.sin(p * 0.4 + s) * 0.8, zCoord));
}
let stringGeom = new THREE.BufferGeometry().setFromPoints(points);
stringsGroup.add(new THREE.Line(stringGeom, stringMat));
}
}
// --- 4. SUPERFICIE ONDAS ZETA DE RIEMANN ---
const zetaGeo = new THREE.PlaneGeometry(24, 24, 36, 36);
zetaGeo.rotateX(-Math.PI / 2);
const zetaPosAttr = zetaGeo.attributes.position;
const nonTrivialZeros = [14.1347, 21.0220, 25.0110, 30.4249, 32.9351];
function updateZetaWave(r) {
for (let k = 0; k < zetaPosAttr.count; k++) {
let x = zetaPosAttr.getX(k);
let z = zetaPosAttr.getZ(k);
let reS = x / 4;
let imS = Math.abs(z / 1.2) + 2;
let waveBase = Math.cos(reS * 2 + r * 5) * 0.5;
let zeroPull = 0;
nonTrivialZeros.forEach(zeroIm => {
let dist = Math.sqrt(Math.pow(reS - 0.5, 2) + Math.pow(imS - zeroIm * 0.4, 2));
zeroPull += 2.5 / (1.0 + Math.pow(dist * 3, 2));
});
let y = (waveBase - zeroPull) * (1.0 + Math.abs(r)) * reversalZeroFactor;
zetaPosAttr.setY(k, y - 0.5);
}
zetaPosAttr.needsUpdate = true;
}
const zetaMaterial = new THREE.MeshStandardMaterial({
color: 0x22d3ee,
wireframe: true,
transparent: true,
opacity: 0.35,
side: THREE.DoubleSide
});
const zetaMesh = new THREE.Mesh(zetaGeo, zetaMaterial);
master3DGroup.add(zetaMesh);
// --- 5. TEXTURA CANVAS 2D MATRIZ EN EL SUELO INFERIOR ---
const floorCanvas = document.createElement('canvas');
floorCanvas.width = 2048;
floorCanvas.height = 2048;
const ctxFloor = floorCanvas.getContext('2d');
const floorTexture = new THREE.CanvasTexture(floorCanvas);
const floorGeo = new THREE.PlaneGeometry(26, 26);
floorGeo.rotateX(-Math.PI / 2);
const floorMat = new THREE.MeshBasicMaterial({
map: floorTexture,
transparent: true,
opacity: 0.85,
side: THREE.DoubleSide
});
const floorMesh = new THREE.Mesh(floorGeo, floorMat);
floorMesh.position.y = -3.48;
master3DGroup.add(floorMesh);
function drawNumericMatrix(r) {
ctxFloor.clearRect(0, 0, 2048, 2048);
ctxFloor.fillStyle = 'rgba(3, 7, 18, 0.95)';
ctxFloor.fillRect(0, 0, 2048, 2048);
ctxFloor.strokeStyle = '#1e293b';
ctxFloor.lineWidth = 4;
ctxFloor.strokeRect(20, 20, 2008, 2008);
ctxFloor.fillStyle = '#38bdf8';
ctxFloor.font = 'bold 36px monospace';
ctxFloor.fillText(`MATRIZ DE TRANSFORMACIÓN NUMÉRICA ρ_${currentDimSize}D(r) - REV_FACTOR: ${reversalZeroFactor.toFixed(2)}`, 50, 70);
let displayDim = Math.min(currentDimSize, 16);
let cellSize = Math.floor(1900 / displayDim);
let startX = 80;
let startY = 120;
ctxFloor.font = 'bold 18px monospace';
for (let i = 0; i < displayDim; i++) {
for (let j = 0; j < displayDim; j++) {
let cellX = startX + j * cellSize;
let cellY = startY + i * cellSize;
let isEven = (i + j) % 2 === 0;
let baseVal = 1.0 / ((i + 1) * (j + 1));
let val;
if (isEven) {
val = baseVal * (1.0 + Math.cosh(Math.abs(r) * 2) * 1.2517) * reversalZeroFactor;
ctxFloor.fillStyle = '#38bdf8';
} else {
val = baseVal * (1.0 + Math.sinh(Math.abs(r) * 2) * 1.0278) * reversalZeroFactor;
ctxFloor.fillStyle = '#f43f5e';
}
ctxFloor.strokeStyle = isEven ? 'rgba(56, 189, 248, 0.25)' : 'rgba(244, 63, 94, 0.25)';
ctxFloor.strokeRect(cellX, cellY, cellSize - 4, cellSize - 4);
let strVal = val < 0.01 ? val.toExponential(1) : val.toFixed(3);
ctxFloor.fillText(strVal, cellX + 8, cellY + (cellSize / 2));
}
}
floorTexture.needsUpdate = true;
}
// --- 6. GRÁFICO DE ESPACIO DE FASE Y CURL VECTORIAL ---
const chartCanvas = document.getElementById('spectralChart');
const ctxChart = chartCanvas.getContext('2d');
function calcularCurlYFrecuenciaMatriz(matrixStates, dimSize, t) {
let curlTotal = 0;
let count = 0;
for (let i = 1; i < dimSize - 1; i++) {
for (let j = 1; j < dimSize - 1; j++) {
let idxCenter = i * dimSize + j;
let idxRight = (i + 1) * dimSize + j;
let idxLeft = (i - 1) * dimSize + j;
let idxUp = i * dimSize + (j + 1);
let idxDown = i * dimSize + (j - 1);
if (matrixStates[idxCenter] && matrixStates[idxRight] && matrixStates[idxLeft] && matrixStates[idxUp] && matrixStates[idxDown]) {
let hR = matrixStates[idxRight].scale.y;
let hL = matrixStates[idxLeft].scale.y;
let hU = matrixStates[idxUp].scale.y;
let hD = matrixStates[idxDown].scale.y;
let dVz_dx = (hR - hL) / 2.0;
let dVx_dz = (hU - hD) / 2.0;
let curlLocal = Math.abs(dVz_dx - dVx_dz);
curlTotal += curlLocal;
count++;
}
}
}
let vorticidadPromedio = count > 0 ? curlTotal / count : 0;
let matrizFrecuenciaHz = (vorticidadPromedio * TELEMETRY_CONFIG.globalEnergyInvariant * TELEMETRY_CONFIG.harmonicConstant * reversalZeroFactor + Math.sin(t * 1.5) * 12.4 * reversalZeroFactor).toFixed(2);
document.getElementById('chart-tag').innerText = `Freq: ${matrizFrecuenciaHz} Hz (${TELEMETRY_CONFIG.targetNode})`;
return matrizFrecuenciaHz;
}
function dibujarEspacioFase(t) {
chartCanvas.width = chartCanvas.clientWidth;
chartCanvas.height = chartCanvas.clientHeight;
let w = chartCanvas.width;
let h = chartCanvas.height;
ctxChart.clearRect(0, 0, w, h);
ctxChart.strokeStyle = 'rgba(0, 240, 255, 0.3)';
ctxChart.lineWidth = 1;
ctxChart.beginPath();
ctxChart.moveTo(20, 5); ctxChart.lineTo(20, h - 10);
ctxChart.moveTo(20, h - 10); ctxChart.lineTo(w - 8, h - 10);
ctxChart.stroke();
ctxChart.strokeStyle = autoSequenceMode === 'REVERSAL_26D_1D' ? '#f43f5e' : (pipelinePhase === 'NON_LINEAR_EXEC' ? '#10b981' : '#00f0ff');
ctxChart.lineWidth = 2;
ctxChart.beginPath();
for (let x = 0; x < w - 28; x++) {
let px = 20 + x;
let normX = x / (w - 28);
let nonLinearWave = Math.sin(normX * 8 + t * 2) / (1.0 + 0.5 * Math.pow(Math.cos(normX * 4), 2));
let py = (h - 10) - (nonLinearWave * 16 * reversalZeroFactor + Math.tanh(Math.sin(t * 3 + normX * 5)) * 10 * reversalZeroFactor) - (h / 2.2);
if (x === 0) ctxChart.moveTo(px, py);
else ctxChart.lineTo(px, py);
}
ctxChart.stroke();
}
// --- 7. ANALIZADOR VECTORIAL POLAR DE 26 CANALES ---
function calcularFrecuencias26Canales(matrixStates, dimSize, t) {
const globalBase = parseFloat(TELEMETRY_CONFIG.globalEnergyInvariant || 3.5189);
for (let k = 0; k < 26; k++) {
if (k >= dimSize) {
channelFrequencies[k] = 0.01;
continue;
}
let gradienteCanal = 0;
let count = 0;
for (let j = 0; j < dimSize - 1; j++) {
let idxCurr = k * dimSize + j;
let idxNext = k * dimSize + (j + 1);
if (matrixStates[idxCurr] && matrixStates[idxNext]) {
let hCurr = matrixStates[idxCurr].scale.y;
let hNext = matrixStates[idxNext].scale.y;
gradienteCanal += Math.abs(hNext - hCurr);
count++;
}
}
let vorticidadCanal = count > 0 ? gradienteCanal / count : 0;
const armonicoMod = (k % 2 === 0) ? Math.cosh(0.04 * k) : Math.sinh(0.04 * k);
const freqHz = ((vorticidadCanal * globalBase * 2.2 + Math.sin(t * 1.5 + k * 0.24) * 3.8 + armonicoMod) * reversalZeroFactor).toFixed(2);
channelFrequencies[k] = Math.max(0.01, parseFloat(freqHz));
}
return channelFrequencies;
}
function renderizarGraficaVectorial26(canvasId, channelFreqs, activeDim = 26) {
const canvas = document.getElementById(canvasId);
if (!canvas) return;
const ctx = canvas.getContext('2d');
if (canvas.width !== canvas.clientWidth || canvas.height !== canvas.clientHeight) {
canvas.width = canvas.clientWidth || 320;
canvas.height = canvas.clientHeight || 190;
}
const width = canvas.width;
const height = canvas.height;
const cx = width / 2;
const cy = height / 2;
const maxRadius = Math.min(cx, cy) - 20;
ctx.clearRect(0, 0, width, height);
ctx.fillStyle = 'rgba(2, 6, 23, 0.95)';
ctx.fillRect(0, 0, width, height);
// Anillos concéntricos de referencia
ctx.strokeStyle = 'rgba(56, 189, 248, 0.15)';
ctx.lineWidth = 1;
for (let r = 1; r <= 3; r++) {
ctx.beginPath();
ctx.arc(cx, cy, (maxRadius / 3) * r, 0, Math.PI * 2);
ctx.stroke();
}
const totalChannels = 26;
const stepAngle = (Math.PI * 2) / totalChannels;
ctx.beginPath();
ctx.strokeStyle = autoSequenceMode === 'REVERSAL_26D_1D' ? '#f43f5e' : '#38bdf8';
ctx.lineWidth = 1.5;
ctx.fillStyle = autoSequenceMode === 'REVERSAL_26D_1D' ? 'rgba(244, 63, 94, 0.15)' : 'rgba(56, 189, 248, 0.12)';
let firstPoint = true;
for (let k = 0; k < totalChannels; k++) {
const angle = k * stepAngle - Math.PI / 2;
const freq = channelFreqs[k] || 0.01;
const normRadius = Math.min(maxRadius, (freq / 12.0) * maxRadius);
const vx = cx + Math.cos(angle) * normRadius;
const vy = cy + Math.sin(angle) * normRadius;
if (k < activeDim) {
if (firstPoint) {
ctx.moveTo(vx, vy);
firstPoint = false;
} else {
ctx.lineTo(vx, vy);
}
}
// Vector individual
ctx.save();
ctx.beginPath();
let isActive = k < activeDim;
if (isActive) {
ctx.strokeStyle = (k % 2 === 0) ? 'rgba(56, 189, 248, 0.5)' : 'rgba(244, 63, 94, 0.5)';
} else {
ctx.strokeStyle = 'rgba(71, 85, 105, 0.15)';
}
ctx.moveTo(cx, cy);
ctx.lineTo(vx, vy);
ctx.stroke();
// Nodo terminal
ctx.fillStyle = isActive ? ((k % 2 === 0) ? '#38bdf8' : '#f43f5e') : '#334155';
ctx.beginPath();
ctx.arc(vx, vy, isActive ? 2.5 : 1.0, 0, Math.PI * 2);
ctx.fill();
if (k % 2 === 0 || activeDim <= 11) {
const tx = cx + Math.cos(angle) * (maxRadius + 11);
const ty = cy + Math.sin(angle) * (maxRadius + 11);
ctx.fillStyle = isActive ? 'rgba(226, 232, 240, 0.6)' : 'rgba(71, 85, 105, 0.3)';
ctx.font = '7px monospace';
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.fillText(`C${k+1}`, tx, ty);
}
ctx.restore();
}
ctx.closePath();
ctx.fill();
ctx.stroke();
// Centro fasorial
ctx.fillStyle = reversalZeroFactor < 0.1 ? '#f43f5e' : '#ffffff';
ctx.beginPath();
ctx.arc(cx, cy, 3, 0, Math.PI * 2);
ctx.fill();
}
// --- 8. LÓGICA DE CONTROL Y MACRO-SECUENCIAS VECTORIALES ---
const rangeSweep = document.getElementById('rangeSweep');
const lblValR = document.getElementById('lblValR');
const valDim = document.getElementById('valDim');
const valMatter = document.getElementById('valMatter');
const valAntimatter = document.getElementById('valAntimatter');
const valFock = document.getElementById('valFock');
const btnAuto = document.getElementById('btnAuto');
const btnReset = document.getElementById('btnReset');
const algebraLog = document.getElementById('algebra-log');
const menuDim = document.getElementById('menu-dim');
function actualizarDimensionUI(dimSize, keyName) {
currentDimSize = dimSize;
selectedDimKey = keyName;
menuDim.value = keyName;
document.getElementById('hud-title').innerText = `Inspección Factorial Fuente (${keyName})`;
document.getElementById('hud-dim-tag').innerText = `${currentDimSize}x${currentDimSize}`;
document.getElementById('vector-hud-tag').innerText = `${currentDimSize} Canales`;
generarMatrizHTML(currentDimSize);
reconstruirEscena3D(currentDimSize);
}
function cambiarDimensionManual(val) {
autoSequenceMode = 'NONE';
reversalZeroFactor = 1.0;
let size = 26;
if (val === '1D') size = 1;
else if (val === '5D') size = 5;
else if (val === '11D') size = 11;
else if (val === '15D') size = 15;
else if (val === '26D') size = 26;
actualizarDimensionUI(size, val);
updateSystemState(parseFloat(rangeSweep.value));
algebraLog.innerHTML = `[${val}] Dimensión fijada manualmente a ${currentDimSize}x${currentDimSize}.`;
}
function iniciarSecuenciaForward() {
autoSequenceMode = 'FORWARD_5D_26D';
sequenceProgress = 0;
reversalZeroFactor = 1.0;
document.getElementById('status-badge').innerText = "Macro: Secuencia 5D → 26D";
document.getElementById('status-badge').style.color = '#38bdf8';
algebraLog.innerHTML = `[SECUENCIA] Iniciando barrido armónico vectorial progresivo desde 5D hasta 26D...`;
}
function iniciarSecuenciaReversal() {
autoSequenceMode = 'REVERSAL_26D_1D';
sequenceProgress = 0;
reversalZeroFactor = 1.0;
document.getElementById('status-badge').innerText = "Macro: Reversal 26D → 1D = 0";
document.getElementById('status-badge').style.color = '#f43f5e';
algebraLog.innerHTML = `[REVERSAL] Ejecutando reversión topológica 26D → 1D con extinción de campo a cero.`;
}
function procesarMacroSecuencias(delta) {
if (autoSequenceMode === 'FORWARD_5D_26D') {
sequenceProgress += delta * 0.25; // Transición gradual
let rVal = -0.5 + Math.sin(sequenceProgress * Math.PI) * 0.5;
rangeSweep.value = rVal.toFixed(3);
if (sequenceProgress < 0.25) {
if (currentDimSize !== 5) actualizarDimensionUI(5, '5D');
} else if (sequenceProgress < 0.50) {
if (currentDimSize !== 11) actualizarDimensionUI(11, '11D');
} else if (sequenceProgress < 0.75) {
if (currentDimSize !== 15) actualizarDimensionUI(15, '15D');
} else if (sequenceProgress < 1.0) {
if (currentDimSize !== 26) actualizarDimensionUI(26, '26D');
} else {
autoSequenceMode = 'NONE';
document.getElementById('status-badge').innerText = "Fase: 26D Alcanzado";
algebraLog.innerHTML = `[SECUENCIA COMPLETE] Acoplamiento pleno en 26D completado.`;
}
updateSystemState(parseFloat(rangeSweep.value));
} else if (autoSequenceMode === 'REVERSAL_26D_1D') {
sequenceProgress += delta * 0.2;
if (sequenceProgress < 0.25) {
if (currentDimSize !== 26) actualizarDimensionUI(26, '26D');
reversalZeroFactor = 1.0 - (sequenceProgress / 0.25) * 0.2;
} else if (sequenceProgress < 0.50) {
if (currentDimSize !== 15) actualizarDimensionUI(15, '15D');
reversalZeroFactor = 0.8 - ((sequenceProgress - 0.25) / 0.25) * 0.3;
} else if (sequenceProgress < 0.75) {
if (currentDimSize !== 11) actualizarDimensionUI(11, '11D');
reversalZeroFactor = 0.5 - ((sequenceProgress - 0.75) / 0.25) * 0.3;
} else if (sequenceProgress < 0.95) {
if (currentDimSize !== 5) actualizarDimensionUI(5, '5D');
reversalZeroFactor = 0.2 - ((sequenceProgress - 0.75) / 0.20) * 0.18;
} else if (sequenceProgress <= 1.2) {
if (currentDimSize !== 1) actualizarDimensionUI(1, '1D');
// Extinción total al llegar a 1D = 0
reversalZeroFactor = Math.max(0.0, 0.02 - (sequenceProgress - 0.95) * 0.1);
} else {
autoSequenceMode = 'NONE';
reversalZeroFactor = 0.0;
document.getElementById('status-badge').innerText = "Fase: Colapso 1D = 0";
algebraLog.innerHTML = `[REVERSAL COMPLETE] Colapso total alcanzado: Matriz nula en 1D = 0.`;
}
updateSystemState(parseFloat(rangeSweep.value));
}
}
function updateSystemState(r) {
lblValR.innerText = r.toFixed(3);
let energyMatter = (1.2517 + Math.cosh(Math.abs(r) * 2.5) * 0.35 + Math.sin(r * 10) * 0.05) * reversalZeroFactor;
let energyAntimatter = (1.0278 + Math.sinh(Math.abs(r) * 2.5) * 0.35 - Math.cos(r * 10) * 0.05) * reversalZeroFactor;
valMatter.innerText = energyMatter.toFixed(4);
valAntimatter.innerText = energyAntimatter.toFixed(4);
if (reversalZeroFactor === 0) {
valFock.innerText = "0.0000 (Singularidad Extinta)";
valFock.style.color = "#f43f5e";
valDim.innerText = "1D = 0 (Nulo)";
valDim.style.color = "#f43f5e";
} else {
let isResonance = Math.abs(r - (-0.25)) < 0.01 || Math.abs(r - (-0.42)) < 0.01;
if (isResonance) {
valFock.innerText = "0.0000 (F=0 Absorbido)";
valFock.style.color = "#38bdf8";
} else {
valFock.innerText = "Equilibrio Dinámico";
valFock.style.color = "#22c55e";
}
if (currentDimSize === 1) {
valDim.innerText = "1D - Colapso a Cero";
valDim.style.color = "#f43f5e";
} else if (r > -0.05) {
valDim.innerText = `${selectedDimKey} - Base Anclaje`;
valDim.style.color = "#fbbf24";
} else if (r >= -0.18) {
valDim.innerText = `${selectedDimKey} - Cero Espectral 1`;
valDim.style.color = "#38bdf8";
} else if (r >= -0.38) {
valDim.innerText = `${selectedDimKey} - Transición Topológica`;
valDim.style.color = "#22c55e";
} else {
valDim.innerText = `${selectedDimKey} - Cierre Bosónico Completo`;
valDim.style.color = "#f43f5e";
}
}
// Deformación de retícula 3D
matrixStates.forEach(bar => {
let dist = Math.sqrt(bar.userData.baseX**2 + bar.userData.baseZ**2);
let waveMod = Math.sin(dist * 0.4 + r * 12);
let heightScale;
if (bar.userData.isEven) {
heightScale = bar.userData.baseHeight * (1.0 + Math.cosh(Math.abs(r) * 2) * energyMatter * 0.3 + waveMod * 0.15) * reversalZeroFactor;
} else {
heightScale = bar.userData.baseHeight * (1.0 + Math.sinh(Math.abs(r) * 2) * energyAntimatter * 0.3 - waveMod * 0.15) * reversalZeroFactor;
}
if (pipelinePhase === 'NON_LINEAR_EXEC') {
let rho = bar.userData.density;
let nonLinearResponse = rho > 0 ? (rho / (1.0 + Math.pow(rho, 2))) * 12.0 : 0.02;
heightScale = Math.max(0.01, nonLinearResponse * reversalZeroFactor);
}
bar.scale.y = Math.max(0.01, heightScale);
});
updateZetaWave(r);
drawNumericMatrix(r);
}
function ejecutarDiracCero() {
pipelinePhase = 'DIRAC_ZERO';
document.getElementById('status-badge').innerText = "Fase: Dirac = 0";
document.getElementById('status-badge').style.color = '#f97316';
algebraLog.innerHTML = `[Dirac = 0] Operador espinorial anulado. Retícula de paridad ajustada a base cero.`;
updateSystemState(parseFloat(rangeSweep.value));
}
function ejecutarFusionFock() {
pipelinePhase = 'FOCK_FUSION';
document.getElementById('status-badge').innerText = "Fase: Fusión de Fock";
document.getElementById('status-badge').style.color = '#3b82f6';
algebraLog.innerHTML = `[Fock Fusion] Operadores bosónicos acoplados con éxito a la matriz fuente &rho;₂₆_D⁽²⁾.`;
updateSystemState(parseFloat(rangeSweep.value));
}
function ejecutarAlgebraNoLineal() {
pipelinePhase = 'NON_LINEAR_EXEC';
document.getElementById('status-badge').innerText = "Fase: Álgebra No Lineal";
document.getElementById('status-badge').style.color = '#10b981';
algebraLog.innerHTML = `[Álgebra No Lineal] Respuesta de solitón f(&rho;) = &rho; / (1 + &rho;²) activada.`;
updateSystemState(parseFloat(rangeSweep.value));
}
function toggleRotacionAutomatica() {
isAutoRotating = !isAutoRotating;
algebraLog.innerHTML = `[Giro 3D] Giro automático: ${isAutoRotating ? 'Activado' : 'Pausado'}.`;
}
rangeSweep.addEventListener('input', (e) => {
updateSystemState(parseFloat(e.target.value));
});
btnAuto.addEventListener('click', () => {
isAutoSweep = !isAutoSweep;
btnAuto.innerText = isAutoSweep ? "Pausar Barrido" : "Barrido r (Auto)";
});
btnReset.addEventListener('click', () => {
isAutoSweep = false;
autoSequenceMode = 'NONE';
reversalZeroFactor = 1.0;
btnAuto.innerText = "Barrido r (Auto)";
rangeSweep.value = 0.0;
actualizarDimensionUI(26, '26D');
updateSystemState(0.0);
algebraLog.innerHTML = `[REINICIO] Sistema restaurado a 26D Plena Matriz Fuente.`;
});
// --- 9. BUCLE PRINCIPAL DE ANIMACIÓN ---
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
let delta = clock.getDelta();
let t = clock.getElapsedTime();
// Procesamiento de macro-secuencias
if (autoSequenceMode !== 'NONE') {
procesarMacroSecuencias(delta);
}
if (isAutoRotating) {
master3DGroup.rotation.y = t * 0.05;
master3DGroup.rotation.x = Math.sin(t * 0.03) * 0.1;
}
if (isAutoSweep && autoSequenceMode === 'NONE') {
let val = parseFloat(rangeSweep.value);
val += 0.0015 * autoSweepDir;
if (val >= 0.0) { val = 0.0; autoSweepDir = -1; }
if (val <= -0.5) { val = -0.5; autoSweepDir = 1; }
rangeSweep.value = val;
updateSystemState(val);
}
// Animación continua de ondas en barras y cuerdas
matrixStates.forEach((bar) => {
let nonLinearFactor = pipelinePhase === 'NON_LINEAR_EXEC' ? 0.25 : 0.1;
let wave = Math.sin(t * 3.0 + bar.userData.phase + bar.userData.indexI * 0.3) * Math.cos(t * 2.0 - bar.userData.indexJ * 0.3);
let currentH = bar.scale.y;
bar.scale.y = Math.max(0.01, (currentH + wave * nonLinearFactor * 0.05) * (reversalZeroFactor > 0 ? 1 : 0));
});
stringsGroup.children.forEach((str, idx) => {
let posAttr = str.geometry.attributes.position;
for (let i = 0; i < posAttr.count; i++) {
let px = posAttr.getX(i);
let soliton = Math.sin(px * 0.4 + t * 4 + idx) / (0.5 + Math.abs(Math.cos(px * 0.1)));
let amp = (pipelinePhase === 'NON_LINEAR_EXEC' ? 1.2 : 0.4) * reversalZeroFactor;
posAttr.setY(i, soliton * amp);
}
posAttr.needsUpdate = true;
});
// 1. Cálculo del Curl global y espacio de fase
calcularCurlYFrecuenciaMatriz(matrixStates, currentDimSize, t);
dibujarEspacioFase(t);
// 2. Extracción espectral y renderizado vectorial polar
const freqs26 = calcularFrecuencias26Canales(matrixStates, currentDimSize, t);
renderizarGraficaVectorial26('vectorCanvas26', freqs26, currentDimSize);
controls.update();
renderer.render(scene, camera);
}
// Inicialización
generarMatrizHTML(26);
reconstruirEscena3D(26);
updateSystemState(0.0);
animate();
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
</script>
</body>
</html>