adnannovus commited on
Commit
1a8e9f2
·
verified ·
1 Parent(s): cfbea2e

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +110 -162
index.html CHANGED
@@ -3,7 +3,7 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Advanced Particle Accelerator</title>
7
  <style>
8
  * {
9
  margin: 0;
@@ -40,6 +40,7 @@
40
  padding: 15px;
41
  border: 1px solid #00ff00;
42
  z-index: 100;
 
43
  }
44
 
45
  button {
@@ -57,18 +58,6 @@
57
  background: #00ff00;
58
  color: #000;
59
  }
60
-
61
- .separator {
62
- height: 1px;
63
- background: #00ff00;
64
- margin: 10px 0;
65
- }
66
-
67
- .detector {
68
- position: fixed;
69
- border: 1px solid #00ff00;
70
- pointer-events: none;
71
- }
72
  </style>
73
  </head>
74
  <body>
@@ -76,19 +65,18 @@
76
  <canvas id="effectCanvas"></canvas>
77
 
78
  <div class="controls">
79
- <button onclick="initializeAccelerator()">Initialize</button>
80
  <button onclick="injectParticles()">Inject Particles</button>
81
  <button onclick="toggleAcceleration()">Toggle Acceleration</button>
82
  <button onclick="toggleCollisions()">Toggle Collisions</button>
83
- <div class="separator"></div>
84
- <div>Energy Level: <span id="energyLevel">0</span> TeV</div>
85
- <div>Collisions: <span id="collisionCount">0</span></div>
86
- <div>Particles: <span id="particleCount">0</span></div>
87
  </div>
88
 
89
  <div class="data">
90
- <div>Detector Data:</div>
91
- <div id="detectorData"></div>
 
 
 
92
  </div>
93
 
94
  <script>
@@ -107,82 +95,87 @@
107
  resizeCanvases();
108
  window.addEventListener('resize', resizeCanvases);
109
 
110
- // Simulation state
 
 
111
  const state = {
112
  particles: [],
113
- detectors: [],
114
  collisions: [],
115
  acceleratorActive: false,
116
  collisionsEnabled: false,
117
  collisionCount: 0,
118
- maxEnergy: 13, // TeV
119
  centerX: window.innerWidth / 2,
120
  centerY: window.innerHeight / 2,
121
- ringRadius: Math.min(window.innerWidth, window.innerHeight) * 0.35,
122
- time: 0
123
  };
124
 
