-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
425 lines (362 loc) · 21.1 KB
/
Copy pathindex.html
File metadata and controls
425 lines (362 loc) · 21.1 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>2026南通二模物理T11思考</title>
<script>
MathJax = { tex: {inlineMath: [['$', '$'], ['\\(', '\\)']]} };
</script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
<style>
body {
display: flex; flex-direction: column; align-items: center; justify-content: center;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #f0f2f5; margin: 0; padding: 20px; box-sizing: border-box;
min-height: 100vh; overflow-x: hidden;
}
.container {
background-color: white; padding: 25px; border-radius: 12px;
box-shadow: 0 10px 40px rgba(0,0,0,0.1); display: flex; flex-direction: column;
gap: 20px; width: 100%; max-width: 1400px; box-sizing: border-box;
}
@media (min-width: 1000px) {
.container { flex-direction: row; align-items: flex-start; justify-content: center; }
}
.canvas-wrapper { display: flex; justify-content: center; align-items: center; width: 100%; min-height: 0; }
@media (min-width: 1000px) {
.canvas-wrapper { flex: 1; justify-content: center; padding-right: 20px; }
}
canvas {
background-color: #ffffff; border: 1px solid #dee2e6; border-radius: 8px;
cursor: grab; width: 100%;
max-width: min(1000px, 75vh);
aspect-ratio: 1 / 1;
touch-action: none; box-shadow: inset 0 0 10px rgba(0,0,0,0.02);
user-select: none; -webkit-user-select: none;
}
canvas:active { cursor: grabbing; }
.sidebar { display: flex; flex-direction: column; width: 100%; }
@media (min-width: 1000px) {
.sidebar { flex: 0 0 380px; padding-left: 20px; border-left: 1px solid #e9ecef;}
}
.tabs { display: flex; border-bottom: 2px solid #dee2e6; margin-bottom: 15px; }
.tab-btn {
flex: 1; padding: 12px; background: none; border: none; border-bottom: 3px solid transparent;
font-size: 15px; font-weight: bold; cursor: pointer; color: #6c757d; transition: 0.2s;
}
.tab-btn:hover { color: #495057; background: #f8f9fa; }
.tab-btn.active { color: #0d6efd; border-bottom-color: #0d6efd; }
.tab-content { display: none; flex-direction: column; gap: 15px; }
.tab-content.active { display: flex; }
.control-group { background: #f8f9fa; padding: 15px; border-radius: 8px; border: 1px solid #e9ecef; display: flex; flex-direction: column; gap: 5px; }
label { font-size: 14px; font-weight: 600; color: #495057; display: flex; justify-content: space-between;}
input[type=range] { width: 100%; cursor: pointer;}
.global-buttons { display: flex; gap: 8px; margin-bottom: 10px;}
button.action-btn { flex: 1; padding: 10px; font-size: 14px; font-weight: bold; cursor: pointer; color: white; border: none; border-radius: 6px; transition: 0.2s; background-color: #0d6efd;}
button.action-btn:hover { background-color: #0b5ed7; }
button.action-btn.play { background-color: #198754; }
button.action-btn.reset { background-color: #ffc107; color: #212529; }
.problem-text { font-size: 14px; line-height: 1.6; color: #333; background: #f8f9fa; padding: 12px; border-radius: 6px; margin: 0; border-left: 4px solid #0d6efd;}
.option-btn {
text-align: left; padding: 12px 15px; font-size: 14px; line-height: 1.4;
background: #fff; border: 1px solid #dee2e6; border-radius: 6px;
cursor: pointer; transition: 0.2s; color: #495057; margin-bottom: 8px;
}
.option-btn:hover { background: #e9ecef; }
.option-btn.selected { background: #e7f1ff; border-color: #0d6efd; color: #084298; font-weight: bold; box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.25);}
.option-btn.correct { background: #d1e7dd; border-color: #198754; color: #0f5132;}
.option-btn.wrong { background: #f8d7da; border-color: #dc3545; color: #842029;}
.explanation-box {
display: none; padding: 15px; background: #fff3cd; border: 1px solid #ffecb5; border-left: 4px solid #ffc107;
border-radius: 6px; font-size: 14px; line-height: 1.6; color: #664d03; margin-top: 5px;
animation: fadeIn 0.3s ease-in-out;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }
.legend div { font-size: 13px; margin-bottom: 6px; display: flex; align-items: center;}
.legend span { display: inline-block; width: 14px; height: 3px; margin-right: 8px; }
</style>
</head>
<body>
<div class="container">
<div class="canvas-wrapper">
<canvas id="simCanvas" width="1000" height="1000"></canvas>
</div>
<div class="sidebar">
<h3 style="margin-top: 0; margin-bottom: 15px; color: #212529; text-align: center;">2026南通二模物理T11思考</h3>
<div class="global-buttons">
<button id="playBtn" class="action-btn play">▶ 开始运动</button>
<button id="resetBtn" class="action-btn reset">↺ 初始位置 (复位)</button>
<button id="clearBtn" class="action-btn" style="background:#dc3545;">🗑 清空轨迹</button>
</div>
<div class="tabs">
<button id="tabSimBtn" class="tab-btn active" onclick="switchTab('sim')">⚙️ 自由探索</button>
<button id="tabProbBtn" class="tab-btn" onclick="switchTab('prob')">📖 原题互动</button>
</div>
<div id="tabSim" class="tab-content active">
<div class="control-group">
<label>转动方向:</label>
<div style="display: flex; gap: 20px; margin-top: 5px;">
<label style="font-weight: normal; cursor: pointer;"><input type="radio" name="direction" value="-1" checked> 逆时针</label>
<label style="font-weight: normal; cursor: pointer;"><input type="radio" name="direction" value="1"> 顺时针</label>
</div>
</div>
<div class="control-group">
<label>小齿轮半径 (r): <span id="rValue">150</span></label>
<input type="range" id="rSlider" min="50" max="280" step="1" value="150">
<small style="color:#6c757d; font-size:12px;">大齿轮固定为 300 (卡尔丹圆 r=150)</small>
</div>
<div class="control-group">
<label>运行速度 ($\omega$): <span id="speedValue">0.008</span></label>
<input type="range" id="speedSlider" min="0.001" max="0.03" step="0.001" value="0.008">
</div>
<div class="control-group legend">
<label style="cursor: pointer; font-weight: normal; margin-bottom: 10px;"><input type="checkbox" id="showVectors" checked> 显示平行四边形矢量合成</label>
<label style="cursor: pointer; font-weight: normal; margin-bottom: 10px;"><input type="checkbox" id="showTrace" checked> 绘制运动轨迹</label>
<label style="cursor: pointer; font-weight: normal; margin-bottom: 10px; color: #dc3545;"><input type="checkbox" id="showAccel"> 显示加速度矢量 $\vec{a}_P$</label>
<div style="margin-top: 10px;">
<div><span style="background-color: #0d6efd;"></span> $\vec{v}_C$ (牵连速度)</div>
<div><span style="background-color: #fd7e14;"></span> $\vec{v}_{P/C}$ (相对速度)</div>
<div><span style="background-color: #198754; height: 4px;"></span> $\vec{v}_P$ (绝对线速度)</div>
<div><span style="background-color: #dc3545; height: 4px;"></span> $\vec{a}_P$ (绝对加速度)</div>
</div>
</div>
</div>
<div id="tabProb" class="tab-content">
<p class="problem-text">
<strong>题目:</strong>小齿轮的直径与大齿轮的半径相等,P为小齿轮边缘上一点。图示时刻小齿轮贴着左下内壁无滑动滚动。以下判断正确的是:
</p>
<button class="option-btn" id="optA" onclick="selectOption('A')">A. 图示时刻点 P 的速度方向指向 O</button>
<button class="option-btn" id="optB" onclick="selectOption('B')">B. 图示时刻点 P 的加速度方向指向 C</button>
<button class="option-btn" id="optC" onclick="selectOption('C')">C. 点 P 的运动周期是点 C 的两倍</button>
<button class="option-btn" id="optD" onclick="selectOption('D')">D. PO 之间的距离越小,点 P 的加速度越大</button>
<div id="explanationBox" class="explanation-box"></div>
</div>
</div>
</div>
<script>
const canvas = document.getElementById('simCanvas');
const ctx = canvas.getContext('2d');
const playBtn = document.getElementById('playBtn');
const resetBtn = document.getElementById('resetBtn');
const clearBtn = document.getElementById('clearBtn');
const rSlider = document.getElementById('rSlider');
const speedSlider = document.getElementById('speedSlider');
const showVectors = document.getElementById('showVectors');
const showTrace = document.getElementById('showTrace');
const showAccel = document.getElementById('showAccel');
const directionRadios = document.getElementsByName('direction');
const explanationBox = document.getElementById('explanationBox');
const optionBtns = document.querySelectorAll('.option-btn');
const width = canvas.width;
const height = canvas.height;
const cx = width / 2;
const cy = height / 2;
const R = 300;
const INITIAL_THETA = Math.PI * 0.75;
let r = parseInt(rSlider.value);
let omega = parseFloat(speedSlider.value);
let theta = INITIAL_THETA;
let phi_0 = 0;
let isPlaying = false;
let tracePath = [];
let isDraggingP = false;
let currentPx = 0, currentPy = 0;
function switchTab(tabId) {
document.getElementById('tabSim').classList.remove('active');
document.getElementById('tabProb').classList.remove('active');
document.getElementById('tabSimBtn').classList.remove('active');
document.getElementById('tabProbBtn').classList.remove('active');
if(tabId === 'sim') {
document.getElementById('tabSim').classList.add('active');
document.getElementById('tabSimBtn').classList.add('active');
explanationBox.style.display = 'none';
optionBtns.forEach(btn => btn.className = 'option-btn');
} else {
document.getElementById('tabProb').classList.add('active');
document.getElementById('tabProbBtn').classList.add('active');
rSlider.value = 150;
updateParams();
resetToProblemState();
}
}
function getDirection() {
for (const radio of directionRadios) if (radio.checked) return parseInt(radio.value);
return -1;
}
function resetToProblemState() {
isPlaying = false;
playBtn.innerText = "▶ 开始运动"; playBtn.style.backgroundColor = "#198754"; playBtn.style.color = "#fff";
theta = INITIAL_THETA;
phi_0 = 0;
r = 150;
tracePath = [];
showVectors.checked = true;
showAccel.checked = false;
directionRadios[0].checked = true;
drawFrame();
}
function selectOption(opt) {
optionBtns.forEach(btn => btn.className = 'option-btn');
const selectedBtn = document.getElementById('opt' + opt);
let explHtml = "";
switch(opt) {
case 'A':
selectedBtn.classList.add('selected', 'correct');
resetToProblemState();
explHtml = "<strong>解析 A (正确):</strong>画面已为您定格。接触点是瞬心,结合几何关系可知点 $P$ 轨迹是穿过圆心 $O$ 的直线。目前绿色<strong>速度矢量 $\\vec{v}_P$ 精确沿水平直线指向圆心 $O$</strong>。";
break;
case 'B':
selectedBtn.classList.add('selected', 'wrong');
resetToProblemState();
showAccel.checked = true;
drawFrame();
explHtml = "<strong>解析 B (错误):</strong>画面已定格,并为您绘制了<strong>红色加速度矢量 $\\vec{a}_P$</strong>。点 $P$ 做简谐运动,其加速度总是指向平衡位置(大圆圆心 $O$),而不是指向小圆圆心 $C$。";
break;
case 'C':
selectedBtn.classList.add('selected', 'wrong');
resetToProblemState();
showTrace.checked = true;
isPlaying = true;
playBtn.innerText = "⏸ 暂停运动"; playBtn.style.backgroundColor = "#ffc107"; playBtn.style.color = "#000";
explHtml = "<strong>解析 C (错误):</strong>请观察正在播放的动画。圆心 $C$ 绕 $O$ 旋转一整圈(一个周期)的时间内,点 $P$ 刚好在直线上完成一次从一端到另一端再返回的过程。<strong>两者的周期是相等的</strong>($T_P = T_C$)。";
break;
case 'D':
selectedBtn.classList.add('selected', 'wrong');
resetToProblemState();
showAccel.checked = true;
isPlaying = true;
playBtn.innerText = "⏸ 暂停运动"; playBtn.style.backgroundColor = "#ffc107"; playBtn.style.color = "#000";
explHtml = "<strong>解析 D (错误):</strong>请观察红色的加速度箭头。根据简谐运动 $a = \\omega^2 x$,距离 $PO$ 越小(越靠近中心),受到的回复力越小,<strong>红色的加速度箭头会变得越短</strong>。当到达中心时加速度为零。";
break;
}
explanationBox.innerHTML = explHtml;
explanationBox.style.display = 'block';
if (window.MathJax) { MathJax.typesetPromise([explanationBox]); }
}
rSlider.addEventListener('input', updateParams);
speedSlider.addEventListener('input', updateParams);
for (const radio of directionRadios) radio.addEventListener('change', () => { tracePath = []; if(!isPlaying) drawFrame(); });
showVectors.addEventListener('change', drawFrame);
showAccel.addEventListener('change', drawFrame);
showTrace.addEventListener('change', drawFrame);
clearBtn.addEventListener('click', () => { tracePath = []; if(!isPlaying) drawFrame(); });
resetBtn.addEventListener('click', resetToProblemState);
playBtn.addEventListener('click', () => {
isPlaying = !isPlaying;
if(isPlaying) {
playBtn.innerText = "⏸ 暂停运动"; playBtn.style.backgroundColor = "#ffc107"; playBtn.style.color = "#000";
} else {
playBtn.innerText = "▶ 开始运动"; playBtn.style.backgroundColor = "#198754"; playBtn.style.color = "#fff";
}
});
function getEventPos(e) {
const rect = canvas.getBoundingClientRect();
return {
x: (e.clientX - rect.left) * (canvas.width / rect.width),
y: (e.clientY - rect.top) * (canvas.height / rect.height)
};
}
canvas.addEventListener('pointerdown', function(e) {
const pos = getEventPos(e);
if (Math.hypot(pos.x - currentPx, pos.y - currentPy) < 60) {
isDraggingP = true;
canvas.setPointerCapture(e.pointerId);
if (e.cancelable) e.preventDefault();
}
});
canvas.addEventListener('pointermove', function(e) {
if (!isDraggingP) return;
if (e.cancelable) e.preventDefault();
const pos = getEventPos(e);
const cx_small = cx + (R - r) * Math.cos(theta);
const cy_small = cy + (R - r) * Math.sin(theta);
phi_0 = Math.atan2(pos.y - cy_small, pos.x - cx_small) + ((R - r) / r) * theta;
tracePath = [];
if (!isPlaying) drawFrame();
});
canvas.addEventListener('pointerup', function(e) {
if (isDraggingP) {
isDraggingP = false;
canvas.releasePointerCapture(e.pointerId);
}
});
canvas.addEventListener('pointercancel', function(e) {
isDraggingP = false;
});
function updateParams() {
r = parseInt(rSlider.value);
omega = parseFloat(speedSlider.value);
document.getElementById('rValue').innerText = r;
document.getElementById('speedValue').innerText = omega.toFixed(3);
if(!isDraggingP) tracePath = [];
if(!isPlaying) drawFrame();
}
function drawArrow(fromX, fromY, toX, toY, color, lineWidth = 2) {
if (Math.abs(fromX - toX) < 0.1 && Math.abs(fromY - toY) < 0.1) return;
const headlen = 12; const angle = Math.atan2(toY - fromY, toX - fromX);
ctx.beginPath(); ctx.moveTo(fromX, fromY); ctx.lineTo(toX, toY);
ctx.lineTo(toX - headlen * Math.cos(angle - Math.PI / 6), toY - headlen * Math.sin(angle - Math.PI / 6));
ctx.moveTo(toX, toY); ctx.lineTo(toX - headlen * Math.cos(angle + Math.PI / 6), toY - headlen * Math.sin(angle + Math.PI / 6));
ctx.strokeStyle = color; ctx.lineWidth = lineWidth; ctx.stroke();
}
function drawFrame() {
ctx.clearRect(0, 0, width, height);
ctx.beginPath(); ctx.arc(cx, cy, R, 0, Math.PI * 2); ctx.strokeStyle = '#343a40'; ctx.lineWidth = 3; ctx.stroke();
ctx.beginPath(); ctx.arc(cx, cy, 6, 0, Math.PI * 2); ctx.fillStyle = '#000'; ctx.fill();
ctx.fillText("O", cx - 25, cy + 20); ctx.font = "20px Arial";
const cx_small = cx + (R - r) * Math.cos(theta);
const cy_small = cy + (R - r) * Math.sin(theta);
const dir = getDirection();
const vcx = -(R - r) * (dir * omega) * Math.sin(theta);
const vcy = (R - r) * (dir * omega) * Math.cos(theta);
const alpha = -((R - r) / r) * theta + phi_0;
const omega_rel = -((R - r) / r) * (dir * omega);
currentPx = cx_small + r * Math.cos(alpha);
currentPy = cy_small + r * Math.sin(alpha);
const vpcx = -omega_rel * (currentPy - cy_small);
const vpcy = omega_rel * (currentPx - cx_small);
const vpx = vcx + vpcx; const vpy = vcy + vpcy;
if (isPlaying && !isDraggingP && showTrace.checked) {
tracePath.push({x: currentPx, y: currentPy});
// 数组上限提升至 50000,基本不会再消失了
if (tracePath.length > 50000) tracePath.shift();
}
if (showTrace.checked && tracePath.length > 0) {
ctx.beginPath(); ctx.moveTo(tracePath[0].x, tracePath[0].y);
for (let i = 1; i < tracePath.length; i++) ctx.lineTo(tracePath[i].x, tracePath[i].y);
ctx.strokeStyle = 'rgba(220, 53, 69, 0.4)'; ctx.lineWidth = 3; ctx.stroke();
}
ctx.beginPath(); ctx.arc(cx_small, cy_small, r, 0, Math.PI * 2); ctx.strokeStyle = 'rgba(13, 110, 253, 0.5)'; ctx.lineWidth = 2.5; ctx.stroke();
ctx.beginPath(); ctx.moveTo(cx, cy); ctx.lineTo(cx_small, cy_small); ctx.lineTo(currentPx, currentPy); ctx.strokeStyle = '#adb5bd'; ctx.lineWidth = 1.5; ctx.stroke();
ctx.beginPath(); ctx.arc(cx_small, cy_small, 6, 0, Math.PI * 2); ctx.fillStyle = '#0d6efd'; ctx.fill();
ctx.fillStyle = '#0d6efd'; ctx.fillText("C", cx_small - 25, cy_small + 25);
ctx.beginPath(); ctx.arc(currentPx, currentPy, isDraggingP ? 15 : 10, 0, Math.PI * 2); ctx.fillStyle = isDraggingP ? '#ffc107' : '#198754'; ctx.fill(); ctx.strokeStyle = '#fff'; ctx.lineWidth = 3; ctx.stroke();
ctx.fillStyle = '#198754'; ctx.fillText("P", currentPx + 15, currentPy - 15);
if (showVectors.checked) {
const v_scale = 65;
drawArrow(currentPx, currentPy, currentPx + vcx * v_scale, currentPy + vcy * v_scale, '#0d6efd', 3);
drawArrow(currentPx, currentPy, currentPx + vpcx * v_scale, currentPy + vpcy * v_scale, '#fd7e14', 3);
ctx.beginPath(); ctx.setLineDash([7, 7]);
ctx.moveTo(currentPx + vcx * v_scale, currentPy + vcy * v_scale); ctx.lineTo(currentPx + vpx * v_scale, currentPy + vpy * v_scale);
ctx.moveTo(currentPx + vpcx * v_scale, currentPy + vpcy * v_scale); ctx.lineTo(currentPx + vpx * v_scale, currentPy + vpy * v_scale);
ctx.strokeStyle = 'rgba(173, 181, 189, 0.9)'; ctx.lineWidth = 2; ctx.stroke(); ctx.setLineDash([]);
drawArrow(currentPx, currentPy, currentPx + vpx * v_scale, currentPy + vpy * v_scale, '#198754', 5);
}
if (showAccel.checked) {
const a_scale = 0.6;
const ax = cx - currentPx;
const ay = cy - currentPy;
drawArrow(currentPx, currentPy, currentPx + ax * a_scale, currentPy + ay * a_scale, '#dc3545', 5);
}
}
function loop() {
if (isPlaying && !isDraggingP) theta += getDirection() * omega;
drawFrame();
requestAnimationFrame(loop);
}
resetToProblemState();
loop();
</script>
</body>
</html>