125
  class Particle {
126
  constructor(clockwise = true) {
127
  this.clockwise = clockwise;
128
  this.angle = clockwise ? 0 : Math.PI;
129
- this.energy = 0.1;
130
- this.velocity = 0.01;
 
131
  this.radius = state.ringRadius;
132
- this.size = 3;
133
  this.trail = [];
134
- this.maxTrailLength = 50;
135
  this.collided = false;
136
  this.updatePosition();
137
- this.detectedBy = new Set();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  }
139
 
140
  updatePosition() {
 
 
 
 
141
  this.x = state.centerX + Math.cos(this.angle) * this.radius;
142
  this.y = state.centerY + Math.sin(this.angle) * this.radius;
143
-
144
  this.trail.push({ x: this.x, y: this.y });
145
  if (this.trail.length > this.maxTrailLength) {
146
  this.trail.shift();
147
  }
148
  }
149
 
150
- accelerate() {
151
- if (state.acceleratorActive && this.energy < state.maxEnergy) {
152
- this.energy += 0.01;
153
- this.velocity = 0.01 + (this.energy / state.maxEnergy) * 0.04;
154
- }
155
- }
156
-
157
  update() {
158
- this.accelerate();
159
- this.angle += this.clockwise ? this.velocity : -this.velocity;
160
  this.updatePosition();
161
- this.checkDetectors();
162
- }
163
-
164
- checkDetectors() {
165
- state.detectors.forEach(detector => {
166
- if (!this.detectedBy.has(detector) &&
167
- this.x > detector.x &&
168
- this.x < detector.x + detector.width &&
169
- this.y > detector.y &&
170
- this.y < detector.y + detector.height) {
171
-
172
- this.detectedBy.add(detector);
173
- detector.detect(this);
174
- }
175
- });
176
  }
177
 
178
  draw(ctx) {
179
- // Draw trail
 
 
 
 
180
  ctx.beginPath();
181
- ctx.strokeStyle = this.clockwise ?
182
- `rgba(0, ${155 + this.energy * 10}, 255, 0.5)` :
183
- `rgba(255, ${155 + this.energy * 10}, 0, 0.5)`;
184
- ctx.lineWidth = 2;
185
-
186
  for (let i = 0; i < this.trail.length; i++) {
187
  if (i === 0) {
188
  ctx.moveTo(this.trail[i].x, this.trail[i].y);
@@ -192,81 +185,61 @@
192
  }
193
  ctx.stroke();
194
 
195
- // Draw particle
 
196
  ctx.beginPath();
197
- ctx.fillStyle = this.clockwise ? '#00ffff' : '#ff9900';
198
- ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
199
  ctx.fill();
200
 
201
- // Energy indicator
202
  ctx.beginPath();
203
- ctx.strokeStyle = `rgba(255, 255, 255, ${this.energy / state.maxEnergy})`;
204
- ctx.arc(this.x, this.y, this.size + 3, 0, Math.PI * 2);
205
  ctx.stroke();
206
  }
207
  }
208
 
209
- class Detector {
210
- constructor(x, y, width, height) {
211
- this.x = x;
212
- this.y = y;
213
- this.width = width;
214
- this.height = height;
215
- this.detections = [];
216
- this.element = document.createElement('div');
217
- this.element.className = 'detector';
218
- this.element.style.left = `${x}px`;
219
- this.element.style.top = `${y}px`;
220
- this.element.style.width = `${width}px`;
221
- this.element.style.height = `${height}px`;
222
- document.body.appendChild(this.element);
223
- }
224
-
225
- detect(particle) {
226
- this.detections.push({
227
- time: state.time,
228
- energy: particle.energy,
229
- direction: particle.clockwise ? 'clockwise' : 'counterclockwise'
230
  });
231
- this.element.style.backgroundColor = 'rgba(0, 255, 0, 0.2)';
232
- setTimeout(() => {
233
- this.element.style.backgroundColor = 'transparent';
234
- }, 100);
235
  }
236
  }
237
 
238
- function createDetectors() {
239
- const detectorSize = 40;
240
- const positions = [
241
- { angle: 0, label: 'East' },
242
- { angle: Math.PI / 2, label: 'South' },
243
- { angle: Math.PI, label: 'West' },
244
- { angle: 3 * Math.PI / 2, label: 'North' }
245
- ];
246
-
247
- positions.forEach(pos => {
248
- const x = state.centerX + Math.cos(pos.angle) * state.ringRadius - detectorSize/2;
249
- const y = state.centerY + Math.sin(pos.angle) * state.ringRadius - detectorSize/2;
250
- state.detectors.push(new Detector(x, y, detectorSize, detectorSize));
251
- });
252
- }
253
-
254
  function drawAccelerator() {
 
255
  mainCtx.beginPath();
256
- mainCtx.strokeStyle = '#333';
257
  mainCtx.lineWidth = 20;
258
  mainCtx.arc(state.centerX, state.centerY, state.ringRadius, 0, Math.PI * 2);
259
  mainCtx.stroke();
260
 
261
- // Energy sections
262
- for (let i = 0; i < 8; i++) {
263
- const angle = (i / 8) * Math.PI * 2;
264
- mainCtx.beginPath();
265
- mainCtx.strokeStyle = '#0f0';
266
- mainCtx.lineWidth = 2;
267
  const x = state.centerX + Math.cos(angle) * state.ringRadius;
268
  const y = state.centerY + Math.sin(angle) * state.ringRadius;
269
- mainCtx.arc(x, y, 10, 0, Math.PI * 2);
 
 
 
 
270
  mainCtx.stroke();
271
  }
272
  }
@@ -284,8 +257,9 @@
284
  const dy = p1.y - p2.y;
285
  const distance = Math.sqrt(dx * dx + dy * dy);
286
 
287
- if (distance < 10 && p1.energy > 1 && p2.energy > 1) {
288
- createCollisionEffect(p1.x, p1.y, p1.energy + p2.energy);
 
289
  p1.collided = true;
290
  p2.collided = true;
291
  state.collisionCount++;
@@ -297,30 +271,13 @@
297
  state.particles = state.particles.filter(p => !p.collided);
298
  }
299
 
300
- function createCollisionEffect(x, y, energy) {
301
- const particles = 50;
302
- const speed = 5;
303
-
304
- for (let i = 0; i < particles; i++) {
305
- const angle = (i / particles) * Math.PI * 2;
306
- const velocity = {
307
- x: Math.cos(angle) * speed * (Math.random() + 0.5),
308
- y: Math.sin(angle) * speed * (Math.random() + 0.5)
309
- };
310
- state.collisions.push({
311
- x, y,
312
- velocity,
313
- life: 1,
314
- color: `hsl(${Math.random() * 60 + 30}, 100%, 50%)`
315
- });
316
- }
317
- }
318
-
319
  function updateCollisionEffects() {
320
  state.collisions.forEach(p => {
321
  p.x += p.velocity.x;
322
  p.y += p.velocity.y;
323
  p.life -= 0.02;
 
 
324
  });
325
 
326
  state.collisions = state.collisions.filter(p => p.life > 0);
@@ -332,32 +289,20 @@
332
  state.collisions.forEach(p => {
333
  effectCtx.beginPath();
334
  effectCtx.fillStyle = p.color.replace(')', `, ${p.life})`);
335
- effectCtx.arc(p.x, p.y, 2, 0, Math.PI * 2);
336
  effectCtx.fill();
337
  });
338
  }
339
 
340
  function updateUI() {
341
- document.getElementById('energyLevel').textContent =
342
- state.particles.length > 0 ?
343
- state.particles[0].energy.toFixed(2) : '0.00';
344
- document.getElementById('collisionCount').textContent = state.collisionCount;
 
 
345
  document.getElementById('particleCount').textContent = state.particles.length;
346
-
347
- // Update detector data
348
- const detectorData = state.detectors.map((detector, i) => {
349
- const recent = detector.detections.slice(-3);
350
- return `Detector ${i + 1}: ${recent.length} recent detections`;
351
- }).join('<br>');
352
- document.getElementById('detectorData').innerHTML = detectorData;
353
- }
354
-
355
- // Control functions
356
- function initializeAccelerator() {
357
- state.particles = [];
358
- state.collisions = [];
359
- state.collisionCount = 0;
360
- state.detectors.forEach(d => d.detections = []);
361
  }
362
 
363
  function injectParticles() {
@@ -373,10 +318,14 @@
373
  state.collisionsEnabled = !state.collisionsEnabled;
374
  }
375
 
376
- function animate() {
377
- state.time++;
 
 
 
378
 
379
- // Clear main canvas
 
380
  mainCtx.fillStyle = 'rgba(0, 0, 0, 0.1)';
381
  mainCtx.fillRect(0, 0, mainCanvas.width, mainCanvas.height);
382
 
@@ -395,8 +344,7 @@
395
  requestAnimationFrame(animate);
396
  }
397
 
398
- // Initialize and start
399
- createDetectors();
400
  animate();
401
  </script>
402
  </body>
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Relativistic Particle Accelerator</title>
7
  <style>
8
  * {
9
  margin: 0;
 
40
  padding: 15px;
41
  border: 1px solid #00ff00;
42
  z-index: 100;
43
+ min-width: 200px;
44
  }
45
 
46
  button {
 
58
  background: #00ff00;
59
  color: #000;
60
  }
 
 
 
 
 
 
 
 
 
 
 
 
61
  </style>
62
  </head>
63
  <body>
 
65
  <canvas id="effectCanvas"></canvas>
66
 
67
  <div class="controls">
 
68
  <button onclick="injectParticles()">Inject Particles</button>
69
  <button onclick="toggleAcceleration()">Toggle Acceleration</button>
70
  <button onclick="toggleCollisions()">Toggle Collisions</button>
71
+ <button onclick="clearParticles()">Clear</button>
 
 
 
72
  </div>
73
 
74
  <div class="data">
75
+ <div>Energy: <span id="energyLevel">0</span> TeV</div>
76
+ <div>Velocity: <span id="velocityC">0</span>c</div>
77
+ <div>Particles: <span id="particleCount">0</span></div>
78
+ <div>Collisions: <span id="collisionCount">0</span></div>
79
+ <div>Time Dilation: <span id="timeDilation">1</span>x</div>
80
  </div>
81
 
82
  <script>
 
95
  resizeCanvases();
96
  window.addEventListener('resize', resizeCanvases);
97
 
98
+ const SPEED_OF_LIGHT = 299792458; // m/s
99
+ const ELECTRON_MASS = 9.1093837015e-31; // kg
100
+
101
  const state = {
102
  particles: [],
 
103
  collisions: [],
104
  acceleratorActive: false,
105
  collisionsEnabled: false,
106
  collisionCount: 0,
 
107
  centerX: window.innerWidth / 2,
108
  centerY: window.innerHeight / 2,
109
+ ringRadius: Math.min(window.innerWidth, window.innerHeight) * 0.35
 
110
  };
111
 
112
  class Particle {
113
  constructor(clockwise = true) {
114
  this.clockwise = clockwise;
115
  this.angle = clockwise ? 0 : Math.PI;
116
+ this.energy = 0.1; // TeV
117
+ this.mass = ELECTRON_MASS;
118
+ this.velocity = 0.1; // As fraction of c
119
  this.radius = state.ringRadius;
 
120
  this.trail = [];
121
+ this.maxTrailLength = 100;
122
  this.collided = false;
123
  this.updatePosition();
124
+ }
125
+
126
+ // Relativistic calculations
127
+ get gamma() {
128
+ return 1 / Math.sqrt(1 - this.velocity * this.velocity);
129
+ }
130
+
131
+ get timeDilation() {
132
+ return this.gamma;
133
+ }
134
+
135
+ get relativeVelocity() {
136
+ return this.velocity * SPEED_OF_LIGHT;
137
+ }
138
+
139
+ accelerate(deltaTime) {
140
+ if (state.acceleratorActive) {
141
+ // Relativistic acceleration
142
+ const acceleration = 0.001 * (1 - this.velocity);
143
+ this.velocity = Math.min(0.9999999999, this.velocity + acceleration);
144
+
145
+ // Energy calculation in TeV
146
+ this.energy = (this.gamma - 1) * 0.511e-3 * 1000;
147
+ }
148
  }
149
 
150
  updatePosition() {
151
+ // Relativistic motion
152
+ const angleChange = (this.velocity * 0.1) / this.gamma;
153
+ this.angle += this.clockwise ? angleChange : -angleChange;
154
+
155
  this.x = state.centerX + Math.cos(this.angle) * this.radius;
156
  this.y = state.centerY + Math.sin(this.angle) * this.radius;
157
+
158
  this.trail.push({ x: this.x, y: this.y });
159
  if (this.trail.length > this.maxTrailLength) {
160
  this.trail.shift();
161
  }
162
  }
163
 
 
 
 
 
 
 
 
164
  update() {
165
+ this.accelerate(1/60);
 
166
  this.updatePosition();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
  }
168
 
169
  draw(ctx) {
170
+ // Draw relativistic trail with Doppler effect
171
+ const hue = this.clockwise ?
172
+ 240 - (this.velocity * 240) : // Blue shifting
173
+ 60 + (this.velocity * 60); // Red shifting
174
+
175
  ctx.beginPath();
176
+ ctx.strokeStyle = `hsla(${hue}, 100%, 50%, 0.5)`;
177
+ ctx.lineWidth = 2 + (this.velocity * 3);
178
+
 
 
179
  for (let i = 0; i < this.trail.length; i++) {
180
  if (i === 0) {
181
  ctx.moveTo(this.trail[i].x, this.trail[i].y);
 
185
  }
186
  ctx.stroke();
187
 
188
+ // Draw particle with relativistic effects
189
+ const particleSize = 3 + (this.velocity * 2);
190
  ctx.beginPath();
191
+ ctx.fillStyle = `hsl(${hue}, 100%, 50%)`;
192
+ ctx.arc(this.x, this.y, particleSize, 0, Math.PI * 2);
193
  ctx.fill();
194
 
195
+ // Energy aura
196
  ctx.beginPath();
197
+ ctx.strokeStyle = `rgba(255, 255, 255, ${this.velocity})`;
198
+ ctx.arc(this.x, this.y, particleSize + 3, 0, Math.PI * 2);
199
  ctx.stroke();
200
  }
201
  }
202
 
203
+ function createCollisionEffect(x, y, energy) {
204
+ const particleCount = Math.floor(50 + energy * 10);
205
+ const baseSpeed = 5 + energy;
206
+
207
+ for (let i = 0; i < particleCount; i++) {
208
+ const angle = (i / particleCount) * Math.PI * 2 + Math.random() * 0.5;
209
+ const speed = baseSpeed * (0.5 + Math.random());
210
+ const velocity = {
211
+ x: Math.cos(angle) * speed,
212
+ y: Math.sin(angle) * speed
213
+ };
214
+
215
+ state.collisions.push({
216
+ x, y,
217
+ velocity,
218
+ life: 1,
219
+ energy: energy * Math.random(),
220
+ color: `hsl(${30 + Math.random() * 60}, 100%, 50%)`
 
 
 
221
  });
 
 
 
 
222
  }
223
  }
224
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225
  function drawAccelerator() {
226
+ // Draw main ring
227
  mainCtx.beginPath();
228
+ mainCtx.strokeStyle = '#111';
229
  mainCtx.lineWidth = 20;
230
  mainCtx.arc(state.centerX, state.centerY, state.ringRadius, 0, Math.PI * 2);
231
  mainCtx.stroke();
232
 
233
+ // Draw acceleration segments
234
+ for (let i = 0; i < 16; i++) {
235
+ const angle = (i / 16) * Math.PI * 2;
 
 
 
236
  const x = state.centerX + Math.cos(angle) * state.ringRadius;
237
  const y = state.centerY + Math.sin(angle) * state.ringRadius;
238
+
239
+ mainCtx.beginPath();
240
+ mainCtx.strokeStyle = state.acceleratorActive ? '#0f0' : '#030';
241
+ mainCtx.lineWidth = 2;
242
+ mainCtx.arc(x, y, 5, 0, Math.PI * 2);
243
  mainCtx.stroke();
244
  }
245
  }
 
257
  const dy = p1.y - p2.y;
258
  const distance = Math.sqrt(dx * dx + dy * dy);
259
 
260
+ if (distance < 10) {
261
+ const totalEnergy = p1.energy + p2.energy;
262
+ createCollisionEffect(p1.x, p1.y, totalEnergy);
263
  p1.collided = true;
264
  p2.collided = true;
265
  state.collisionCount++;
 
271
  state.particles = state.particles.filter(p => !p.collided);
272
  }
273
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
274
  function updateCollisionEffects() {
275
  state.collisions.forEach(p => {
276
  p.x += p.velocity.x;
277
  p.y += p.velocity.y;
278
  p.life -= 0.02;
279
+ p.velocity.x *= 0.98;
280
+ p.velocity.y *= 0.98;
281
  });
282
 
283
  state.collisions = state.collisions.filter(p => p.life > 0);
 
289
  state.collisions.forEach(p => {
290
  effectCtx.beginPath();
291
  effectCtx.fillStyle = p.color.replace(')', `, ${p.life})`);
292
+ effectCtx.arc(p.x, p.y, 2 + p.energy/10, 0, Math.PI * 2);
293
  effectCtx.fill();
294
  });
295
  }
296
 
297
  function updateUI() {
298
+ const particle = state.particles[0];
299
+ if (particle) {
300
+ document.getElementById('energyLevel').textContent = particle.energy.toFixed(2);
301
+ document.getElementById('velocityC').textContent = particle.velocity.toFixed(9);
302
+ document.getElementById('timeDilation').textContent = particle.gamma.toFixed(2);
303
+ }
304
  document.getElementById('particleCount').textContent = state.particles.length;
305
+ document.getElementById('collisionCount').textContent = state.collisionCount;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
306
  }
307
 
308
  function injectParticles() {
 
318
  state.collisionsEnabled = !state.collisionsEnabled;
319
  }
320
 
321
+ function clearParticles() {
322
+ state.particles = [];
323
+ state.collisions = [];
324
+ state.collisionCount = 0;
325
+ }
326
 
327
+ function animate() {
328
+ // Clear main canvas with trail effect
329
  mainCtx.fillStyle = 'rgba(0, 0, 0, 0.1)';
330
  mainCtx.fillRect(0, 0, mainCanvas.width, mainCanvas.height);
331
 
 
344
  requestAnimationFrame(animate);
345
  }
346
 
347
+ // Start animation
 
348
  animate();
349
  </script>
350
  </body>