index.html 124 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399
  1. <!DOCTYPE html>
  2. <html lang="ru">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Электромагнитный канал утечки информации</title>
  7. <link rel="preconnect" href="https://fonts.googleapis.com">
  8. <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  9. <link href="https://fonts.googleapis.com/css2?family=Oswald:wght@400;500;700&family=PT+Serif:ital,wght@0,400;0,700;1,400&family=Roboto+Mono:wght@400;700&display=swap" rel="stylesheet">
  10. <style>
  11. :root {
  12. --paper: #f2e9d6;
  13. --paper-dark: #e6dac2;
  14. --ink: #1a2a4a;
  15. --ink-light: #4a5a7a;
  16. --red: #8b1a1a;
  17. --red-light: #b84242;
  18. --blue: #1a4a6a;
  19. --blue-light: #3a7aa0;
  20. --green: #2a5a2a;
  21. --line: #c4b8a0;
  22. }
  23. * { box-sizing: border-box; }
  24. html, body { margin: 0; padding: 0; }
  25. body {
  26. background:
  27. repeating-linear-gradient(0deg, transparent, transparent 23px, rgba(0,0,0,0.03) 24px),
  28. var(--paper);
  29. color: var(--ink);
  30. font-family: 'PT Serif', Georgia, serif;
  31. min-height: 100vh;
  32. display: flex;
  33. justify-content: center;
  34. padding: 20px;
  35. line-height: 1.6;
  36. }
  37. .app {
  38. width: 100%;
  39. max-width: 900px;
  40. background: var(--paper);
  41. border: 2px solid var(--ink);
  42. box-shadow: 6px 6px 0 rgba(26,42,74,0.15);
  43. position: relative;
  44. }
  45. .app::before {
  46. content: '';
  47. position: absolute;
  48. inset: 8px;
  49. border: 1px solid var(--line);
  50. pointer-events: none;
  51. z-index: 1;
  52. }
  53. .header {
  54. padding: 20px 30px 15px;
  55. border-bottom: 2px solid var(--ink);
  56. position: relative;
  57. z-index: 2;
  58. }
  59. .header-top {
  60. display: flex;
  61. justify-content: space-between;
  62. align-items: baseline;
  63. font-family: 'Roboto Mono', monospace;
  64. font-size: 11px;
  65. letter-spacing: 1px;
  66. text-transform: uppercase;
  67. color: var(--ink-light);
  68. margin-bottom: 8px;
  69. }
  70. .header h1 {
  71. font-family: 'Oswald', sans-serif;
  72. font-weight: 700;
  73. font-size: 28px;
  74. letter-spacing: 1px;
  75. text-transform: uppercase;
  76. margin: 0;
  77. color: var(--ink);
  78. }
  79. .header .sub {
  80. font-family: 'PT Serif', serif;
  81. font-style: italic;
  82. font-size: 14px;
  83. color: var(--ink-light);
  84. margin-top: 4px;
  85. }
  86. .progress {
  87. display: flex;
  88. gap: 3px;
  89. padding: 12px 30px;
  90. background: var(--paper-dark);
  91. border-bottom: 1px solid var(--line);
  92. position: relative;
  93. z-index: 2;
  94. }
  95. .progress-step {
  96. flex: 1;
  97. height: 4px;
  98. background: var(--line);
  99. transition: background 0.3s;
  100. }
  101. .progress-step.done { background: var(--blue); }
  102. .progress-step.current { background: var(--red); }
  103. .content {
  104. padding: 30px;
  105. position: relative;
  106. z-index: 2;
  107. min-height: 400px;
  108. }
  109. .scene { display: none; animation: fadeIn 0.4s ease-out; }
  110. .scene.active { display: block; }
  111. @keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
  112. .scene-num {
  113. font-family: 'Roboto Mono', monospace;
  114. font-size: 11px;
  115. letter-spacing: 2px;
  116. color: var(--red);
  117. text-transform: uppercase;
  118. margin-bottom: 6px;
  119. }
  120. .scene-title {
  121. font-family: 'Oswald', sans-serif;
  122. font-size: 22px;
  123. font-weight: 500;
  124. letter-spacing: 0.5px;
  125. margin: 0 0 16px;
  126. text-transform: uppercase;
  127. }
  128. .scene p {
  129. font-size: 15px;
  130. margin: 0 0 12px;
  131. }
  132. .scene p.lead {
  133. font-size: 16px;
  134. color: var(--ink-light);
  135. font-style: italic;
  136. }
  137. .notebook {
  138. background: #fffef8;
  139. border: 1px solid var(--red);
  140. border-left: 6px solid var(--red);
  141. padding: 16px 20px;
  142. margin: 20px 0;
  143. position: relative;
  144. background-image: repeating-linear-gradient(0deg, transparent, transparent 23px, rgba(139,26,26,0.08) 24px);
  145. }
  146. .notebook::before {
  147. content: 'ЗАПИШИ В ТЕТРАДЬ';
  148. position: absolute;
  149. top: -10px;
  150. left: 12px;
  151. background: var(--red);
  152. color: #fff;
  153. font-family: 'Roboto Mono', monospace;
  154. font-size: 10px;
  155. font-weight: 700;
  156. letter-spacing: 2px;
  157. padding: 2px 8px;
  158. }
  159. .notebook p {
  160. margin: 6px 0;
  161. font-size: 14px;
  162. line-height: 1.7;
  163. }
  164. .notebook p:first-child { margin-top: 4px; }
  165. .notebook strong { color: var(--red); }
  166. .notebook .formula {
  167. font-family: 'Roboto Mono', monospace;
  168. background: rgba(139,26,26,0.08);
  169. padding: 2px 6px;
  170. font-size: 13px;
  171. border-radius: 2px;
  172. }
  173. .viz {
  174. background: #fffef8;
  175. border: 1px solid var(--line);
  176. padding: 16px;
  177. margin: 20px 0;
  178. position: relative;
  179. }
  180. .viz canvas { display: block; width: 100%; }
  181. .viz-caption {
  182. font-family: 'Roboto Mono', monospace;
  183. font-size: 11px;
  184. color: var(--ink-light);
  185. text-align: center;
  186. margin-top: 8px;
  187. letter-spacing: 0.5px;
  188. }
  189. .two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  190. @media (max-width: 640px) { .two-col { grid-template-columns: 1fr; } }
  191. .control-group { margin: 14px 0; }
  192. .control-label {
  193. display: flex;
  194. justify-content: space-between;
  195. font-family: 'Roboto Mono', monospace;
  196. font-size: 12px;
  197. text-transform: uppercase;
  198. letter-spacing: 0.5px;
  199. margin-bottom: 4px;
  200. }
  201. .control-label .val { color: var(--blue); font-weight: 700; }
  202. input[type=range] {
  203. -webkit-appearance: none;
  204. width: 100%;
  205. height: 6px;
  206. background: linear-gradient(to right, var(--line), var(--ink-light));
  207. border-radius: 3px;
  208. outline: none;
  209. margin: 6px 0;
  210. }
  211. input[type=range]::-webkit-slider-thumb {
  212. -webkit-appearance: none;
  213. width: 18px;
  214. height: 18px;
  215. background: var(--red);
  216. border: 2px solid var(--ink);
  217. border-radius: 50%;
  218. cursor: pointer;
  219. }
  220. input[type=range]::-moz-range-thumb {
  221. width: 18px;
  222. height: 18px;
  223. background: var(--red);
  224. border: 2px solid var(--ink);
  225. border-radius: 50%;
  226. cursor: pointer;
  227. }
  228. .indicator {
  229. background: var(--ink);
  230. color: #4af626;
  231. font-family: 'Roboto Mono', monospace;
  232. padding: 10px 16px;
  233. border-radius: 3px;
  234. letter-spacing: 1px;
  235. text-shadow: 0 0 8px rgba(74,246,38,0.6);
  236. margin: 12px 0;
  237. display: flex;
  238. flex-direction: column;
  239. gap: 6px;
  240. }
  241. .indicator .row {
  242. display: flex;
  243. justify-content: space-between;
  244. align-items: baseline;
  245. }
  246. .indicator .main {
  247. font-size: 24px;
  248. font-weight: 700;
  249. }
  250. .indicator .secondary {
  251. font-size: 16px;
  252. opacity: 0.8;
  253. font-weight: 700;
  254. }
  255. .indicator small { font-size: 11px; color: #8aa; letter-spacing: 1px; font-weight: 400; }
  256. .feedback {
  257. background: rgba(26,74,106,0.06);
  258. border-left: 3px solid var(--blue);
  259. padding: 10px 14px;
  260. font-size: 13px;
  261. font-style: italic;
  262. color: var(--ink-light);
  263. margin: 12px 0;
  264. min-height: 40px;
  265. }
  266. .nav {
  267. display: flex;
  268. justify-content: space-between;
  269. align-items: center;
  270. padding: 16px 30px;
  271. border-top: 2px solid var(--ink);
  272. background: var(--paper-dark);
  273. position: relative;
  274. z-index: 2;
  275. }
  276. button {
  277. font-family: 'Oswald', sans-serif;
  278. font-size: 14px;
  279. font-weight: 500;
  280. letter-spacing: 1px;
  281. text-transform: uppercase;
  282. padding: 10px 24px;
  283. border: 2px solid var(--ink);
  284. background: var(--paper);
  285. color: var(--ink);
  286. cursor: pointer;
  287. transition: all 0.15s;
  288. }
  289. button:hover:not(:disabled) { background: var(--ink); color: var(--paper); }
  290. button:disabled { opacity: 0.3; cursor: not-allowed; }
  291. button.primary { background: var(--red); color: #fff; border-color: var(--red); }
  292. button.primary:hover:not(:disabled) { background: var(--red-light); border-color: var(--red-light); }
  293. button.ghost { background: transparent; }
  294. .channel-diagram {
  295. display: flex;
  296. align-items: center;
  297. justify-content: center;
  298. gap: 0;
  299. margin: 24px 0;
  300. flex-wrap: wrap;
  301. }
  302. .channel-block {
  303. background: #fffef8;
  304. border: 2px solid var(--ink);
  305. padding: 12px 20px;
  306. text-align: center;
  307. min-width: 140px;
  308. }
  309. .channel-block .label {
  310. font-family: 'Roboto Mono', monospace;
  311. font-size: 10px;
  312. letter-spacing: 1px;
  313. color: var(--ink-light);
  314. text-transform: uppercase;
  315. margin-bottom: 4px;
  316. }
  317. .channel-block .name {
  318. font-family: 'Oswald', sans-serif;
  319. font-size: 16px;
  320. font-weight: 500;
  321. text-transform: uppercase;
  322. }
  323. .channel-arrow { font-size: 24px; color: var(--red); padding: 0 8px; font-family: 'Roboto Mono', monospace; }
  324. .channel-block.source { border-color: var(--red); }
  325. .channel-block.medium { border-color: var(--blue); }
  326. .channel-block.receiver { border-color: var(--green); }
  327. .mechanisms { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 20px 0; }
  328. @media (max-width: 640px) { .mechanisms { grid-template-columns: 1fr; } }
  329. .mech-card { border: 1px solid var(--line); background: #fffef8; padding: 12px; }
  330. .mech-card .mech-title { font-family: 'Oswald', sans-serif; font-size: 14px; text-transform: uppercase; margin-bottom: 6px; }
  331. .mech-card .mech-env { font-size: 12px; color: var(--ink-light); font-style: italic; }
  332. .mech-card.ind { border-top: 4px solid var(--red); }
  333. .mech-card.cap { border-top: 4px solid var(--blue); }
  334. .mech-card.gal { border-top: 4px solid var(--green); }
  335. .protection-table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 13px; }
  336. .protection-table th {
  337. background: var(--ink); color: var(--paper); padding: 8px 10px; text-align: left;
  338. font-family: 'Oswald', sans-serif; font-weight: 500; text-transform: uppercase; font-size: 12px; letter-spacing: 0.5px;
  339. }
  340. .protection-table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
  341. .protection-table tr:nth-child(even) td { background: rgba(0,0,0,0.02); }
  342. .question { margin: 20px 0; padding: 16px; background: #fffef8; border: 1px solid var(--line); }
  343. .question .q-num { font-family: 'Roboto Mono', monospace; font-size: 11px; color: var(--red); letter-spacing: 1px; margin-bottom: 4px; }
  344. .question .q-text { font-weight: 700; margin-bottom: 10px; font-size: 15px; }
  345. .question label { display: block; padding: 6px 10px; margin: 4px 0; cursor: pointer; border: 1px solid transparent; border-radius: 2px; font-size: 14px; }
  346. .question label:hover { background: rgba(26,42,74,0.05); }
  347. .question input[type=radio] { margin-right: 8px; accent-color: var(--red); }
  348. .question .explain { display: none; margin-top: 10px; padding: 10px; background: rgba(26,74,106,0.08); border-left: 3px solid var(--blue); font-size: 13px; font-style: italic; }
  349. .question .explain.show { display: block; }
  350. .question.correct { border-color: var(--green); }
  351. .question.incorrect { border-color: var(--red); }
  352. .question .result-mark { font-family: 'Roboto Mono', monospace; font-size: 12px; font-weight: 700; margin-top: 8px; }
  353. .question .result-mark.ok { color: var(--green); }
  354. .question .result-mark.bad { color: var(--red); }
  355. .checklist { background: #fffef8; border: 1px solid var(--line); padding: 16px; margin: 20px 0; }
  356. .checklist h4 { font-family: 'Oswald', sans-serif; font-size: 14px; text-transform: uppercase; margin: 0 0 10px; letter-spacing: 0.5px; }
  357. .checklist label { display: block; padding: 4px 0; font-size: 13px; cursor: pointer; }
  358. .checklist input[type=checkbox] { margin-right: 8px; accent-color: var(--green); }
  359. .final-score { text-align: center; padding: 30px 20px; background: #fffef8; border: 2px solid var(--ink); margin: 20px 0; }
  360. .final-score .num { font-family: 'Oswald', sans-serif; font-size: 56px; font-weight: 700; color: var(--red); line-height: 1; }
  361. .final-score .of { font-family: 'Roboto Mono', monospace; font-size: 14px; color: var(--ink-light); margin-top: 4px; }
  362. .final-score .verdict { font-family: 'Oswald', sans-serif; font-size: 18px; text-transform: uppercase; margin-top: 12px; letter-spacing: 1px; }
  363. #inductionCanvas { cursor: grab; touch-action: none; }
  364. #inductionCanvas.dragging { cursor: grabbing; }
  365. #inductiveViz { cursor: default; touch-action: none; }
  366. #capacitiveViz { cursor: default; touch-action: none; }
  367. #galvanicViz { cursor: default; touch-action: none; }
  368. .hint { font-size: 12px; color: var(--ink-light); font-style: italic; margin-top: 8px; }
  369. @media (max-width: 640px) {
  370. body { padding: 10px; }
  371. .header { padding: 16px 20px 12px; }
  372. .header h1 { font-size: 20px; }
  373. .content { padding: 20px; }
  374. .nav { padding: 12px 20px; }
  375. button { padding: 8px 16px; font-size: 12px; }
  376. .channel-diagram { gap: 4px; }
  377. .channel-block { min-width: 100px; padding: 8px 10px; }
  378. .channel-arrow { font-size: 18px; padding: 0 2px; }
  379. }
  380. </style>
  381. </head>
  382. <body>
  383. <div class="app">
  384. <div class="header">
  385. <div class="header-top">
  386. <span>ПМ.03.01 · Техническая защита информации</span>
  387. <span>3.1.400</span>
  388. </div>
  389. <h1>Электромагнитный канал утечки информации</h1>
  390. <div class="sub">Один канал — три механизма</div>
  391. </div>
  392. <div class="progress" id="progress"></div>
  393. <div class="content" id="content">
  394. <div class="scene active" data-scene="1">
  395. <div class="scene-num">Цель</div>
  396. <h2 class="scene-title">Что вы узнаете</h2>
  397. <p class="lead">Пройдите интерактив последовательно: сначала вспомним физику, потом разберём структуру канала, затем — три механизма наводок и защиту от каждого.</p>
  398. <div class="notebook">
  399. <p><strong>После прохождения вы сможете:</strong></p>
  400. <p>1. Объяснить, какие электромагнитные явления лежат в основе передачи информации и перехвата.</p>
  401. <p>2. Описать структуру канала: источник → среда → приёмник.</p>
  402. <p>3. Различить три механизма наводок по физической природе, а не по названию.</p>
  403. <p>4. Объяснить, почему защита от разных механизмов разная.</p>
  404. </div>
  405. <p class="hint">Ключевая мысль: электромагнитный канал один. Структура одна. Механизмов связи — три, и они разные физически.</p>
  406. </div>
  407. <div class="scene" data-scene="2">
  408. <div class="scene-num">Актуализация · 1 из 4</div>
  409. <h2 class="scene-title">Электрическое и магнитное поле</h2>
  410. <p>Вспомним два фундаментальных понятия. Они понадобятся, чтобы понять, почему наводки бывают разными.</p>
  411. <div class="two-col">
  412. <div class="viz">
  413. <canvas id="fieldE" width="400" height="180"></canvas>
  414. <div class="viz-caption">Электрическое поле: линии от зарядов</div>
  415. </div>
  416. <div class="viz">
  417. <canvas id="fieldB" width="400" height="180"></canvas>
  418. <div class="viz-caption">Магнитное поле: линии вокруг тока</div>
  419. </div>
  420. </div>
  421. <div class="notebook">
  422. <p><strong>Электрическое поле</strong> — создаётся электрическими зарядами, действует на заряды силой.</p>
  423. <p><strong>Магнитное поле</strong> — создаётся движущимися зарядами (током), действует на движущиеся заряды.</p>
  424. </div>
  425. </div>
  426. <div class="scene" data-scene="3">
  427. <div class="scene-num">Актуализация · 2 из 4</div>
  428. <h2 class="scene-title">Магнитное поле вокруг проводника с током</h2>
  429. <p>Подвигайте ползунок: чем больше ток, тем сильнее поле.</p>
  430. <div class="viz">
  431. <canvas id="wireB" width="800" height="220"></canvas>
  432. <div class="viz-caption">Концентрические линии магнитного поля вокруг провода</div>
  433. </div>
  434. <div class="control-group">
  435. <div class="control-label"><span>Ток, А</span><span class="val" id="currentVal2">5</span></div>
  436. <input type="range" id="currentSlider2" min="0" max="10" step="0.5" value="5">
  437. </div>
  438. <div class="notebook">
  439. <p>Вокруг проводника с током возникает магнитное поле. Чем больше ток, тем сильнее поле.</p>
  440. <p>Направление — по правилу буравчика: если вкручивать буравчик по току, рукоятка вращается по линиям поля.</p>
  441. </div>
  442. </div>
  443. <div class="scene" data-scene="4">
  444. <div class="scene-num">Актуализация · 3 из 4</div>
  445. <h2 class="scene-title">Возникновение тока при изменении магнитного поля</h2>
  446. <p>Зажмите магнит и тяните его к катушке или от неё. Чем ближе магнит — тем больше линий поля пронизывают катушку и тем они ярче. Стрелка гальванометра отклоняется, пока магнит движется. Остановите магнит — линии перестают меняться, стрелка возвращается в нуль.</p>
  447. <div class="viz">
  448. <canvas id="inductionCanvas" width="800" height="320"></canvas>
  449. <div class="viz-caption">Линии магнитного поля: чем ближе магнит, тем гуще и ярче · гальванометр показывает ЭДС</div>
  450. </div>
  451. <div class="indicator">
  452. <div class="row">
  453. <small>ЭДС = −dФ/dt</small>
  454. <span class="main"><span id="emfValue">0.0</span> мВ</span>
  455. </div>
  456. </div>
  457. <div class="feedback" id="inductionFeedback">Зажмите магнит и двигайте его.</div>
  458. <div class="notebook">
  459. <p><strong>Электромагнитная индукция</strong> — при изменении магнитного потока через контур в нём возникает ЭДС (и ток, если контур замкнут).</p>
  460. <p>Закон Фарадея: <span class="formula">ЭДС = −dФ/dt</span>. Важно: ток возникает только при <em>изменении</em> потока, а не при постоянном поле.</p>
  461. </div>
  462. </div>
  463. <div class="scene" data-scene="5">
  464. <div class="scene-num">Актуализация · 4 из 4</div>
  465. <h2 class="scene-title">Конденсатор и индуктивность</h2>
  466. <p>Два элемента, которые накапливают энергию поля. Подвигайте ползунки — увидите, как меняется поле внутри и вокруг элемента.</p>
  467. <div class="two-col">
  468. <div class="viz">
  469. <canvas id="capacitorViz" width="400" height="200"></canvas>
  470. <div class="viz-caption">Конденсатор в разрезе: заряд и поле E между пластинами</div>
  471. <div class="control-group">
  472. <div class="control-label"><span>Заряд на пластинах</span><span class="val" id="capChargeVal">50</span>%</div>
  473. <input type="range" id="capCharge" min="0" max="100" step="5" value="50">
  474. </div>
  475. </div>
  476. <div class="viz">
  477. <canvas id="inductorViz" width="400" height="200"></canvas>
  478. <div class="viz-caption">Катушка индуктивности: ток и поле B вокруг витков</div>
  479. <div class="control-group">
  480. <div class="control-label"><span>Ток через катушку</span><span class="val" id="indCurrentVal3">50</span>%</div>
  481. <input type="range" id="indCurrent3" min="0" max="100" step="5" value="50">
  482. </div>
  483. </div>
  484. </div>
  485. <div class="notebook">
  486. <p><strong>Конденсатор</strong> — две проводящие пластины, разделённые диэлектриком. Накапливает заряд, создаёт электрическое поле между пластинами. Чем больше заряд — тем сильнее поле.</p>
  487. <p><strong>Индуктивность</strong> — свойство проводника накапливать энергию магнитного поля при протекании тока. Чем больше ток — тем сильнее поле.</p>
  488. </div>
  489. <p class="hint">Связь с наводками: два провода рядом образуют паразитный конденсатор (ёмкостная связь). Провод с током рядом с другим создаёт магнитное поле (индуктивная связь).</p>
  490. </div>
  491. <div class="scene" data-scene="6">
  492. <div class="scene-num">Новая тема · структура</div>
  493. <h2 class="scene-title">Структура канала передачи информации</h2>
  494. <p>Любой канал — от полезного сигнала до утечки — устроен одинаково: есть источник, среда и приёмник.</p>
  495. <div class="channel-diagram">
  496. <div class="channel-block source">
  497. <div class="label">Источник</div>
  498. <div class="name">Создаёт сигнал</div>
  499. </div>
  500. <div class="channel-arrow">→</div>
  501. <div class="channel-block medium">
  502. <div class="label">Среда</div>
  503. <div class="name">Переносит</div>
  504. </div>
  505. <div class="channel-arrow">→</div>
  506. <div class="channel-block receiver">
  507. <div class="label">Приёмник</div>
  508. <div class="name">Принимает</div>
  509. </div>
  510. </div>
  511. <div class="notebook">
  512. <p><strong>Канал передачи информации</strong> — путь от источника к приёмнику.</p>
  513. <p>Структура: <strong>источник</strong> (создаёт сигнал) → <strong>среда</strong> (переносит) → <strong>приёмник</strong> (принимает).</p>
  514. <p>В электромагнитном канале среда — это электрическое или магнитное поле, либо общий проводник.</p>
  515. </div>
  516. <p><strong>Ключевая мысль:</strong> те же явления злоумышленник использует для перехвата. Канал тот же, но работает против вас.</p>
  517. </div>
  518. <div class="scene" data-scene="7">
  519. <div class="scene-num">Новая тема · механизмы</div>
  520. <h2 class="scene-title">Наводки: три механизма одного канала</h2>
  521. <p>Наводка — это помеха в сигнальной цепи. Механизмов три, и они разные физически, хотя структура канала общая.</p>
  522. <div class="mechanisms">
  523. <div class="mech-card ind">
  524. <div class="mech-title">Индуктивный</div>
  525. <div class="mech-env">Среда — магнитное поле</div>
  526. </div>
  527. <div class="mech-card cap">
  528. <div class="mech-title">Ёмкостный</div>
  529. <div class="mech-env">Среда — электрическое поле</div>
  530. </div>
  531. <div class="mech-card gal">
  532. <div class="mech-title">Гальванический</div>
  533. <div class="mech-env">Среда — общий проводник</div>
  534. </div>
  535. </div>
  536. <div class="notebook">
  537. <p><strong>Наводка</strong> — помеха, наведённая в сигнальной цепи за счёт паразитной связи с другой цепью.</p>
  538. <p>Виды: <strong>индуктивная</strong> (через магнитное поле), <strong>ёмкостная</strong> (через электрическое поле), <strong>гальваническая</strong> (через общий проводник).</p>
  539. <p>Это один канал, три разных физических механизма. Структура общая: источник → среда → приёмник.</p>
  540. </div>
  541. </div>
  542. <div class="scene" data-scene="8">
  543. <div class="scene-num">Механизм 1 · индуктивный</div>
  544. <h2 class="scene-title">Индуктивная наводка</h2>
  545. <p>Источник — провод с переменным током. Среда — магнитное поле. Приёмник — петля сигнального провода. Меняйте ток, частоту, расстояние и площадь петли. Провод можно перетаскивать мышью, углы петли — тянуть и менять площадь.</p>
  546. <div class="viz">
  547. <canvas id="inductiveViz" width="800" height="440"></canvas>
  548. <div class="viz-caption">Плотность линий = интенсивность поля · мерцание = частота · длина дуги в петле = амплитуда ЭДС</div>
  549. </div>
  550. <div class="two-col">
  551. <div>
  552. <div class="control-group">
  553. <div class="control-label"><span>Ток источника, А</span><span class="val" id="indCurrentVal">5</span></div>
  554. <input type="range" id="indCurrent" min="0" max="10" step="0.5" value="5">
  555. </div>
  556. <div class="control-group">
  557. <div class="control-label"><span>Частота, Гц</span><span class="val" id="indFreqVal">500</span></div>
  558. <input type="range" id="indFreq" min="0" max="1000" step="50" value="500">
  559. </div>
  560. </div>
  561. <div>
  562. <div class="control-group">
  563. <div class="control-label"><span>Расстояние, см</span><span class="val" id="indDistVal">10</span></div>
  564. <input type="range" id="indDist" min="1" max="20" step="1" value="10">
  565. </div>
  566. <div class="control-group">
  567. <div class="control-label"><span>Площадь петли, см²</span><span class="val" id="indAreaVal">50</span></div>
  568. <input type="range" id="indArea" min="0" max="100" step="5" value="50">
  569. </div>
  570. </div>
  571. </div>
  572. <div class="indicator">
  573. <div class="row">
  574. <small>Мгновенная ЭДС = −dФ/dt</small>
  575. <span class="main"><span id="indResult">0.0</span> мВ</span>
  576. </div>
  577. <div class="row">
  578. <small>Амплитуда (средняя)</small>
  579. <span class="secondary"><span id="indPeak">0.0</span> мВ</span>
  580. </div>
  581. </div>
  582. <div class="feedback" id="indFeedback">Двигайте ползунки или перетаскивайте провод и углы петли.</div>
  583. <div class="notebook">
  584. <p><strong>Индуктивная наводка</strong> — наведение ЭДС в контуре за счёт изменения магнитного потока от соседнего проводника с током.</p>
  585. <p>Зависит от тока, частоты, площади петли и расстояния. При постоянном токе (частота = 0) наводки нет — поток не меняется.</p>
  586. </div>
  587. </div>
  588. <div class="scene" data-scene="9">
  589. <div class="scene-num">Механизм 2 · ёмкостный</div>
  590. <h2 class="scene-title">Ёмкостная наводка</h2>
  591. <p>Источник — провод с переменным напряжением. Среда — электрическое поле. Приёмник — провод или плата. Меняйте напряжение, частоту, расстояние и площадь. Провод можно перетаскивать мышью, углы приёмника — тянуть и менять площадь.</p>
  592. <div class="viz">
  593. <canvas id="capacitiveViz" width="800" height="440"></canvas>
  594. <div class="viz-caption">Плотность линий = напряжённость поля E · мерцание = частота · длина стрелки = амплитуда наводки</div>
  595. </div>
  596. <div class="two-col">
  597. <div>
  598. <div class="control-group">
  599. <div class="control-label"><span>Напряжение источника, В</span><span class="val" id="capVoltVal">500</span></div>
  600. <input type="range" id="capVolt" min="0" max="1000" step="50" value="500">
  601. </div>
  602. <div class="control-group">
  603. <div class="control-label"><span>Частота, Гц</span><span class="val" id="capFreqVal">500</span></div>
  604. <input type="range" id="capFreq" min="0" max="1000" step="50" value="500">
  605. </div>
  606. </div>
  607. <div>
  608. <div class="control-group">
  609. <div class="control-label"><span>Расстояние, см</span><span class="val" id="capDistVal">10</span></div>
  610. <input type="range" id="capDist" min="1" max="20" step="1" value="10">
  611. </div>
  612. <div class="control-group">
  613. <div class="control-label"><span>Площадь приёмника, см²</span><span class="val" id="capAreaVal">50</span></div>
  614. <input type="range" id="capArea" min="0" max="100" step="5" value="50">
  615. </div>
  616. </div>
  617. </div>
  618. <div class="indicator">
  619. <div class="row">
  620. <small>Мгновенное наведённое напряжение</small>
  621. <span class="main"><span id="capResult">0.0</span> мВ</span>
  622. </div>
  623. <div class="row">
  624. <small>Амплитуда (средняя)</small>
  625. <span class="secondary"><span id="capPeak">0.0</span> мВ</span>
  626. </div>
  627. </div>
  628. <div class="feedback" id="capFeedback">Двигайте ползунки или перетаскивайте провод и углы приёмника.</div>
  629. <div class="notebook">
  630. <p><strong>Ёмкостная наводка</strong> — наведение напряжения в проводнике за счёт электрического поля соседнего проводника с переменным напряжением.</p>
  631. <p>Зависит от напряжения, частоты, площади и расстояния. При постоянном напряжении (частота = 0) наводки нет — заряд не меняется.</p>
  632. </div>
  633. </div>
  634. <div class="scene" data-scene="10">
  635. <div class="scene-num">Механизм 3 · гальванический</div>
  636. <h2 class="scene-title">Гальваническая наводка</h2>
  637. <p>Источник — силовая нагрузка, которая потребляет ток. Приёмник — сигнальная цепь. Среда — общий проводник (земля или питание), по которому ток от нагрузки течёт к земле. На сопротивлении общего участка падает напряжение, и оно смещает потенциал сигнальной цепи — это и есть помеха. Тяните нагрузку или сигнальную цепь мышью: расстояние между ними определяет сопротивление общего участка.</p>
  638. <div class="viz">
  639. <canvas id="galvanicViz" width="800" height="440"></canvas>
  640. <div class="viz-caption">Толщина общего участка = сопротивление · длина стрелки U = I·R = падение · полоса в приёмнике = помеха</div>
  641. </div>
  642. <div class="two-col">
  643. <div>
  644. <div class="control-group">
  645. <div class="control-label"><span>Ток в общей цепи, А</span><span class="val" id="galCurrentVal">5</span></div>
  646. <input type="range" id="galCurrent" min="0" max="10" step="0.5" value="5">
  647. </div>
  648. <div class="control-group">
  649. <div class="control-label"><span>Сопротивление общего участка, Ом</span><span class="val" id="galResVal">0.60</span></div>
  650. <input type="range" id="galRes" min="0" max="1" step="0.05" value="0.6">
  651. </div>
  652. </div>
  653. <div>
  654. <div class="control-group">
  655. <div class="control-label"><span>Качество заземления, %</span><span class="val" id="galGroundVal">50</span></div>
  656. <input type="range" id="galGround" min="0" max="100" step="5" value="50">
  657. </div>
  658. </div>
  659. </div>
  660. <div class="indicator">
  661. <div class="row">
  662. <small>Помеха в сигнальной цепи U = I·R<sub>эфф</sub></small>
  663. <span class="main"><span id="galResult">0.0</span> мВ</span>
  664. </div>
  665. <div class="row">
  666. <small>Эффективное сопротивление (с учётом заземления)</small>
  667. <span class="secondary"><span id="galReff">0.00</span> Ом</span>
  668. </div>
  669. </div>
  670. <div class="feedback" id="galFeedback">Тяните нагрузку или сигнальную цепь, или двигайте ползунки.</div>
  671. <div class="notebook">
  672. <p><strong>Гальваническая наводка</strong> — помеха, попадающая в сигнальную цепь через общий проводник (землю, питание) за счёт падения напряжения на его сопротивлении.</p>
  673. <p>Зависит от тока, сопротивления общего участка и качества заземления. По закону Ома: <span class="formula">U = I·R</span>. Это <em>постоянная</em> помеха, не зависящая от частоты — ключевое отличие от индуктивной и ёмкостной.</p>
  674. </div>
  675. </div>
  676. <div class="scene" data-scene="11">
  677. <div class="scene-num">Применение · защита</div>
  678. <h2 class="scene-title">Как защищаться от каждого механизма</h2>
  679. <p>Механизмы разные — значит, и защита разная. Один и тот же способ не работает одинаково против всех трёх.</p>
  680. <table class="protection-table">
  681. <thead>
  682. <tr>
  683. <th>Механизм</th>
  684. <th>От чего зависит</th>
  685. <th>Защита</th>
  686. </tr>
  687. </thead>
  688. <tbody>
  689. <tr>
  690. <td><strong>Индуктивный</strong></td>
  691. <td>Ток, частота, площадь петли, расстояние</td>
  692. <td>Разнос, витая пара, экран из магнитного материала</td>
  693. </tr>
  694. <tr>
  695. <td><strong>Ёмкостный</strong></td>
  696. <td>Напряжение, частота, площадь, расстояние</td>
  697. <td>Экран (электростатический), разнос, заземление экрана</td>
  698. </tr>
  699. <tr>
  700. <td><strong>Гальванический</strong></td>
  701. <td>Ток, сопротивление общего участка, заземление</td>
  702. <td>Разрыв общей цепи (оптрон, трансформатор), правильное заземление</td>
  703. </tr>
  704. </tbody>
  705. </table>
  706. <div class="notebook">
  707. <p><strong>От индуктивной</strong> — разнос, витая пара, экран из магнитного материала.</p>
  708. <p><strong>От ёмкостной</strong> — экран (электростатический), разнос, заземление экрана.</p>
  709. <p><strong>От гальванической</strong> — разрыв общей цепи (оптрон, трансформатор), правильное заземление.</p>
  710. </div>
  711. <p><strong>Ключевая мысль:</strong> защита разная, потому что механизмы разные. Экран от ёмкостной работает, от гальванической — нет.</p>
  712. </div>
  713. <div class="scene" data-scene="12">
  714. <div class="scene-num">Проверка</div>
  715. <h2 class="scene-title">Тест: проверьте понимание</h2>
  716. <p>Ответьте на вопросы. После каждого ответа — пояснение. В конце — результат и чек-лист конспекта.</p>
  717. <div id="quizContainer"></div>
  718. <div id="quizResult" style="display:none;"></div>
  719. <div class="checklist" id="finalChecklist" style="display:none;">
  720. <h4>Проверь, что записал в тетрадь</h4>
  721. <label><input type="checkbox"> Определение электрического и магнитного поля</label>
  722. <label><input type="checkbox"> Электромагнитная индукция (закон Фарадея)</label>
  723. <label><input type="checkbox"> Конденсатор и индуктивность</label>
  724. <label><input type="checkbox"> Структура канала: источник → среда → приёмник</label>
  725. <label><input type="checkbox"> Определение наводки</label>
  726. <label><input type="checkbox"> Три механизма: индуктивный, ёмкостный, гальванический</label>
  727. <label><input type="checkbox"> Зависимости каждого механизма</label>
  728. <label><input type="checkbox"> Защита от каждого механизма</label>
  729. </div>
  730. </div>
  731. </div>
  732. <div class="nav">
  733. <button id="prevBtn" class="ghost" disabled>← Назад</button>
  734. <span id="navLabel" style="font-family: 'Roboto Mono', monospace; font-size: 12px; color: var(--ink-light);"></span>
  735. <button id="nextBtn" class="primary">Дальше →</button>
  736. </div>
  737. </div>
  738. <script>
  739. (function() {
  740. 'use strict';
  741. const scenes = document.querySelectorAll('.scene');
  742. const totalScenes = scenes.length;
  743. const progress = document.getElementById('progress');
  744. const prevBtn = document.getElementById('prevBtn');
  745. const nextBtn = document.getElementById('nextBtn');
  746. const navLabel = document.getElementById('navLabel');
  747. let current = 0;
  748. for (let i = 0; i < totalScenes; i++) {
  749. const step = document.createElement('div');
  750. step.className = 'progress-step';
  751. progress.appendChild(step);
  752. }
  753. const progressSteps = progress.querySelectorAll('.progress-step');
  754. function showScene(index) {
  755. scenes.forEach((s, i) => s.classList.toggle('active', i === index));
  756. progressSteps.forEach((s, i) => {
  757. s.classList.toggle('done', i < index);
  758. s.classList.toggle('current', i === index);
  759. });
  760. prevBtn.disabled = index === 0;
  761. nextBtn.textContent = index === totalScenes - 1 ? 'К началу' : 'Дальше →';
  762. navLabel.textContent = (index + 1) + ' / ' + totalScenes;
  763. if (index === 1) initFields();
  764. if (index === 2) drawWireB();
  765. if (index === 3) initInductionScene();
  766. if (index === 4) { drawCapacitor(); drawInductor(); }
  767. if (index === 7) initInductive();
  768. if (index === 8) initCapacitive8();
  769. if (index === 9) initGal8();
  770. if (index === 11) initQuiz();
  771. window.scrollTo({ top: 0, behavior: 'smooth' });
  772. }
  773. prevBtn.addEventListener('click', () => {
  774. if (current > 0) { current--; showScene(current); }
  775. });
  776. nextBtn.addEventListener('click', () => {
  777. if (current < totalScenes - 1) { current++; showScene(current); }
  778. else { current = 0; showScene(0); }
  779. });
  780. function initFields() {
  781. const eCanvas = document.getElementById('fieldE');
  782. const eCtx = eCanvas.getContext('2d');
  783. const bCanvas = document.getElementById('fieldB');
  784. const bCtx = bCanvas.getContext('2d');
  785. eCtx.clearRect(0, 0, 400, 180);
  786. eCtx.fillStyle = '#f2e9d6';
  787. eCtx.fillRect(0, 0, 400, 180);
  788. eCtx.fillStyle = '#8b1a1a';
  789. eCtx.beginPath(); eCtx.arc(100, 90, 14, 0, Math.PI*2); eCtx.fill();
  790. eCtx.fillStyle = '#1a4a6a';
  791. eCtx.beginPath(); eCtx.arc(300, 90, 14, 0, Math.PI*2); eCtx.fill();
  792. eCtx.fillStyle = '#fff';
  793. eCtx.font = 'bold 16px serif';
  794. eCtx.textAlign = 'center'; eCtx.textBaseline = 'middle';
  795. eCtx.fillText('+', 100, 90);
  796. eCtx.fillText('−', 300, 90);
  797. eCtx.strokeStyle = 'rgba(139,26,26,0.4)';
  798. eCtx.lineWidth = 1.5;
  799. for (let i = 0; i < 8; i++) {
  800. const y = 30 + i * 18;
  801. eCtx.beginPath();
  802. eCtx.moveTo(114, 90);
  803. eCtx.quadraticCurveTo(200, y, 286, 90);
  804. eCtx.stroke();
  805. }
  806. bCtx.clearRect(0, 0, 400, 180);
  807. bCtx.fillStyle = '#f2e9d6';
  808. bCtx.fillRect(0, 0, 400, 180);
  809. bCtx.fillStyle = '#1a2a4a';
  810. bCtx.fillRect(190, 20, 20, 140);
  811. bCtx.fillStyle = '#fff';
  812. bCtx.font = '12px monospace';
  813. bCtx.textAlign = 'center';
  814. bCtx.fillText('I', 200, 95);
  815. bCtx.strokeStyle = 'rgba(26,74,106,0.4)';
  816. bCtx.lineWidth = 1.5;
  817. for (let r = 30; r <= 90; r += 15) {
  818. bCtx.beginPath();
  819. bCtx.arc(200, 90, r, 0, Math.PI*2);
  820. bCtx.stroke();
  821. }
  822. }
  823. function drawWireB() {
  824. const canvas = document.getElementById('wireB');
  825. const ctx = canvas.getContext('2d');
  826. const current = parseFloat(document.getElementById('currentSlider2').value);
  827. const w = canvas.width, h = canvas.height;
  828. ctx.fillStyle = '#f2e9d6';
  829. ctx.fillRect(0, 0, w, h);
  830. ctx.fillStyle = '#1a2a4a';
  831. ctx.fillRect(390, 20, 20, h - 40);
  832. ctx.fillStyle = '#fff';
  833. ctx.font = 'bold 14px monospace';
  834. ctx.textAlign = 'center';
  835. ctx.fillText('I', 400, h/2);
  836. const maxR = 200;
  837. const lineCount = Math.floor(current * 2);
  838. ctx.strokeStyle = 'rgba(139,26,26,0.35)';
  839. ctx.lineWidth = 1.5;
  840. for (let i = 1; i <= lineCount; i++) {
  841. const r = (i / lineCount) * maxR;
  842. ctx.beginPath();
  843. ctx.ellipse(400, h/2, r * 0.6, r * 1.1, 0, 0, Math.PI*2);
  844. ctx.stroke();
  845. }
  846. ctx.fillStyle = '#4a5a7a';
  847. ctx.font = '13px serif';
  848. ctx.textAlign = 'center';
  849. ctx.fillText('Ток: ' + current + ' А', 400, h - 12);
  850. }
  851. document.getElementById('currentSlider2').addEventListener('input', function() {
  852. document.getElementById('currentVal2').textContent = this.value;
  853. drawWireB();
  854. });
  855. // === СЦЕНА 4 ===
  856. const induction = {
  857. canvas: null, ctx: null,
  858. magnet: { x: 100, y: 130, w: 70, h: 60, dragging: false, offsetX: 0 },
  859. coil: { x: 520, y: 110, w: 100, h: 100 },
  860. flux: 0, lastTime: 0, emf: 0, displayEmf: 0,
  861. initialized: false, minX: 20, maxX: 440
  862. };
  863. function initInductionScene() {
  864. const c = document.getElementById('inductionCanvas');
  865. if (!c) return;
  866. if (induction.initialized) { induction.canvas = c; induction.ctx = c.getContext('2d'); return; }
  867. induction.canvas = c;
  868. induction.ctx = c.getContext('2d');
  869. induction.initialized = true;
  870. c.addEventListener('mousedown', onIndDown);
  871. c.addEventListener('mousemove', onIndMove);
  872. c.addEventListener('mouseup', onIndUp);
  873. c.addEventListener('mouseleave', onIndUp);
  874. c.addEventListener('touchstart', onIndDown, { passive: false });
  875. c.addEventListener('touchmove', onIndMove, { passive: false });
  876. c.addEventListener('touchend', onIndUp);
  877. c.addEventListener('touchcancel', onIndUp);
  878. induction.lastTime = performance.now();
  879. requestAnimationFrame(drawInduction);
  880. }
  881. function getCanvasCoords(e, canvas) {
  882. const rect = canvas.getBoundingClientRect();
  883. const scaleX = canvas.width / rect.width, scaleY = canvas.height / rect.height;
  884. let cx, cy;
  885. if (e.touches && e.touches.length) { cx = e.touches[0].clientX; cy = e.touches[0].clientY; }
  886. else { cx = e.clientX; cy = e.clientY; }
  887. return { x: (cx - rect.left) * scaleX, y: (cy - rect.top) * scaleY };
  888. }
  889. function onIndDown(e) {
  890. e.preventDefault();
  891. const p = getCanvasCoords(e, induction.canvas);
  892. const m = induction.magnet;
  893. if (p.x >= m.x && p.x <= m.x + m.w && p.y >= m.y && p.y <= m.y + m.h) {
  894. m.dragging = true; m.offsetX = p.x - m.x;
  895. induction.canvas.classList.add('dragging');
  896. }
  897. }
  898. function onIndMove(e) {
  899. if (!induction.magnet.dragging) return;
  900. e.preventDefault();
  901. const p = getCanvasCoords(e, induction.canvas);
  902. let newX = p.x - induction.magnet.offsetX;
  903. newX = Math.max(induction.minX, Math.min(induction.maxX, newX));
  904. induction.magnet.x = newX;
  905. }
  906. function onIndUp() {
  907. if (induction.magnet.dragging) { induction.magnet.dragging = false; induction.canvas.classList.remove('dragging'); }
  908. }
  909. function drawInduction() {
  910. const sceneEl = document.querySelector('.scene[data-scene="4"]');
  911. if (!sceneEl || !sceneEl.classList.contains('active')) { requestAnimationFrame(drawInduction); return; }
  912. if (!induction.ctx) { requestAnimationFrame(drawInduction); return; }
  913. const now = performance.now();
  914. const dt = (now - induction.lastTime) / 1000;
  915. induction.lastTime = now;
  916. const m = induction.magnet, c = induction.coil;
  917. const magnetCenterX = m.x + m.w / 2, coilCenterX = c.x + c.w / 2;
  918. const dist = Math.abs(magnetCenterX - coilCenterX);
  919. const flux = 1000 / (dist * dist + 5000);
  920. if (dt > 0.001 && dt < 0.3) {
  921. const dflux = flux - induction.flux;
  922. const emfRaw = -(dflux / dt) * 2000;
  923. induction.emf = Math.max(-100, Math.min(100, emfRaw));
  924. } else { induction.emf = induction.emf * 0.9; }
  925. induction.flux = flux;
  926. induction.displayEmf += (induction.emf - induction.displayEmf) * 0.25;
  927. if (Math.abs(induction.displayEmf) < 0.5) induction.displayEmf = 0;
  928. renderInduction();
  929. const emfEl = document.getElementById('emfValue');
  930. if (emfEl) emfEl.textContent = induction.displayEmf.toFixed(1);
  931. const fbEl = document.getElementById('inductionFeedback');
  932. if (fbEl) {
  933. const speed = Math.abs(induction.displayEmf);
  934. if (speed < 1) fbEl.textContent = 'Магнит неподвижен → поток не меняется → ЭДС = 0.';
  935. else if (speed < 30) fbEl.textContent = 'Магнит движется медленно → поток меняется медленно → ЭДС небольшая.';
  936. else fbEl.textContent = 'Магнит движется быстро → поток меняется быстро → ЭДС большая.';
  937. }
  938. requestAnimationFrame(drawInduction);
  939. }
  940. function renderInduction() {
  941. const c = induction.canvas, ctx = induction.ctx;
  942. if (!c || !ctx) return;
  943. const w = c.width, h = c.height;
  944. ctx.fillStyle = '#f2e9d6'; ctx.fillRect(0, 0, w, h);
  945. const m = induction.magnet, coil = induction.coil;
  946. const magnetCenterX = m.x + m.w / 2, coilCenterX = coil.x + coil.w / 2;
  947. const dist = Math.abs(magnetCenterX - coilCenterX);
  948. const reach = Math.max(0, Math.min(1, 1 - (dist - 60) / 400));
  949. ctx.strokeStyle = '#1a2a4a'; ctx.lineWidth = 3;
  950. for (let i = 0; i < 5; i++) {
  951. const rx = 15 + i * 2;
  952. const x = coil.x + 20 + i * 12;
  953. ctx.beginPath(); ctx.ellipse(x, coil.y + coil.h/2, rx, coil.h/2, 0, 0, Math.PI * 2); ctx.stroke();
  954. }
  955. ctx.fillStyle = '#4a5a7a'; ctx.font = '12px "Roboto Mono", monospace';
  956. ctx.textAlign = 'center';
  957. ctx.fillText('катушка', coil.x + coil.w/2, coil.y + coil.h + 20);
  958. if (reach > 0.4) {
  959. const glow = (reach - 0.4) / 0.6;
  960. const grad = ctx.createRadialGradient(coilCenterX, coil.y + coil.h/2, 20, coilCenterX, coil.y + coil.h/2, coil.w);
  961. grad.addColorStop(0, `rgba(255,140,50,${glow * 0.25})`);
  962. grad.addColorStop(1, 'rgba(255,140,50,0)');
  963. ctx.fillStyle = grad;
  964. ctx.fillRect(coil.x - 80, coil.y - 60, coil.w + 160, coil.h + 120);
  965. }
  966. const nX = m.x + m.w, sX = m.x, myCenter = m.y + m.h / 2;
  967. const numFlux = Math.max(3, Math.round(3 + reach * 10));
  968. const spread = m.h * (0.35 + reach * 0.35);
  969. const rightEndX = coil.x + 15;
  970. const rightLen = rightEndX - nX;
  971. const leftEndX = Math.max(10, sX - rightLen);
  972. const alpha = 0.1 + reach * 0.9;
  973. const lineWidth = 0.8 + reach * 2.2;
  974. const rCol = Math.floor(139 + reach * 80);
  975. const gCol = Math.floor(20 + reach * 130);
  976. const bCol = Math.floor(20 + reach * 30);
  977. const shadowCol = `rgba(255,140,50,${reach * 0.7})`;
  978. const shadowBlur = reach * 12;
  979. function drawFluxLine(x1, startY, x2, endY, curvature) {
  980. ctx.strokeStyle = `rgba(${rCol},${gCol},${bCol},${alpha})`;
  981. ctx.lineWidth = lineWidth;
  982. if (reach > 0.3) { ctx.shadowColor = shadowCol; ctx.shadowBlur = shadowBlur; }
  983. ctx.beginPath(); ctx.moveTo(x1, startY);
  984. const midX = (x1 + x2) / 2, midY = (startY + endY) / 2 + curvature;
  985. ctx.quadraticCurveTo(midX, midY, x2, endY);
  986. ctx.stroke();
  987. ctx.shadowBlur = 0; ctx.shadowColor = 'transparent';
  988. }
  989. for (let i = 0; i < numFlux; i++) {
  990. const t = numFlux === 1 ? 0.5 : i / (numFlux - 1);
  991. const rel = (t - 0.5) * 2;
  992. const startY = myCenter + rel * spread;
  993. const rightEndY = myCenter + rel * (spread + coil.h * 0.3 * reach);
  994. drawFluxLine(nX, startY, rightEndX, rightEndY, rel * 15);
  995. const leftEndY = myCenter + rel * spread;
  996. drawFluxLine(sX, startY, leftEndX, leftEndY, rel * 15);
  997. }
  998. ctx.fillStyle = '#1a4a6a'; ctx.fillRect(m.x, m.y, m.w / 2, m.h);
  999. ctx.fillStyle = '#8b1a1a'; ctx.fillRect(m.x + m.w / 2, m.y, m.w / 2, m.h);
  1000. ctx.strokeStyle = '#1a2a4a'; ctx.lineWidth = 2; ctx.strokeRect(m.x, m.y, m.w, m.h);
  1001. ctx.fillStyle = '#fff'; ctx.font = 'bold 20px "PT Serif", serif';
  1002. ctx.textAlign = 'center'; ctx.textBaseline = 'middle';
  1003. ctx.fillText('S', m.x + m.w / 4, m.y + m.h / 2);
  1004. ctx.fillText('N', m.x + 3 * m.w / 4, m.y + m.h / 2);
  1005. ctx.textBaseline = 'alphabetic';
  1006. const gx = 700, gy = 200, gr = 50;
  1007. ctx.beginPath(); ctx.arc(gx, gy, gr, 0, Math.PI * 2);
  1008. ctx.fillStyle = '#fffef8'; ctx.fill();
  1009. ctx.strokeStyle = '#1a2a4a'; ctx.lineWidth = 2; ctx.stroke();
  1010. ctx.strokeStyle = '#4a5a7a'; ctx.lineWidth = 1;
  1011. for (let a = -60; a <= 60; a += 15) {
  1012. const rad = (a - 90) * Math.PI / 180;
  1013. const x1 = gx + Math.cos(rad) * (gr - 10), y1 = gy + Math.sin(rad) * (gr - 10);
  1014. const x2 = gx + Math.cos(rad) * (gr - 2), y2 = gy + Math.sin(rad) * (gr - 2);
  1015. ctx.beginPath(); ctx.moveTo(x1, y1); ctx.lineTo(x2, y2); ctx.stroke();
  1016. }
  1017. ctx.fillStyle = '#4a5a7a'; ctx.font = '10px monospace';
  1018. ctx.textAlign = 'center'; ctx.fillText('0', gx, gy - gr + 12);
  1019. const angle = (induction.displayEmf / 100) * 45;
  1020. const rad = (angle - 90) * Math.PI / 180;
  1021. const arrowLen = gr - 8;
  1022. ctx.strokeStyle = '#8b1a1a'; ctx.lineWidth = 3;
  1023. ctx.beginPath(); ctx.moveTo(gx, gy);
  1024. ctx.lineTo(gx + Math.cos(rad) * arrowLen, gy + Math.sin(rad) * arrowLen);
  1025. ctx.stroke();
  1026. ctx.fillStyle = '#1a2a4a'; ctx.beginPath(); ctx.arc(gx, gy, 5, 0, Math.PI * 2); ctx.fill();
  1027. ctx.fillStyle = '#4a5a7a'; ctx.font = '12px "Roboto Mono", monospace';
  1028. ctx.fillText('гальванометр', gx, gy + gr + 18);
  1029. ctx.font = '14px "Roboto Mono", monospace'; ctx.fillStyle = '#8b1a1a';
  1030. ctx.fillText('−', gx - gr - 12, gy - 5);
  1031. ctx.fillText('+', gx + gr + 12, gy - 5);
  1032. }
  1033. // === СЦЕНА 5 ===
  1034. function drawCapacitor() {
  1035. const c = document.getElementById('capacitorViz');
  1036. if (!c) return;
  1037. const ctx = c.getContext('2d');
  1038. const charge = parseFloat(document.getElementById('capCharge').value);
  1039. const w = c.width, h = c.height;
  1040. ctx.fillStyle = '#f2e9d6'; ctx.fillRect(0, 0, w, h);
  1041. const plateW = 16, plateH = 120, leftX = 80, rightX = w - 80 - plateW;
  1042. const topY = (h - plateH) / 2;
  1043. ctx.fillStyle = '#8b1a1a'; ctx.fillRect(leftX, topY, plateW, plateH);
  1044. ctx.fillStyle = '#1a4a6a'; ctx.fillRect(rightX, topY, plateW, plateH);
  1045. const numCharges = Math.floor(charge / 10);
  1046. if (numCharges > 0) {
  1047. const signY0 = topY + 30;
  1048. const signYStep = (plateH - 60) / Math.max(1, numCharges - 1);
  1049. ctx.fillStyle = '#fff'; ctx.font = 'bold 14px serif';
  1050. ctx.textAlign = 'center'; ctx.textBaseline = 'middle';
  1051. for (let i = 0; i < numCharges; i++) {
  1052. const y = signY0 + i * signYStep;
  1053. ctx.fillText('+', leftX + plateW/2, y);
  1054. ctx.fillText('−', rightX + plateW/2, y);
  1055. }
  1056. }
  1057. if (charge > 0) {
  1058. const lines = Math.max(1, Math.floor(charge / 12));
  1059. const alpha = 0.15 + (charge / 100) * 0.75;
  1060. const lw = 1 + (charge / 100) * 2;
  1061. ctx.strokeStyle = `rgba(139,26,26,${alpha})`; ctx.lineWidth = lw;
  1062. for (let i = 0; i < lines; i++) {
  1063. const y = topY + 20 + i * (plateH - 40) / Math.max(1, lines - 1);
  1064. ctx.beginPath(); ctx.moveTo(leftX + plateW, y); ctx.lineTo(rightX, y); ctx.stroke();
  1065. }
  1066. }
  1067. ctx.fillStyle = '#8b1a1a'; ctx.font = 'bold 13px "Roboto Mono", monospace';
  1068. ctx.textAlign = 'center'; ctx.textBaseline = 'alphabetic';
  1069. ctx.fillText('E', w/2, topY - 10);
  1070. ctx.fillStyle = '#4a5a7a'; ctx.font = '11px "Roboto Mono", monospace';
  1071. ctx.fillText('диэлектрик', w/2, h - 12);
  1072. ctx.font = '11px "Roboto Mono", monospace';
  1073. ctx.textAlign = 'left'; ctx.fillText('+', leftX - 18, topY + plateH/2);
  1074. ctx.textAlign = 'right'; ctx.fillText('−', rightX + plateW + 18, topY + plateH/2);
  1075. }
  1076. function drawInductor() {
  1077. const c = document.getElementById('inductorViz');
  1078. if (!c) return;
  1079. const ctx = c.getContext('2d');
  1080. const current = parseFloat(document.getElementById('indCurrent3').value);
  1081. const w = c.width, h = c.height;
  1082. ctx.fillStyle = '#f2e9d6'; ctx.fillRect(0, 0, w, h);
  1083. const coilCX = w/2, coilCY = h/2 + 10, coilW = 180, coilH = 100, turns = 5;
  1084. if (current > 0) {
  1085. const lineCount = Math.max(1, Math.floor(current / 12));
  1086. const alpha = 0.15 + (current / 100) * 0.75;
  1087. const lw = 1 + (current / 100) * 2;
  1088. const maxR = 55;
  1089. ctx.strokeStyle = `rgba(139,26,26,${alpha})`; ctx.lineWidth = lw;
  1090. for (let i = 0; i < lineCount; i++) {
  1091. const r = 12 + i * (maxR - 12) / Math.max(1, lineCount - 1);
  1092. ctx.beginPath(); ctx.ellipse(coilCX, coilCY, coilW/2 + r, coilH/2 + r*0.7, 0, 0, Math.PI*2); ctx.stroke();
  1093. }
  1094. }
  1095. ctx.strokeStyle = '#1a2a4a'; ctx.lineWidth = 4;
  1096. for (let i = 0; i < turns; i++) {
  1097. const x = coilCX - coilW/2 + (i + 0.5) * (coilW / turns);
  1098. const rx = (coilW / turns) * 0.55;
  1099. ctx.beginPath(); ctx.ellipse(x, coilCY, rx, coilH/2, 0, 0, Math.PI*2); ctx.stroke();
  1100. }
  1101. ctx.fillStyle = '#8b1a1a'; ctx.font = 'bold 13px "Roboto Mono", monospace';
  1102. ctx.textAlign = 'left'; ctx.textBaseline = 'alphabetic'; ctx.fillText('B', 20, 24);
  1103. ctx.fillStyle = '#4a5a7a'; ctx.font = '11px "Roboto Mono", monospace';
  1104. ctx.textAlign = 'center'; ctx.fillText('витки', coilCX, h - 12);
  1105. }
  1106. document.getElementById('capCharge').addEventListener('input', function() {
  1107. document.getElementById('capChargeVal').textContent = this.value;
  1108. drawCapacitor();
  1109. });
  1110. document.getElementById('indCurrent3').addEventListener('input', function() {
  1111. document.getElementById('indCurrentVal3').textContent = this.value;
  1112. drawInductor();
  1113. });
  1114. // === СЦЕНА 8: индуктивная ===
  1115. const ind8 = {
  1116. canvas: null, ctx: null,
  1117. wire: { x: 370, w: 22, h: 260, cy: 220 },
  1118. loop: { x1: 560, y1: 150, w: 120, h: 105 },
  1119. pxPerCm: 18, phase: 0, lastT: 0,
  1120. dragMode: null, dragOffset: { x: 0 },
  1121. initialized: false
  1122. };
  1123. function initInductive() {
  1124. const c = document.getElementById('inductiveViz');
  1125. if (!c) return;
  1126. ind8.canvas = c;
  1127. ind8.ctx = c.getContext('2d');
  1128. if (!ind8.initialized) {
  1129. ind8.initialized = true;
  1130. c.addEventListener('mousedown', onInd8Down);
  1131. c.addEventListener('mousemove', onInd8Move);
  1132. c.addEventListener('mouseup', onInd8Up);
  1133. c.addEventListener('mouseleave', onInd8Up);
  1134. c.addEventListener('touchstart', onInd8Down, { passive: false });
  1135. c.addEventListener('touchmove', onInd8Move, { passive: false });
  1136. c.addEventListener('touchend', onInd8Up);
  1137. c.addEventListener('touchcancel', onInd8Up);
  1138. ['indCurrent', 'indFreq'].forEach(id => {
  1139. document.getElementById(id).addEventListener('input', updateInductive);
  1140. });
  1141. document.getElementById('indDist').addEventListener('input', function() {
  1142. applyInd8DistSlider(); updateInductive();
  1143. });
  1144. document.getElementById('indArea').addEventListener('input', function() {
  1145. applyInd8AreaSlider(); updateInductive();
  1146. });
  1147. applyInd8AreaSlider();
  1148. applyInd8DistSlider();
  1149. ind8.lastT = performance.now();
  1150. requestAnimationFrame(drawInd8);
  1151. }
  1152. }
  1153. function getInd8Coords(e) {
  1154. const c = ind8.canvas, rect = c.getBoundingClientRect();
  1155. const sx = c.width / rect.width, sy = c.height / rect.height;
  1156. let cx, cy;
  1157. if (e.touches && e.touches.length) { cx = e.touches[0].clientX; cy = e.touches[0].clientY; }
  1158. else { cx = e.clientX; cy = e.clientY; }
  1159. return { x: (cx - rect.left) * sx, y: (cy - rect.top) * sy };
  1160. }
  1161. function onInd8Down(e) {
  1162. e.preventDefault();
  1163. const p = getInd8Coords(e);
  1164. const l = ind8.loop;
  1165. const corners = [
  1166. { name: 'tl', x: l.x1, y: l.y1 }, { name: 'tr', x: l.x1 + l.w, y: l.y1 },
  1167. { name: 'bl', x: l.x1, y: l.y1 + l.h }, { name: 'br', x: l.x1 + l.w, y: l.y1 + l.h }
  1168. ];
  1169. for (const c of corners) {
  1170. if (Math.hypot(p.x - c.x, p.y - c.y) < 18) { ind8.dragMode = c.name; return; }
  1171. }
  1172. const w = ind8.wire;
  1173. if (p.x >= w.x - w.w/2 - 8 && p.x <= w.x + w.w/2 + 8 && p.y >= w.cy - w.h/2 && p.y <= w.cy + w.h/2) {
  1174. ind8.dragMode = 'wire'; ind8.dragOffset.x = p.x - w.x;
  1175. ind8.canvas.style.cursor = 'grabbing';
  1176. }
  1177. }
  1178. function onInd8Move(e) {
  1179. const p = getInd8Coords(e);
  1180. if (!ind8.dragMode) {
  1181. const l = ind8.loop;
  1182. const corners = [[l.x1, l.y1], [l.x1 + l.w, l.y1], [l.x1, l.y1 + l.h], [l.x1 + l.w, l.y1 + l.h]];
  1183. let overCorner = false;
  1184. for (const [cx, cy] of corners) if (Math.hypot(p.x - cx, p.y - cy) < 18) { overCorner = true; break; }
  1185. if (overCorner) ind8.canvas.style.cursor = 'nwse-resize';
  1186. else if (Math.abs(p.x - ind8.wire.x) < 20 && p.y > 60 && p.y < 380) ind8.canvas.style.cursor = 'grab';
  1187. else ind8.canvas.style.cursor = 'default';
  1188. return;
  1189. }
  1190. e.preventDefault();
  1191. if (ind8.dragMode === 'wire') {
  1192. let newX = p.x - ind8.dragOffset.x;
  1193. const loopLeft = ind8.loop.x1;
  1194. const minDistPx = 1 * ind8.pxPerCm, maxDistPx = 20 * ind8.pxPerCm;
  1195. const wireRightEdge = newX + ind8.wire.w / 2;
  1196. let distPx = loopLeft - wireRightEdge;
  1197. if (distPx < minDistPx) newX = loopLeft - minDistPx - ind8.wire.w / 2;
  1198. if (distPx > maxDistPx) newX = loopLeft - maxDistPx - ind8.wire.w / 2;
  1199. if (newX < 30) newX = 30;
  1200. ind8.wire.x = newX;
  1201. const d = Math.max(1, Math.min(20, Math.round((loopLeft - (newX + ind8.wire.w / 2)) / ind8.pxPerCm)));
  1202. document.getElementById('indDist').value = d;
  1203. document.getElementById('indDistVal').textContent = d;
  1204. return;
  1205. }
  1206. const l = ind8.loop;
  1207. let x1 = l.x1, y1 = l.y1, x2 = l.x1 + l.w, y2 = l.y1 + l.h;
  1208. if (ind8.dragMode === 'tl') { x1 = p.x; y1 = p.y; }
  1209. if (ind8.dragMode === 'tr') { x2 = p.x; y1 = p.y; }
  1210. if (ind8.dragMode === 'bl') { x1 = p.x; y2 = p.y; }
  1211. if (ind8.dragMode === 'br') { x2 = p.x; y2 = p.y; }
  1212. const minW = 50, minH = 50, maxW = 220, maxH = 260;
  1213. if (x2 - x1 < minW) { if (ind8.dragMode === 'tl' || ind8.dragMode === 'bl') x1 = x2 - minW; else x2 = x1 + minW; }
  1214. if (x2 - x1 > maxW) { if (ind8.dragMode === 'tl' || ind8.dragMode === 'bl') x1 = x2 - maxW; else x2 = x1 + maxW; }
  1215. if (y2 - y1 < minH) { if (ind8.dragMode === 'tl' || ind8.dragMode === 'tr') y1 = y2 - minH; else y2 = y1 + minH; }
  1216. if (y2 - y1 > maxH) { if (ind8.dragMode === 'tl' || ind8.dragMode === 'tr') y1 = y2 - maxH; else y2 = y1 + maxH; }
  1217. if (x1 < 20) x1 = 20; if (y1 < 20) y1 = 20;
  1218. if (x2 > 780) x2 = 780; if (y2 > 420) y2 = 420;
  1219. const wireRightEdge = ind8.wire.x + ind8.wire.w / 2;
  1220. if (x1 < wireRightEdge + 1 * ind8.pxPerCm) {
  1221. const shift = (wireRightEdge + 1 * ind8.pxPerCm) - x1;
  1222. x1 += shift; x2 += shift;
  1223. if (ind8.dragMode === 'tl' || ind8.dragMode === 'bl') x1 = wireRightEdge + 1 * ind8.pxPerCm;
  1224. }
  1225. l.x1 = x1; l.y1 = y1; l.w = x2 - x1; l.h = y2 - y1;
  1226. const areaCm2 = Math.round((l.w * l.h) / 250);
  1227. document.getElementById('indArea').value = Math.max(0, Math.min(100, areaCm2));
  1228. document.getElementById('indAreaVal').textContent = Math.max(0, Math.min(100, areaCm2));
  1229. const distPx = l.x1 - wireRightEdge;
  1230. const distCm = Math.round(distPx / ind8.pxPerCm);
  1231. document.getElementById('indDist').value = Math.max(1, Math.min(20, distCm));
  1232. document.getElementById('indDistVal').textContent = Math.max(1, Math.min(20, distCm));
  1233. }
  1234. function onInd8Up() {
  1235. if (ind8.dragMode) { ind8.dragMode = null; ind8.canvas.style.cursor = 'default'; }
  1236. }
  1237. function applyInd8DistSlider() {
  1238. const d = parseFloat(document.getElementById('indDist').value);
  1239. ind8.wire.x = ind8.loop.x1 - d * ind8.pxPerCm - ind8.wire.w / 2;
  1240. if (ind8.wire.x < 30) ind8.wire.x = 30;
  1241. }
  1242. function applyInd8AreaSlider() {
  1243. const S = parseFloat(document.getElementById('indArea').value);
  1244. const targetArea = Math.max(2500, S * 250);
  1245. const aspect = ind8.loop.w / ind8.loop.h || 1;
  1246. let newH = Math.sqrt(targetArea / aspect);
  1247. let newW = newH * aspect;
  1248. if (newW < 50) { newW = 50; newH = targetArea / 50; }
  1249. if (newH < 50) { newH = 50; newW = targetArea / 50; }
  1250. if (newW > 220) { newW = 220; newH = targetArea / 220; }
  1251. if (newH > 260) { newH = 260; newW = targetArea / 260; }
  1252. ind8.loop.w = newW; ind8.loop.h = newH;
  1253. }
  1254. function updateInductive() {
  1255. document.getElementById('indCurrentVal').textContent = document.getElementById('indCurrent').value;
  1256. document.getElementById('indFreqVal').textContent = document.getElementById('indFreq').value;
  1257. document.getElementById('indDistVal').textContent = document.getElementById('indDist').value;
  1258. document.getElementById('indAreaVal').textContent = document.getElementById('indArea').value;
  1259. }
  1260. function drawInd8() {
  1261. const sceneEl = document.querySelector('.scene[data-scene="8"]');
  1262. if (!sceneEl || !sceneEl.classList.contains('active')) { requestAnimationFrame(drawInd8); return; }
  1263. if (!ind8.ctx) { requestAnimationFrame(drawInd8); return; }
  1264. const now = performance.now();
  1265. let dt = (now - ind8.lastT) / 1000;
  1266. ind8.lastT = now;
  1267. if (dt > 0.15) dt = 0.15;
  1268. if (dt < 0) dt = 0;
  1269. const I = parseFloat(document.getElementById('indCurrent').value);
  1270. const f = parseFloat(document.getElementById('indFreq').value);
  1271. const apparentF = f / 200;
  1272. if (f > 1) ind8.phase += 2 * Math.PI * apparentF * dt;
  1273. const B = I * Math.cos(ind8.phase);
  1274. const Babs = Math.min(1, Math.abs(B) / 10);
  1275. const ctx = ind8.ctx, cw = ind8.canvas.width, ch = ind8.canvas.height;
  1276. ctx.fillStyle = '#f2e9d6'; ctx.fillRect(0, 0, cw, ch);
  1277. const l = ind8.loop;
  1278. const lx1 = l.x1, ly1 = l.y1, lx2 = l.x1 + l.w, ly2 = l.y1 + l.h;
  1279. const wireRight = ind8.wire.x + ind8.wire.w / 2;
  1280. const distPx = Math.max(1, lx1 - wireRight);
  1281. const distCm = distPx / ind8.pxPerCm;
  1282. const areaCm2 = (l.w * l.h) / 250;
  1283. drawInd8Field(ctx, I, Babs, ind8.wire.x, ind8.wire.cy);
  1284. drawInd8Wire(ctx, ind8.wire, B);
  1285. drawInd8Loop(ctx, lx1, ly1, lx2, ly2);
  1286. drawInd8Distance(ctx, wireRight, lx1, (ly1 + ly2) / 2, distCm);
  1287. let emfInst = 0, emfPeak = 0;
  1288. if (f > 1 && I > 0 && areaCm2 > 0) {
  1289. const base = 0.02 * I * areaCm2 * apparentF / Math.max(1, distCm);
  1290. emfPeak = Math.min(base, 99.9);
  1291. emfInst = emfPeak * Math.sin(ind8.phase);
  1292. }
  1293. drawInd8EmfArrow(ctx, lx1, ly1, lx2, ly2, emfInst, emfPeak);
  1294. ctx.fillStyle = '#4a5a7a'; ctx.font = '11px "Roboto Mono", monospace';
  1295. ctx.textAlign = 'left'; ctx.textBaseline = 'alphabetic';
  1296. ctx.fillText('S = ' + areaCm2.toFixed(0) + ' см²', lx1 + 4, ly1 - 24);
  1297. const emfEl = document.getElementById('indResult');
  1298. if (emfEl) emfEl.textContent = emfInst.toFixed(1);
  1299. const peakEl = document.getElementById('indPeak');
  1300. if (peakEl) peakEl.textContent = emfPeak.toFixed(1);
  1301. const fbEl = document.getElementById('indFeedback');
  1302. if (fbEl) {
  1303. let msg = '';
  1304. if (I === 0) msg = 'Ток = 0 → магнитного поля нет → ЭДС = 0.';
  1305. else if (f <= 1) msg = 'Частота = 0 (постоянный ток) → поле не меняется → ЭДС = 0.';
  1306. else if (areaCm2 < 15) msg = 'Площадь петли маленькая → поток захватывается слабо.';
  1307. else {
  1308. const parts = [];
  1309. if (I >= 7) parts.push('ток большой → поле сильное');
  1310. if (f >= 700) parts.push('частота высокая → поле меняется быстро');
  1311. if (areaCm2 >= 70) parts.push('площадь большая → поток велик');
  1312. if (distCm <= 5) parts.push('расстояние маленькое → поле не ослабло');
  1313. if (parts.length === 0) parts.push('значения в среднем диапазоне');
  1314. msg = 'Амплитуда ЭДС: ' + parts.join(', ') + '.';
  1315. }
  1316. fbEl.textContent = msg;
  1317. }
  1318. requestAnimationFrame(drawInd8);
  1319. }
  1320. function drawInd8Field(ctx, I, Babs, cx, cy) {
  1321. if (I <= 0) return;
  1322. const numLines = Math.max(1, Math.round(I * 1.4));
  1323. const alpha = 0.08 + Babs * 0.85;
  1324. const lw = 0.8 + Babs * 2.5;
  1325. for (let i = 1; i <= numLines; i++) {
  1326. const r = 30 + (i / numLines) * 260;
  1327. if (Babs > 0.4) { ctx.shadowColor = `rgba(255,140,50,${Babs * 0.55})`; ctx.shadowBlur = 6 + Babs * 10; }
  1328. ctx.strokeStyle = `rgba(139,26,26,${alpha})`; ctx.lineWidth = lw;
  1329. ctx.beginPath(); ctx.ellipse(cx, cy, r * 0.7, r, 0, 0, Math.PI * 2); ctx.stroke();
  1330. ctx.shadowBlur = 0; ctx.shadowColor = 'transparent';
  1331. }
  1332. }
  1333. function drawInd8Wire(ctx, wire, B) {
  1334. const x = wire.x, w = wire.w, y = wire.cy - wire.h / 2, h = wire.h;
  1335. ctx.fillStyle = 'rgba(0,0,0,0.15)'; ctx.fillRect(x - w/2 + 3, y + 3, w, h);
  1336. ctx.fillStyle = '#8b1a1a'; ctx.fillRect(x - w/2, y, w, h);
  1337. ctx.strokeStyle = '#1a2a4a'; ctx.lineWidth = 2; ctx.strokeRect(x - w/2, y, w, h);
  1338. const dir = B >= 0 ? -1 : 1;
  1339. const numArrows = 5, arrowY0 = y + 40, arrowStep = (h - 80) / (numArrows - 1);
  1340. ctx.fillStyle = 'rgba(255,255,255,0.9)';
  1341. for (let i = 0; i < numArrows; i++) {
  1342. const ay = arrowY0 + i * arrowStep, tip = ay + 8 * dir;
  1343. ctx.beginPath(); ctx.moveTo(x, tip); ctx.lineTo(x - 6, ay); ctx.lineTo(x + 6, ay); ctx.closePath(); ctx.fill();
  1344. }
  1345. ctx.fillStyle = '#8b1a1a'; ctx.font = 'bold 14px "Roboto Mono", monospace';
  1346. ctx.textAlign = 'center'; ctx.textBaseline = 'alphabetic';
  1347. ctx.fillText('I', x, y - 12);
  1348. ctx.fillStyle = '#4a5a7a'; ctx.font = '11px "Roboto Mono", monospace';
  1349. ctx.fillText('источник', x, y + h + 20);
  1350. }
  1351. function drawInd8Loop(ctx, x1, y1, x2, y2) {
  1352. ctx.fillStyle = 'rgba(42,90,42,0.04)'; ctx.fillRect(x1, y1, x2 - x1, y2 - y1);
  1353. ctx.strokeStyle = '#2a5a2a'; ctx.lineWidth = 4; ctx.strokeRect(x1, y1, x2 - x1, y2 - y1);
  1354. const corners = [[x1,y1],[x2,y1],[x1,y2],[x2,y2]];
  1355. corners.forEach(([cx,cy]) => {
  1356. ctx.fillStyle = '#2a5a2a'; ctx.beginPath(); ctx.arc(cx, cy, 7, 0, Math.PI*2); ctx.fill();
  1357. ctx.strokeStyle = '#fffef8'; ctx.lineWidth = 2; ctx.stroke();
  1358. });
  1359. ctx.fillStyle = '#2a5a2a'; ctx.font = '11px "Roboto Mono", monospace';
  1360. ctx.textAlign = 'center'; ctx.textBaseline = 'alphabetic';
  1361. ctx.fillText('петля', (x1+x2)/2, y2 + 20);
  1362. }
  1363. function drawInd8Distance(ctx, x1, x2, y, distCm) {
  1364. ctx.strokeStyle = 'rgba(74,90,122,0.55)'; ctx.lineWidth = 1; ctx.setLineDash([4, 4]);
  1365. ctx.beginPath(); ctx.moveTo(x1 + 4, y); ctx.lineTo(x2 - 4, y); ctx.stroke();
  1366. ctx.setLineDash([]);
  1367. ctx.fillStyle = 'rgba(74,90,122,0.85)';
  1368. ctx.beginPath(); ctx.moveTo(x1 + 4, y); ctx.lineTo(x1 + 14, y - 5); ctx.lineTo(x1 + 14, y + 5); ctx.closePath(); ctx.fill();
  1369. ctx.beginPath(); ctx.moveTo(x2 - 4, y); ctx.lineTo(x2 - 14, y - 5); ctx.lineTo(x2 - 14, y + 5); ctx.closePath(); ctx.fill();
  1370. ctx.fillStyle = '#1a2a4a'; ctx.font = 'bold 12px "Roboto Mono", monospace';
  1371. ctx.textAlign = 'center'; ctx.textBaseline = 'bottom';
  1372. ctx.fillText('d = ' + distCm.toFixed(1) + ' см', (x1 + x2) / 2, y - 6);
  1373. }
  1374. function drawInd8EmfArrow(ctx, x1, y1, x2, y2, emf, peak) {
  1375. const maxEmf = 30;
  1376. const instRatio = Math.min(1, Math.abs(emf) / maxEmf);
  1377. const peakRatio = Math.min(1, Math.abs(peak) / maxEmf);
  1378. if (peakRatio < 0.02 && instRatio < 0.02) return;
  1379. const cx = (x1 + x2) / 2, cy = (y1 + y2) / 2;
  1380. const baseR = Math.min(x2 - x1, y2 - y1) * 0.28;
  1381. if (baseR < 8) return;
  1382. const spanFactor = 0.25 + 0.75 * peakRatio;
  1383. const lw = 1.5 + instRatio * 3.5;
  1384. const alpha = 0.25 + instRatio * 0.7;
  1385. const A = -Math.PI * 0.85 * spanFactor;
  1386. const B = Math.PI * 0.55 * spanFactor;
  1387. const r = baseR;
  1388. const clockwise = emf >= 0;
  1389. ctx.save();
  1390. ctx.translate(cx, cy);
  1391. ctx.strokeStyle = `rgba(139,26,26,${alpha})`;
  1392. ctx.lineWidth = lw; ctx.lineCap = 'round';
  1393. let hx, hy, tang;
  1394. if (clockwise) {
  1395. ctx.beginPath(); ctx.arc(0, 0, r, A, B, false); ctx.stroke();
  1396. hx = Math.cos(B) * r; hy = Math.sin(B) * r; tang = B + Math.PI / 2;
  1397. } else {
  1398. ctx.beginPath(); ctx.arc(0, 0, r, B, A, true); ctx.stroke();
  1399. hx = Math.cos(A) * r; hy = Math.sin(A) * r; tang = A - Math.PI / 2;
  1400. }
  1401. const size = 5 + instRatio * 7;
  1402. const tipX = hx + Math.cos(tang) * size, tipY = hy + Math.sin(tang) * size;
  1403. const perpX = Math.cos(tang + Math.PI / 2), perpY = Math.sin(tang + Math.PI / 2);
  1404. const baseX1 = hx + perpX * size * 0.6, baseY1 = hy + perpY * size * 0.6;
  1405. const baseX2 = hx - perpX * size * 0.6, baseY2 = hy - perpY * size * 0.6;
  1406. ctx.beginPath(); ctx.moveTo(tipX, tipY); ctx.lineTo(baseX1, baseY1); ctx.lineTo(baseX2, baseY2); ctx.closePath();
  1407. ctx.fillStyle = `rgba(139,26,26,${alpha})`; ctx.fill();
  1408. ctx.restore(); ctx.lineCap = 'butt';
  1409. ctx.fillStyle = '#8b1a1a'; ctx.font = 'bold 11px "Roboto Mono", monospace';
  1410. ctx.textAlign = 'center'; ctx.textBaseline = 'middle';
  1411. const sign = emf >= 0 ? '+' : '−';
  1412. ctx.fillText(sign + ' ' + Math.abs(peak).toFixed(1) + ' мВ', cx, cy + r + 18);
  1413. }
  1414. // === СЦЕНА 9: ёмкостная ===
  1415. const cap8 = {
  1416. canvas: null, ctx: null,
  1417. src: { x: 280, w: 26, h: 280, cy: 220 },
  1418. recv: { x1: 560, y1: 140, w: 40, h: 160 },
  1419. pxPerCm: 18, phase: 0, lastT: 0,
  1420. dragMode: null, dragOffset: { x: 0 },
  1421. initialized: false
  1422. };
  1423. function initCapacitive8() {
  1424. const c = document.getElementById('capacitiveViz');
  1425. if (!c) return;
  1426. cap8.canvas = c;
  1427. cap8.ctx = c.getContext('2d');
  1428. if (!cap8.initialized) {
  1429. cap8.initialized = true;
  1430. c.addEventListener('mousedown', onCap8Down);
  1431. c.addEventListener('mousemove', onCap8Move);
  1432. c.addEventListener('mouseup', onCap8Up);
  1433. c.addEventListener('mouseleave', onCap8Up);
  1434. c.addEventListener('touchstart', onCap8Down, { passive: false });
  1435. c.addEventListener('touchmove', onCap8Move, { passive: false });
  1436. c.addEventListener('touchend', onCap8Up);
  1437. c.addEventListener('touchcancel', onCap8Up);
  1438. ['capVolt', 'capFreq'].forEach(id => {
  1439. document.getElementById(id).addEventListener('input', updateCapacitive8);
  1440. });
  1441. document.getElementById('capDist').addEventListener('input', function() {
  1442. applyCap8DistSlider(); updateCapacitive8();
  1443. });
  1444. document.getElementById('capArea').addEventListener('input', function() {
  1445. applyCap8AreaSlider(); updateCapacitive8();
  1446. });
  1447. applyCap8AreaSlider();
  1448. applyCap8DistSlider();
  1449. cap8.lastT = performance.now();
  1450. requestAnimationFrame(drawCap8);
  1451. }
  1452. }
  1453. function getCap8Coords(e) {
  1454. const c = cap8.canvas, rect = c.getBoundingClientRect();
  1455. const sx = c.width / rect.width, sy = c.height / rect.height;
  1456. let cx, cy;
  1457. if (e.touches && e.touches.length) { cx = e.touches[0].clientX; cy = e.touches[0].clientY; }
  1458. else { cx = e.clientX; cy = e.clientY; }
  1459. return { x: (cx - rect.left) * sx, y: (cy - rect.top) * sy };
  1460. }
  1461. function onCap8Down(e) {
  1462. e.preventDefault();
  1463. const p = getCap8Coords(e);
  1464. const r = cap8.recv;
  1465. const corners = [
  1466. { name: 'tl', x: r.x1, y: r.y1 }, { name: 'tr', x: r.x1 + r.w, y: r.y1 },
  1467. { name: 'bl', x: r.x1, y: r.y1 + r.h }, { name: 'br', x: r.x1 + r.w, y: r.y1 + r.h }
  1468. ];
  1469. for (const c of corners) {
  1470. if (Math.hypot(p.x - c.x, p.y - c.y) < 18) { cap8.dragMode = c.name; return; }
  1471. }
  1472. const s = cap8.src;
  1473. if (p.x >= s.x - s.w/2 - 8 && p.x <= s.x + s.w/2 + 8 && p.y >= s.cy - s.h/2 && p.y <= s.cy + s.h/2) {
  1474. cap8.dragMode = 'src'; cap8.dragOffset.x = p.x - s.x;
  1475. cap8.canvas.style.cursor = 'grabbing';
  1476. }
  1477. }
  1478. function onCap8Move(e) {
  1479. const p = getCap8Coords(e);
  1480. if (!cap8.dragMode) {
  1481. const r = cap8.recv;
  1482. const corners = [[r.x1, r.y1], [r.x1 + r.w, r.y1], [r.x1, r.y1 + r.h], [r.x1 + r.w, r.y1 + r.h]];
  1483. let overCorner = false;
  1484. for (const [cx, cy] of corners) if (Math.hypot(p.x - cx, p.y - cy) < 18) { overCorner = true; break; }
  1485. if (overCorner) cap8.canvas.style.cursor = 'nwse-resize';
  1486. else if (Math.abs(p.x - cap8.src.x) < 20 && p.y > 60 && p.y < 380) cap8.canvas.style.cursor = 'grab';
  1487. else cap8.canvas.style.cursor = 'default';
  1488. return;
  1489. }
  1490. e.preventDefault();
  1491. if (cap8.dragMode === 'src') {
  1492. let newX = p.x - cap8.dragOffset.x;
  1493. const recvLeft = cap8.recv.x1;
  1494. const minDistPx = 1 * cap8.pxPerCm, maxDistPx = 20 * cap8.pxPerCm;
  1495. const srcRightEdge = newX + cap8.src.w / 2;
  1496. let distPx = recvLeft - srcRightEdge;
  1497. if (distPx < minDistPx) newX = recvLeft - minDistPx - cap8.src.w / 2;
  1498. if (distPx > maxDistPx) newX = recvLeft - maxDistPx - cap8.src.w / 2;
  1499. if (newX < 30) newX = 30;
  1500. cap8.src.x = newX;
  1501. const d = Math.max(1, Math.min(20, Math.round((recvLeft - (newX + cap8.src.w / 2)) / cap8.pxPerCm)));
  1502. document.getElementById('capDist').value = d;
  1503. document.getElementById('capDistVal').textContent = d;
  1504. return;
  1505. }
  1506. const r = cap8.recv;
  1507. let x1 = r.x1, y1 = r.y1, x2 = r.x1 + r.w, y2 = r.y1 + r.h;
  1508. if (cap8.dragMode === 'tl') { x1 = p.x; y1 = p.y; }
  1509. if (cap8.dragMode === 'tr') { x2 = p.x; y1 = p.y; }
  1510. if (cap8.dragMode === 'bl') { x1 = p.x; y2 = p.y; }
  1511. if (cap8.dragMode === 'br') { x2 = p.x; y2 = p.y; }
  1512. const minW = 24, minH = 60, maxW = 80, maxH = 300;
  1513. if (x2 - x1 < minW) { if (cap8.dragMode === 'tl' || cap8.dragMode === 'bl') x1 = x2 - minW; else x2 = x1 + minW; }
  1514. if (x2 - x1 > maxW) { if (cap8.dragMode === 'tl' || cap8.dragMode === 'bl') x1 = x2 - maxW; else x2 = x1 + maxW; }
  1515. if (y2 - y1 < minH) { if (cap8.dragMode === 'tl' || cap8.dragMode === 'tr') y1 = y2 - minH; else y2 = y1 + minH; }
  1516. if (y2 - y1 > maxH) { if (cap8.dragMode === 'tl' || cap8.dragMode === 'tr') y1 = y2 - maxH; else y2 = y1 + maxH; }
  1517. if (x1 < 20) x1 = 20; if (y1 < 40) y1 = 40;
  1518. if (x2 > 780) x2 = 780; if (y2 > 400) y2 = 400;
  1519. const srcRightEdge = cap8.src.x + cap8.src.w / 2;
  1520. if (x1 < srcRightEdge + 1 * cap8.pxPerCm) {
  1521. x1 = srcRightEdge + 1 * cap8.pxPerCm;
  1522. if (x2 - x1 < minW) x2 = x1 + minW;
  1523. }
  1524. r.x1 = x1; r.y1 = y1; r.w = x2 - x1; r.h = y2 - y1;
  1525. const areaCm2 = Math.round((r.w * r.h) / 200);
  1526. document.getElementById('capArea').value = Math.max(0, Math.min(100, areaCm2));
  1527. document.getElementById('capAreaVal').textContent = Math.max(0, Math.min(100, areaCm2));
  1528. const distPx = r.x1 - srcRightEdge;
  1529. const distCm = Math.round(distPx / cap8.pxPerCm);
  1530. document.getElementById('capDist').value = Math.max(1, Math.min(20, distCm));
  1531. document.getElementById('capDistVal').textContent = Math.max(1, Math.min(20, distCm));
  1532. }
  1533. function onCap8Up() {
  1534. if (cap8.dragMode) { cap8.dragMode = null; cap8.canvas.style.cursor = 'default'; }
  1535. }
  1536. function applyCap8DistSlider() {
  1537. const d = parseFloat(document.getElementById('capDist').value);
  1538. cap8.src.x = cap8.recv.x1 - d * cap8.pxPerCm - cap8.src.w / 2;
  1539. if (cap8.src.x < 30) cap8.src.x = 30;
  1540. }
  1541. function applyCap8AreaSlider() {
  1542. const S = parseFloat(document.getElementById('capArea').value);
  1543. const targetArea = Math.max(1800, S * 200);
  1544. const aspect = cap8.recv.w / cap8.recv.h || 0.3;
  1545. let newH = Math.sqrt(targetArea / aspect);
  1546. let newW = newH * aspect;
  1547. if (newW < 24) { newW = 24; newH = targetArea / 24; }
  1548. if (newH < 60) { newH = 60; newW = targetArea / 60; }
  1549. if (newW > 80) { newW = 80; newH = targetArea / 80; }
  1550. if (newH > 300) { newH = 300; newW = targetArea / 300; }
  1551. cap8.recv.w = newW; cap8.recv.h = newH;
  1552. }
  1553. function updateCapacitive8() {
  1554. document.getElementById('capVoltVal').textContent = document.getElementById('capVolt').value;
  1555. document.getElementById('capFreqVal').textContent = document.getElementById('capFreq').value;
  1556. document.getElementById('capDistVal').textContent = document.getElementById('capDist').value;
  1557. document.getElementById('capAreaVal').textContent = document.getElementById('capArea').value;
  1558. }
  1559. function drawCap8() {
  1560. const sceneEl = document.querySelector('.scene[data-scene="9"]');
  1561. if (!sceneEl || !sceneEl.classList.contains('active')) { requestAnimationFrame(drawCap8); return; }
  1562. if (!cap8.ctx) { requestAnimationFrame(drawCap8); return; }
  1563. const now = performance.now();
  1564. let dt = (now - cap8.lastT) / 1000;
  1565. cap8.lastT = now;
  1566. if (dt > 0.15) dt = 0.15;
  1567. if (dt < 0) dt = 0;
  1568. const U = parseFloat(document.getElementById('capVolt').value);
  1569. const f = parseFloat(document.getElementById('capFreq').value);
  1570. const apparentF = f / 200;
  1571. if (f > 1) cap8.phase += 2 * Math.PI * apparentF * dt;
  1572. const Uinst = U * Math.cos(cap8.phase);
  1573. const Uabs = Math.min(1, Math.abs(Uinst) / 1000);
  1574. const ctx = cap8.ctx, cw = cap8.canvas.width, ch = cap8.canvas.height;
  1575. ctx.fillStyle = '#f2e9d6'; ctx.fillRect(0, 0, cw, ch);
  1576. const s = cap8.src, r = cap8.recv;
  1577. const srcRight = s.x + s.w / 2, recvLeft = r.x1;
  1578. const distPx = Math.max(1, recvLeft - srcRight);
  1579. const distCm = distPx / cap8.pxPerCm;
  1580. const areaCm2 = (r.w * r.h) / 200;
  1581. const overlapTop = Math.max(s.cy - s.h/2, r.y1);
  1582. const overlapBot = Math.min(s.cy + s.h/2, r.y1 + r.h);
  1583. const polarity = Uinst >= 0 ? 1 : -1;
  1584. drawCap8Field(ctx, srcRight, recvLeft, overlapTop, overlapBot, U, Uabs, polarity);
  1585. drawCap8Source(ctx, s, Uinst);
  1586. drawCap8Receiver(ctx, r, Uinst, Uabs, areaCm2);
  1587. drawCap8Distance(ctx, srcRight, recvLeft, (overlapTop + overlapBot) / 2, distCm);
  1588. let vInst = 0, vPeak = 0;
  1589. if (f > 1 && U > 0 && areaCm2 > 0) {
  1590. const base = 0.02 * U * areaCm2 * apparentF / Math.max(1, distCm * distCm);
  1591. vPeak = Math.min(base, 99.9);
  1592. vInst = vPeak * Math.sin(cap8.phase);
  1593. }
  1594. drawCap8CurrentArrow(ctx, srcRight, recvLeft, overlapTop, overlapBot, vInst, vPeak, f);
  1595. ctx.fillStyle = '#4a5a7a'; ctx.font = '11px "Roboto Mono", monospace';
  1596. ctx.textAlign = 'left'; ctx.textBaseline = 'alphabetic';
  1597. ctx.fillText('S = ' + areaCm2.toFixed(0) + ' см²', r.x1 - 4, r.y1 - 24);
  1598. const resEl = document.getElementById('capResult');
  1599. if (resEl) resEl.textContent = vInst.toFixed(1);
  1600. const peakEl = document.getElementById('capPeak');
  1601. if (peakEl) peakEl.textContent = vPeak.toFixed(1);
  1602. const fbEl = document.getElementById('capFeedback');
  1603. if (fbEl) {
  1604. let msg = '';
  1605. if (U === 0) msg = 'Напряжение = 0 → электрического поля нет → наведённый заряд = 0.';
  1606. else if (f <= 1) msg = 'Частота = 0 (постоянное напряжение) → поле не меняется → наводки нет.';
  1607. else if (areaCm2 < 15) msg = 'Площадь перекрытия мала → ёмкость связи слабая.';
  1608. else {
  1609. const parts = [];
  1610. if (U >= 700) parts.push('напряжение большое → поле сильное');
  1611. if (f >= 700) parts.push('частота высокая → поле меняется быстро');
  1612. if (areaCm2 >= 70) parts.push('площадь большая → ёмкость больше');
  1613. if (distCm <= 5) parts.push('расстояние маленькое → поле не ослабло');
  1614. if (parts.length === 0) parts.push('значения в среднем диапазоне');
  1615. msg = 'Амплитуда наводки: ' + parts.join(', ') + '.';
  1616. }
  1617. fbEl.textContent = msg;
  1618. }
  1619. requestAnimationFrame(drawCap8);
  1620. }
  1621. function drawCap8Field(ctx, x1, x2, top, bot, U, Uabs, polarity) {
  1622. if (U <= 0 || bot <= top) return;
  1623. const height = bot - top;
  1624. const numLines = Math.max(1, Math.round(U / 100));
  1625. const alpha = 0.08 + Uabs * 0.85;
  1626. const lw = 0.8 + Uabs * 2.3;
  1627. const rCol = polarity > 0 ? 26 : 139;
  1628. const gCol = polarity > 0 ? 74 : 26;
  1629. const bCol = polarity > 0 ? 106 : 26;
  1630. for (let i = 0; i < numLines; i++) {
  1631. const t = numLines === 1 ? 0.5 : i / (numLines - 1);
  1632. const y = top + t * height;
  1633. if (Uabs > 0.4) { ctx.shadowColor = `rgba(255,140,50,${Uabs * 0.5})`; ctx.shadowBlur = 6 + Uabs * 8; }
  1634. ctx.strokeStyle = `rgba(${rCol},${gCol},${bCol},${alpha})`; ctx.lineWidth = lw;
  1635. ctx.beginPath(); ctx.moveTo(x1, y); ctx.lineTo(x2, y); ctx.stroke();
  1636. ctx.shadowBlur = 0; ctx.shadowColor = 'transparent';
  1637. }
  1638. }
  1639. function drawCap8Source(ctx, s, Uinst) {
  1640. const x = s.x - s.w / 2, y = s.cy - s.h / 2;
  1641. ctx.fillStyle = 'rgba(0,0,0,0.15)'; ctx.fillRect(x + 3, y + 3, s.w, s.h);
  1642. ctx.fillStyle = '#1a4a6a'; ctx.fillRect(x, y, s.w, s.h);
  1643. ctx.strokeStyle = '#1a2a4a'; ctx.lineWidth = 2; ctx.strokeRect(x, y, s.w, s.h);
  1644. const polarity = Uinst >= 0 ? '+' : '−';
  1645. ctx.fillStyle = 'rgba(255,255,255,0.92)'; ctx.font = 'bold 16px "PT Serif", serif';
  1646. ctx.textAlign = 'center'; ctx.textBaseline = 'middle';
  1647. const num = 7;
  1648. for (let i = 0; i < num; i++) {
  1649. const py = y + 30 + i * (s.h - 60) / (num - 1);
  1650. ctx.fillText(polarity, s.x, py);
  1651. }
  1652. ctx.fillStyle = '#1a4a6a'; ctx.font = 'bold 14px "Roboto Mono", monospace';
  1653. ctx.textAlign = 'center'; ctx.textBaseline = 'alphabetic'; ctx.fillText('U', s.x, y - 12);
  1654. ctx.fillStyle = '#4a5a7a'; ctx.font = '11px "Roboto Mono", monospace';
  1655. ctx.fillText('источник', s.x, y + s.h + 20);
  1656. }
  1657. function drawCap8Receiver(ctx, r, Uinst, Uabs, areaCm2) {
  1658. ctx.fillStyle = 'rgba(42,90,42,0.06)'; ctx.fillRect(r.x1, r.y1, r.w, r.h);
  1659. ctx.strokeStyle = '#2a5a2a'; ctx.lineWidth = 4; ctx.strokeRect(r.x1, r.y1, r.w, r.h);
  1660. const corners = [[r.x1, r.y1], [r.x1 + r.w, r.y1], [r.x1, r.y1 + r.h], [r.x1 + r.w, r.y1 + r.h]];
  1661. corners.forEach(([cx, cy]) => {
  1662. ctx.fillStyle = '#2a5a2a'; ctx.beginPath(); ctx.arc(cx, cy, 7, 0, Math.PI * 2); ctx.fill();
  1663. ctx.strokeStyle = '#fffef8'; ctx.lineWidth = 2; ctx.stroke();
  1664. });
  1665. const polarity = Uinst >= 0 ? '−' : '+';
  1666. const numCharges = Math.floor(areaCm2 / 15);
  1667. if (numCharges > 0) {
  1668. const maxN = Math.min(numCharges, 10);
  1669. const step = (r.h - 40) / Math.max(1, maxN - 1);
  1670. ctx.fillStyle = '#8b1a1a'; ctx.font = 'bold 14px "PT Serif", serif';
  1671. ctx.textAlign = 'center'; ctx.textBaseline = 'middle';
  1672. for (let i = 0; i < maxN; i++) ctx.fillText(polarity, r.x1 + r.w / 2, r.y1 + 20 + i * step);
  1673. }
  1674. ctx.fillStyle = '#2a5a2a'; ctx.font = '11px "Roboto Mono", monospace';
  1675. ctx.textAlign = 'center'; ctx.textBaseline = 'alphabetic';
  1676. ctx.fillText('приёмник', r.x1 + r.w / 2, r.y1 + r.h + 20);
  1677. }
  1678. function drawCap8Distance(ctx, x1, x2, y, distCm) {
  1679. if (y <= 0 || y >= 440) y = 220;
  1680. ctx.strokeStyle = 'rgba(74,90,122,0.55)'; ctx.lineWidth = 1; ctx.setLineDash([4, 4]);
  1681. ctx.beginPath(); ctx.moveTo(x1 + 4, y); ctx.lineTo(x2 - 4, y); ctx.stroke();
  1682. ctx.setLineDash([]);
  1683. ctx.fillStyle = 'rgba(74,90,122,0.85)';
  1684. ctx.beginPath(); ctx.moveTo(x1 + 4, y); ctx.lineTo(x1 + 14, y - 5); ctx.lineTo(x1 + 14, y + 5); ctx.closePath(); ctx.fill();
  1685. ctx.beginPath(); ctx.moveTo(x2 - 4, y); ctx.lineTo(x2 - 14, y - 5); ctx.lineTo(x2 - 14, y + 5); ctx.closePath(); ctx.fill();
  1686. ctx.fillStyle = '#1a2a4a'; ctx.font = 'bold 12px "Roboto Mono", monospace';
  1687. ctx.textAlign = 'center'; ctx.textBaseline = 'bottom';
  1688. ctx.fillText('d = ' + distCm.toFixed(1) + ' см', (x1 + x2) / 2, y - 6);
  1689. }
  1690. function drawCap8CurrentArrow(ctx, x1, x2, top, bot, inst, peak, f) {
  1691. if (f <= 1) return;
  1692. const midX = (x1 + x2) / 2, midY = (top + bot) / 2;
  1693. if (!isFinite(midY)) return;
  1694. const instRatio = Math.min(1, Math.abs(inst) / 30);
  1695. const peakRatio = Math.min(1, Math.abs(peak) / 30);
  1696. if (peakRatio < 0.02 && instRatio < 0.02) return;
  1697. const alpha = 0.25 + instRatio * 0.7;
  1698. const lw = 1.5 + instRatio * 2.5;
  1699. const baseLen = Math.min(40, (x2 - x1) * 0.3);
  1700. if (baseLen < 6) return;
  1701. const arrowLen = baseLen * (0.25 + 0.75 * peakRatio);
  1702. const dir = inst >= 0 ? 1 : -1;
  1703. const tipX = midX + dir * arrowLen;
  1704. const tailX = midX - dir * arrowLen * 0.4;
  1705. ctx.strokeStyle = `rgba(139,26,26,${alpha})`; ctx.lineWidth = lw; ctx.lineCap = 'round';
  1706. ctx.beginPath(); ctx.moveTo(tailX, midY); ctx.lineTo(tipX, midY); ctx.stroke();
  1707. const size = 5 + instRatio * 5;
  1708. ctx.beginPath(); ctx.moveTo(tipX, midY);
  1709. ctx.lineTo(tipX - dir * size, midY - size * 0.6);
  1710. ctx.lineTo(tipX - dir * size, midY + size * 0.6);
  1711. ctx.closePath(); ctx.fillStyle = `rgba(139,26,26,${alpha})`; ctx.fill();
  1712. ctx.lineCap = 'butt';
  1713. ctx.fillStyle = '#8b1a1a'; ctx.font = 'bold 11px "Roboto Mono", monospace';
  1714. ctx.textAlign = 'center'; ctx.textBaseline = 'top';
  1715. const sign = inst >= 0 ? '+' : '−';
  1716. ctx.fillText(sign + ' ' + Math.abs(peak).toFixed(1) + ' мВ', midX, midY + 14);
  1717. }
  1718. // === СЦЕНА 10: гальваническая ===
  1719. const gal8 = {
  1720. canvas: null, ctx: null,
  1721. load: { x: 220, w: 110, h: 80, cy: 110 },
  1722. recv: { x: 560, w: 110, h: 80, cy: 110 },
  1723. wireY: 340,
  1724. gnd: { x: 740 },
  1725. pxPerOhm: 500,
  1726. minLoadX: 90,
  1727. maxLoadX: 350,
  1728. minRecvX: 420,
  1729. maxRecvX: 720,
  1730. dragMode: null,
  1731. dragOffset: { x: 0 },
  1732. lastT: 0,
  1733. initialized: false
  1734. };
  1735. function initGal8() {
  1736. const c = document.getElementById('galvanicViz');
  1737. if (!c) return;
  1738. gal8.canvas = c;
  1739. gal8.ctx = c.getContext('2d');
  1740. if (!gal8.initialized) {
  1741. gal8.initialized = true;
  1742. c.addEventListener('mousedown', onGal8Down);
  1743. c.addEventListener('mousemove', onGal8Move);
  1744. c.addEventListener('mouseup', onGal8Up);
  1745. c.addEventListener('mouseleave', onGal8Up);
  1746. c.addEventListener('touchstart', onGal8Down, { passive: false });
  1747. c.addEventListener('touchmove', onGal8Move, { passive: false });
  1748. c.addEventListener('touchend', onGal8Up);
  1749. c.addEventListener('touchcancel', onGal8Up);
  1750. ['galCurrent', 'galGround'].forEach(id => {
  1751. document.getElementById(id).addEventListener('input', updateGal8);
  1752. });
  1753. document.getElementById('galRes').addEventListener('input', function() {
  1754. applyGal8ResSlider();
  1755. updateGal8();
  1756. });
  1757. applyGal8ResSlider();
  1758. gal8.lastT = performance.now();
  1759. requestAnimationFrame(drawGal8);
  1760. }
  1761. }
  1762. function getGal8Coords(e) {
  1763. const c = gal8.canvas, rect = c.getBoundingClientRect();
  1764. const sx = c.width / rect.width, sy = c.height / rect.height;
  1765. let cx, cy;
  1766. if (e.touches && e.touches.length) { cx = e.touches[0].clientX; cy = e.touches[0].clientY; }
  1767. else { cx = e.clientX; cy = e.clientY; }
  1768. return { x: (cx - rect.left) * sx, y: (cy - rect.top) * sy };
  1769. }
  1770. function gal8HitBox(p, box) {
  1771. return p.x >= box.x - box.w/2 && p.x <= box.x + box.w/2
  1772. && p.y >= box.cy - box.h/2 && p.y <= box.cy + box.h/2;
  1773. }
  1774. function onGal8Down(e) {
  1775. e.preventDefault();
  1776. const p = getGal8Coords(e);
  1777. if (gal8HitBox(p, gal8.load)) {
  1778. gal8.dragMode = 'load';
  1779. gal8.dragOffset.x = p.x - gal8.load.x;
  1780. gal8.canvas.style.cursor = 'grabbing';
  1781. return;
  1782. }
  1783. if (gal8HitBox(p, gal8.recv)) {
  1784. gal8.dragMode = 'recv';
  1785. gal8.dragOffset.x = p.x - gal8.recv.x;
  1786. gal8.canvas.style.cursor = 'grabbing';
  1787. return;
  1788. }
  1789. }
  1790. function onGal8Move(e) {
  1791. const p = getGal8Coords(e);
  1792. if (!gal8.dragMode) {
  1793. if (gal8HitBox(p, gal8.load) || gal8HitBox(p, gal8.recv)) {
  1794. gal8.canvas.style.cursor = 'grab';
  1795. } else {
  1796. gal8.canvas.style.cursor = 'default';
  1797. }
  1798. return;
  1799. }
  1800. e.preventDefault();
  1801. const minDist = 40;
  1802. const maxDist = gal8.maxRecvX - gal8.minLoadX;
  1803. if (gal8.dragMode === 'load') {
  1804. let newX = p.x - gal8.dragOffset.x;
  1805. newX = Math.max(gal8.minLoadX, Math.min(gal8.maxLoadX, newX));
  1806. // ограничение: не заезжать на recv
  1807. const maxAllowed = gal8.recv.x - gal8.recv.w/2 - gal8.load.w/2 - minDist;
  1808. if (newX > maxAllowed) newX = maxAllowed;
  1809. if (newX < gal8.minLoadX) newX = gal8.minLoadX;
  1810. gal8.load.x = newX;
  1811. } else if (gal8.dragMode === 'recv') {
  1812. let newX = p.x - gal8.dragOffset.x;
  1813. newX = Math.max(gal8.minRecvX, Math.min(gal8.maxRecvX, newX));
  1814. const minAllowed = gal8.load.x + gal8.load.w/2 + gal8.recv.w/2 + minDist;
  1815. if (newX < minAllowed) newX = minAllowed;
  1816. if (newX > gal8.maxRecvX) newX = gal8.maxRecvX;
  1817. gal8.recv.x = newX;
  1818. }
  1819. syncGal8ResFromDistance();
  1820. }
  1821. function onGal8Up() {
  1822. if (gal8.dragMode) {
  1823. gal8.dragMode = null;
  1824. gal8.canvas.style.cursor = 'default';
  1825. }
  1826. }
  1827. function gal8Distance() {
  1828. return gal8.recv.x - gal8.recv.w/2 - (gal8.load.x + gal8.load.w/2);
  1829. }
  1830. function gal8Res() {
  1831. const d = gal8Distance();
  1832. return Math.max(0, Math.min(1, d / gal8.pxPerOhm));
  1833. }
  1834. function syncGal8ResFromDistance() {
  1835. const R = gal8Res();
  1836. const slider = document.getElementById('galRes');
  1837. slider.value = R.toFixed(2);
  1838. document.getElementById('galResVal').textContent = R.toFixed(2);
  1839. }
  1840. function applyGal8ResSlider() {
  1841. const R = parseFloat(document.getElementById('galRes').value);
  1842. const d = R * gal8.pxPerOhm;
  1843. // хотим: recvLeft - loadRight = d. Регулируем recv.x
  1844. const minDist = 40;
  1845. const targetRecvX = gal8.load.x + gal8.load.w/2 + d + gal8.recv.w/2;
  1846. let newRecvX = targetRecvX;
  1847. if (newRecvX < gal8.minRecvX) newRecvX = gal8.minRecvX;
  1848. if (newRecvX > gal8.maxRecvX) newRecvX = gal8.maxRecvX;
  1849. // если не помещается, попробуем сдвинуть load влево
  1850. if (newRecvX - gal8.recv.w/2 - gal8.load.w/2 - minDist < gal8.load.x) {
  1851. const newLoadX = newRecvX - gal8.recv.w/2 - gal8.load.w/2 - minDist;
  1852. if (newLoadX >= gal8.minLoadX) {
  1853. gal8.load.x = newLoadX;
  1854. }
  1855. }
  1856. gal8.recv.x = newRecvX;
  1857. // если после корректировки R отличается — не страшно, ползунок останется как есть
  1858. // фактическое R пересчитается в drawGal8
  1859. document.getElementById('galResVal').textContent = R.toFixed(2);
  1860. }
  1861. function updateGal8() {
  1862. document.getElementById('galCurrentVal').textContent = document.getElementById('galCurrent').value;
  1863. document.getElementById('galGroundVal').textContent = document.getElementById('galGround').value;
  1864. }
  1865. function drawGal8() {
  1866. const sceneEl = document.querySelector('.scene[data-scene="10"]');
  1867. if (!sceneEl || !sceneEl.classList.contains('active')) { requestAnimationFrame(drawGal8); return; }
  1868. if (!gal8.ctx) { requestAnimationFrame(drawGal8); return; }
  1869. const ctx = gal8.ctx;
  1870. const cw = gal8.canvas.width, ch = gal8.canvas.height;
  1871. ctx.fillStyle = '#f2e9d6';
  1872. ctx.fillRect(0, 0, cw, ch);
  1873. const I = parseFloat(document.getElementById('galCurrent').value);
  1874. const R = gal8Res();
  1875. const G = parseFloat(document.getElementById('galGround').value);
  1876. const Reff = R * (1 + (100 - G) / 100);
  1877. const load = gal8.load, recv = gal8.recv;
  1878. const wireY = gal8.wireY;
  1879. const loadRight = load.x + load.w/2;
  1880. const recvLeft = recv.x - recv.w/2;
  1881. const recvRight = recv.x + recv.w/2;
  1882. const distPx = Math.max(0, recvLeft - loadRight);
  1883. const distCm = distPx / 10;
  1884. // === Общий провод (y = wireY) ===
  1885. // Толщина и насыщенность общего участка зависят от R
  1886. // Сегмент от нагрузки до recv — это "проблемный" участок
  1887. // Дальше до земли — нейтральный
  1888. // Тень провода
  1889. ctx.strokeStyle = 'rgba(0,0,0,0.12)';
  1890. ctx.lineWidth = 8;
  1891. ctx.beginPath();
  1892. ctx.moveTo(load.x, wireY + 3);
  1893. ctx.lineTo(gal8.gnd.x, wireY + 3);
  1894. ctx.stroke();
  1895. // Нейтральный провод (от recv до земли) — тонкий
  1896. ctx.strokeStyle = '#4a5a7a';
  1897. ctx.lineWidth = 4;
  1898. ctx.beginPath();
  1899. ctx.moveTo(recvRight, wireY);
  1900. ctx.lineTo(gal8.gnd.x, wireY);
  1901. ctx.stroke();
  1902. // Левый участок (от левого края до нагрузки) — тонкий
  1903. ctx.beginPath();
  1904. ctx.moveTo(40, wireY);
  1905. ctx.lineTo(loadRight - 0, wireY);
  1906. ctx.stroke();
  1907. // === Общий участок с сопротивлением (между нагрузкой и recv) ===
  1908. // Толщина растёт с R, цвет — от тёмного к красному
  1909. const commonStartX = load.x;
  1910. const commonEndX = recv.x;
  1911. // Наложение «сопротивления»: толстая полоса с шагом штриховки
  1912. if (distPx > 5) {
  1913. const thick = 4 + R * 8;
  1914. const hue = Math.floor(139 + R * 80);
  1915. const sat = Math.floor(20 + R * 130);
  1916. ctx.strokeStyle = `rgb(${hue},${sat},${sat})`;
  1917. ctx.lineWidth = thick;
  1918. ctx.beginPath();
  1919. ctx.moveTo(loadRight, wireY);
  1920. ctx.lineTo(recvLeft, wireY);
  1921. ctx.stroke();
  1922. // Штриховка/засечки для наглядности сопротивления
  1923. if (R > 0.05) {
  1924. const numTicks = Math.max(3, Math.round(distPx / 25));
  1925. ctx.strokeStyle = `rgba(${hue},${sat},${sat},${0.4 + R * 0.5})`;
  1926. ctx.lineWidth = 1;
  1927. for (let i = 0; i < numTicks; i++) {
  1928. const x = loadRight + 5 + i * (distPx - 10) / Math.max(1, numTicks - 1);
  1929. ctx.beginPath();
  1930. ctx.moveTo(x, wireY - thick/2 - 2);
  1931. ctx.lineTo(x, wireY + thick/2 + 2);
  1932. ctx.stroke();
  1933. }
  1934. }
  1935. }
  1936. // Ток: стрелки на общем проводе
  1937. if (I > 0) {
  1938. const numArrows = 4;
  1939. ctx.fillStyle = 'rgba(139,26,26,0.85)';
  1940. for (let i = 0; i < numArrows; i++) {
  1941. const x = loadRight + (distPx / (numArrows + 1)) * (i + 1);
  1942. if (x > recvLeft - 8) break;
  1943. ctx.beginPath();
  1944. ctx.moveTo(x + 8, wireY);
  1945. ctx.lineTo(x - 4, wireY - 5);
  1946. ctx.lineTo(x - 4, wireY + 5);
  1947. ctx.closePath();
  1948. ctx.fill();
  1949. }
  1950. }
  1951. // === Соединения от блоков к проводу ===
  1952. ctx.strokeStyle = '#8b1a1a';
  1953. ctx.lineWidth = 2;
  1954. ctx.beginPath();
  1955. ctx.moveTo(load.x, load.cy + load.h/2);
  1956. ctx.lineTo(load.x, wireY);
  1957. ctx.stroke();
  1958. ctx.strokeStyle = '#2a5a2a';
  1959. ctx.beginPath();
  1960. ctx.moveTo(recv.x, recv.cy + recv.h/2);
  1961. ctx.lineTo(recv.x, wireY);
  1962. ctx.stroke();
  1963. // === Источник (нагрузка) ===
  1964. ctx.fillStyle = 'rgba(0,0,0,0.15)';
  1965. ctx.fillRect(load.x - load.w/2 + 3, load.cy - load.h/2 + 3, load.w, load.h);
  1966. ctx.fillStyle = '#8b1a1a';
  1967. ctx.fillRect(load.x - load.w/2, load.cy - load.h/2, load.w, load.h);
  1968. ctx.strokeStyle = '#1a2a4a';
  1969. ctx.lineWidth = 2;
  1970. ctx.strokeRect(load.x - load.w/2, load.cy - load.h/2, load.w, load.h);
  1971. // Иконка "нагрузка" — стрелка тока
  1972. const loadDir = I > 0 ? -1 : 1;
  1973. ctx.fillStyle = 'rgba(255,255,255,0.9)';
  1974. for (let i = 0; i < 3; i++) {
  1975. const ay = load.cy - 20 + i * 20;
  1976. const tip = ay + 8 * loadDir;
  1977. ctx.beginPath();
  1978. ctx.moveTo(load.x, tip);
  1979. ctx.lineTo(load.x - 7, ay);
  1980. ctx.lineTo(load.x + 7, ay);
  1981. ctx.closePath();
  1982. ctx.fill();
  1983. }
  1984. ctx.fillStyle = '#fff';
  1985. ctx.font = 'bold 13px "PT Serif", serif';
  1986. ctx.textAlign = 'center';
  1987. ctx.textBaseline = 'middle';
  1988. ctx.fillText('I = ' + I + ' А', load.x, load.cy - load.h/2 - 16);
  1989. ctx.fillStyle = '#8b1a1a';
  1990. ctx.font = 'bold 12px "Roboto Mono", monospace';
  1991. ctx.textBaseline = 'alphabetic';
  1992. ctx.fillText('нагрузка', load.x, load.cy + load.h/2 + 18);
  1993. // === Приёмник (сигнальная цепь) ===
  1994. ctx.fillStyle = 'rgba(0,0,0,0.15)';
  1995. ctx.fillRect(recv.x - recv.w/2 + 3, recv.cy - recv.h/2 + 3, recv.w, recv.h);
  1996. ctx.fillStyle = '#2a5a2a';
  1997. ctx.fillRect(recv.x - recv.w/2, recv.cy - recv.h/2, recv.w, recv.h);
  1998. ctx.strokeStyle = '#1a2a4a';
  1999. ctx.lineWidth = 2;
  2000. ctx.strokeRect(recv.x - recv.w/2, recv.cy - recv.h/2, recv.w, recv.h);
  2001. // Полезный сигнал (синусоида) — постоянный
  2002. const sigY = recv.cy + 8;
  2003. ctx.strokeStyle = 'rgba(255,255,255,0.85)';
  2004. ctx.lineWidth = 2;
  2005. ctx.beginPath();
  2006. for (let x = 0; x < recv.w - 20; x++) {
  2007. const y = sigY + Math.sin(x * 0.3) * 8;
  2008. const xx = recv.x - recv.w/2 + 10 + x;
  2009. if (x === 0) ctx.moveTo(xx, y);
  2010. else ctx.lineTo(xx, y);
  2011. }
  2012. ctx.stroke();
  2013. // Помеха — растущая полоса в приёмнике, зависит от U_помехи
  2014. const U_mV = I * Reff * 100; // учебная шкала: 0..2000
  2015. const U_ratio = Math.min(1, U_mV / 2000);
  2016. if (U_ratio > 0.02) {
  2017. const noiseH = 4 + U_ratio * 20;
  2018. const noiseY = recv.cy + 30;
  2019. const noiseW = (recv.w - 20) * (0.15 + 0.85 * U_ratio);
  2020. // Красная полоса "помехи" на приёмнике
  2021. ctx.fillStyle = `rgba(139,26,26,${0.3 + U_ratio * 0.7})`;
  2022. ctx.fillRect(recv.x - recv.w/2 + 10, noiseY - noiseH/2, noiseW, noiseH);
  2023. // Подпись
  2024. ctx.fillStyle = '#fff';
  2025. ctx.font = 'bold 11px "Roboto Mono", monospace';
  2026. ctx.textAlign = 'center';
  2027. ctx.textBaseline = 'middle';
  2028. ctx.fillText('помеха ' + U_mV.toFixed(0) + ' мВ', recv.x, noiseY);
  2029. }
  2030. // Заголовок приёмника
  2031. ctx.fillStyle = '#fff';
  2032. ctx.font = 'bold 13px "PT Serif", serif';
  2033. ctx.textAlign = 'center';
  2034. ctx.textBaseline = 'middle';
  2035. ctx.fillText('U_полезн = 1 В', recv.x, recv.cy - recv.h/2 + 20);
  2036. ctx.fillStyle = '#2a5a2a';
  2037. ctx.font = 'bold 12px "Roboto Mono", monospace';
  2038. ctx.textBaseline = 'alphabetic';
  2039. ctx.fillText('приёмник', recv.x, recv.cy + recv.h/2 + 18);
  2040. // === Стрелка падения напряжения U = I·R на общем участке ===
  2041. // Над проводом на общем участке
  2042. if (distPx > 20 && U_ratio > 0.02) {
  2043. const arrowStartX = loadRight + 10;
  2044. const arrowEndX = loadRight + 10 + (distPx - 20) * U_ratio;
  2045. const arrowY = wireY - 40 - U_ratio * 20;
  2046. // Подъём вверх
  2047. ctx.strokeStyle = `rgba(139,26,26,${0.5 + U_ratio * 0.5})`;
  2048. ctx.lineWidth = 2 + U_ratio * 2;
  2049. ctx.beginPath();
  2050. ctx.moveTo(arrowStartX, wireY - 8);
  2051. ctx.lineTo(arrowStartX, arrowY);
  2052. ctx.stroke();
  2053. ctx.beginPath();
  2054. ctx.moveTo(arrowStartX, arrowY);
  2055. ctx.lineTo(arrowEndX, arrowY);
  2056. ctx.stroke();
  2057. // Стрелка
  2058. const arrowSize = 6 + U_ratio * 4;
  2059. ctx.beginPath();
  2060. ctx.moveTo(arrowEndX, arrowY);
  2061. ctx.lineTo(arrowEndX - arrowSize, arrowY - arrowSize * 0.7);
  2062. ctx.lineTo(arrowEndX - arrowSize, arrowY + arrowSize * 0.7);
  2063. ctx.closePath();
  2064. ctx.fillStyle = `rgba(139,26,26,${0.6 + U_ratio * 0.4})`;
  2065. ctx.fill();
  2066. // Подпись
  2067. ctx.fillStyle = '#8b1a1a';
  2068. ctx.font = 'bold 12px "Roboto Mono", monospace';
  2069. ctx.textAlign = 'left';
  2070. ctx.textBaseline = 'bottom';
  2071. ctx.fillText('U = I·R = ' + U_mV.toFixed(0) + ' мВ', arrowStartX, arrowY - 6);
  2072. }
  2073. // Расстояние между блоками (пунктир)
  2074. const distY = wireY + 45;
  2075. if (distPx > 10) {
  2076. ctx.strokeStyle = 'rgba(74,90,122,0.6)';
  2077. ctx.lineWidth = 1;
  2078. ctx.setLineDash([4, 4]);
  2079. ctx.beginPath();
  2080. ctx.moveTo(loadRight, distY);
  2081. ctx.lineTo(recvLeft, distY);
  2082. ctx.stroke();
  2083. ctx.setLineDash([]);
  2084. // Стрелки на концах
  2085. ctx.fillStyle = 'rgba(74,90,122,0.85)';
  2086. ctx.beginPath();
  2087. ctx.moveTo(loadRight, distY);
  2088. ctx.lineTo(loadRight + 10, distY - 5);
  2089. ctx.lineTo(loadRight + 10, distY + 5);
  2090. ctx.closePath();
  2091. ctx.fill();
  2092. ctx.beginPath();
  2093. ctx.moveTo(recvLeft, distY);
  2094. ctx.lineTo(recvLeft - 10, distY - 5);
  2095. ctx.lineTo(recvLeft - 10, distY + 5);
  2096. ctx.closePath();
  2097. ctx.fill();
  2098. ctx.fillStyle = '#1a2a4a';
  2099. ctx.font = 'bold 12px "Roboto Mono", monospace';
  2100. ctx.textAlign = 'center';
  2101. ctx.textBaseline = 'top';
  2102. ctx.fillText('R = ' + R.toFixed(2) + ' Ом', (loadRight + recvLeft) / 2, distY + 6);
  2103. }
  2104. // === Земля ===
  2105. const gndX = gal8.gnd.x, gndY = wireY;
  2106. // Дополнительное сопротивление заземления (если G < 100)
  2107. const groundExtra = (100 - G) / 100; // 0..1
  2108. const gndExtraW = 30 + groundExtra * 60;
  2109. // Участок "земли" на проводе
  2110. ctx.strokeStyle = `rgba(139,26,26,${0.3 + groundExtra * 0.6})`;
  2111. ctx.lineWidth = 4 + groundExtra * 8;
  2112. ctx.beginPath();
  2113. ctx.moveTo(recvRight, gndY);
  2114. ctx.lineTo(gndX - 20, gndY);
  2115. ctx.stroke();
  2116. // Значок земли
  2117. ctx.fillStyle = '#1a2a4a';
  2118. ctx.beginPath();
  2119. ctx.moveTo(gndX, gndY);
  2120. ctx.lineTo(gndX - 20, gndY + 30);
  2121. ctx.lineTo(gndX + 20, gndY + 30);
  2122. ctx.closePath();
  2123. ctx.fill();
  2124. // Символ заземления (три линии)
  2125. ctx.strokeStyle = '#fffef8';
  2126. ctx.lineWidth = 2;
  2127. for (let i = 0; i < 3; i++) {
  2128. const w = 20 - i * 6;
  2129. const y = gndY + 10 + i * 6;
  2130. ctx.beginPath();
  2131. ctx.moveTo(gndX - w, y);
  2132. ctx.lineTo(gndX + w, y);
  2133. ctx.stroke();
  2134. }
  2135. // Подпись земли
  2136. ctx.fillStyle = '#1a2a4a';
  2137. ctx.font = 'bold 11px "Roboto Mono", monospace';
  2138. ctx.textAlign = 'center';
  2139. ctx.textBaseline = 'top';
  2140. ctx.fillText('земля', gndX, gndY + 38);
  2141. ctx.font = '10px "Roboto Mono", monospace';
  2142. ctx.fillStyle = '#8b1a1a';
  2143. ctx.fillText(G + '%', gndX, gndY + 54);
  2144. // Если плохое заземление — показать "доп. сопротивление" около земли
  2145. if (groundExtra > 0.1) {
  2146. ctx.strokeStyle = `rgba(139,26,26,${0.3 + groundExtra * 0.5})`;
  2147. ctx.lineWidth = 1;
  2148. const resX = gndX - 50 - gndExtraW / 2;
  2149. const resY = gndY;
  2150. // Зигзаг (символ резистора)
  2151. ctx.beginPath();
  2152. ctx.moveTo(resX, resY - 8);
  2153. for (let i = 1; i <= 4; i++) {
  2154. ctx.lineTo(resX + (i - 0.5) * gndExtraW / 4, resY + (i % 2 === 0 ? 8 : -8));
  2155. }
  2156. ctx.lineTo(resX + gndExtraW, resY - 8);
  2157. ctx.stroke();
  2158. }
  2159. // === Индикаторы ===
  2160. document.getElementById('galResult').textContent = U_mV.toFixed(1);
  2161. document.getElementById('galReff').textContent = Reff.toFixed(2);
  2162. // Обратная связь
  2163. const fbEl = document.getElementById('galFeedback');
  2164. if (fbEl) {
  2165. let msg = '';
  2166. if (I === 0) {
  2167. msg = 'Ток = 0 → падения напряжения нет → помехи нет.';
  2168. } else if (R < 0.05) {
  2169. msg = 'Нагрузка и приёмник стоят вплотную, общего участка почти нет → сопротивление близко к нулю → помехи нет.';
  2170. } else {
  2171. const parts = [];
  2172. if (I >= 7) parts.push('ток большой → падение больше');
  2173. if (R >= 0.6) parts.push('общий участок длинный → сопротивление большое');
  2174. if (G <= 30) parts.push('заземление плохое → эффективное сопротивление растёт');
  2175. if (parts.length === 0) parts.push('значения в среднем диапазоне');
  2176. msg = 'По закону Ома U = I·R: ' + parts.join(', ') + '. Это постоянная помеха — не зависит от частоты.';
  2177. }
  2178. fbEl.textContent = msg;
  2179. }
  2180. requestAnimationFrame(drawGal8);
  2181. }
  2182. // === ТЕСТ ===
  2183. const quizData = [
  2184. { q: 'Что является средой в электромагнитном канале?',
  2185. options: ['Только воздух', 'Электрическое или магнитное поле, либо общий проводник', 'Только вакуум'],
  2186. correct: 1,
  2187. explain: 'В электромагнитном канале средой может быть электрическое поле (ёмкостная связь), магнитное поле (индуктивная) или общий проводник (гальваническая). Воздух — лишь одна из возможных сред, но не единственная.' },
  2188. { q: 'От чего зависит индуктивная наводка?',
  2189. options: ['От напряжения и сопротивления', 'От тока, частоты, площади петли и расстояния', 'Только от расстояния'],
  2190. correct: 1,
  2191. explain: 'Индуктивная наводка возникает из-за изменения магнитного потока. Поток зависит от тока, частоты, площади петли и расстояния. Напряжение здесь ни при чём — это ёмкостная наводка.' },
  2192. { q: 'От чего зависит ёмкостная наводка?',
  2193. options: ['От тока и сопротивления', 'От напряжения, частоты, площади и расстояния', 'Только от тока'],
  2194. correct: 1,
  2195. explain: 'Ёмкостная наводка — это наведение через электрическое поле. Оно зависит от напряжения, частоты, площади и расстояния. Ток — это про магнитное поле, не про электрическое.' },
  2196. { q: 'От чего зависит гальваническая наводка?',
  2197. options: ['От тока, сопротивления общего участка и качества заземления', 'От напряжения и площади', 'Только от частоты'],
  2198. correct: 0,
  2199. explain: 'Гальваническая наводка — это падение напряжения на общем сопротивлении по закону Ома: U = I·R. Плохое заземление увеличивает эффективное сопротивление, поэтому помеха растёт.' },
  2200. { q: 'Даёт ли постоянный ток индуктивную наводку?',
  2201. options: ['Да, всегда', 'Нет, потому что магнитный поток не меняется', 'Только при большом токе'],
  2202. correct: 1,
  2203. explain: 'Индуктивная наводка возникает только при изменении магнитного потока (закон Фарадея: ЭДС = −dФ/dt). При постоянном токе поток постоянен, значит, ЭДС = 0. Это ключевое отличие от гальванической наводки, где постоянный ток как раз работает.' },
  2204. { q: 'Экран от какого механизма помогает хуже всего?',
  2205. options: ['От ёмкостного', 'От индуктивного', 'От гальванического'],
  2206. correct: 2,
  2207. explain: 'Электростатический экран хорошо работает от ёмкостной наводки, частично — от индуктивной (если магнитный материал). От гальванической он почти бесполезен: помеха идёт по общему проводнику, и экран её не разрывает. Нужен разрыв цепи (оптрон, трансформатор).' },
  2208. { q: 'Что общего у трёх механизмов наводок?',
  2209. options: ['Они все используют магнитное поле', 'Структура канала: источник → среда → приёмник', 'Они все подавляются одним и тем же экраном'],
  2210. correct: 1,
  2211. explain: 'Все три механизма — это один электромагнитный канал со структурой источник → среда → приёмник. Различается только физическая природа среды. Именно поэтому защита разная: один способ не работает одинаково против всех трёх.' }
  2212. ];
  2213. let quizInitialized = false;
  2214. function initQuiz() {
  2215. if (quizInitialized) return;
  2216. quizInitialized = true;
  2217. const container = document.getElementById('quizContainer');
  2218. let html = '';
  2219. quizData.forEach((item, i) => {
  2220. html += `<div class="question" id="q${i}">
  2221. <div class="q-num">Вопрос ${i+1} из ${quizData.length}</div>
  2222. <div class="q-text">${item.q}</div>`;
  2223. item.options.forEach((opt, j) => {
  2224. html += `<label><input type="radio" name="q${i}" value="${j}"> ${opt}</label>`;
  2225. });
  2226. html += `<div class="explain" id="explain${i}"></div>
  2227. <div class="result-mark" id="mark${i}"></div>
  2228. </div>`;
  2229. });
  2230. html += `<div style="text-align:center; margin-top:20px;">
  2231. <button id="checkQuiz" class="primary">Проверить ответы</button>
  2232. </div>`;
  2233. container.innerHTML = html;
  2234. document.getElementById('checkQuiz').addEventListener('click', checkQuiz);
  2235. }
  2236. function checkQuiz() {
  2237. let score = 0;
  2238. quizData.forEach((item, i) => {
  2239. const selected = document.querySelector(`input[name="q${i}"]:checked`);
  2240. const questionEl = document.getElementById('q' + i);
  2241. const explainEl = document.getElementById('explain' + i);
  2242. const markEl = document.getElementById('mark' + i);
  2243. questionEl.classList.remove('correct', 'incorrect');
  2244. explainEl.classList.remove('show');
  2245. markEl.textContent = '';
  2246. markEl.className = 'result-mark';
  2247. if (!selected) {
  2248. markEl.textContent = '— Нет ответа';
  2249. markEl.classList.add('bad');
  2250. explainEl.innerHTML = '<strong>Правильный ответ:</strong> ' + item.options[item.correct] + '. ' + item.explain;
  2251. explainEl.classList.add('show');
  2252. return;
  2253. }
  2254. const val = parseInt(selected.value);
  2255. if (val === item.correct) {
  2256. score++;
  2257. questionEl.classList.add('correct');
  2258. markEl.textContent = '✓ Верно';
  2259. markEl.classList.add('ok');
  2260. explainEl.innerHTML = '<strong>Пояснение:</strong> ' + item.explain;
  2261. explainEl.classList.add('show');
  2262. } else {
  2263. questionEl.classList.add('incorrect');
  2264. markEl.textContent = '✗ Неверно';
  2265. markEl.classList.add('bad');
  2266. explainEl.innerHTML = '<strong>Правильный ответ:</strong> ' + item.options[item.correct] + '. ' + item.explain;
  2267. explainEl.classList.add('show');
  2268. }
  2269. });
  2270. const resultEl = document.getElementById('quizResult');
  2271. const percent = Math.round((score / quizData.length) * 100);
  2272. let verdict = '';
  2273. if (score === quizData.length) verdict = 'Отлично. Материал усвоен.';
  2274. else if (score >= 5) verdict = 'Хорошо. Есть неточности, но основное понято.';
  2275. else if (score >= 3) verdict = 'Удовлетворительно. Повторите механизмы и их различия.';
  2276. else verdict = 'Неудовлетворительно. Вернитесь к сценам 8–10.';
  2277. resultEl.innerHTML = `
  2278. <div class="final-score">
  2279. <div class="num">${score}</div>
  2280. <div class="of">из ${quizData.length} (${percent}%)</div>
  2281. <div class="verdict">${verdict}</div>
  2282. </div>
  2283. `;
  2284. resultEl.style.display = 'block';
  2285. document.getElementById('finalChecklist').style.display = 'block';
  2286. resultEl.scrollIntoView({ behavior: 'smooth', block: 'center' });
  2287. }
  2288. showScene(0);
  2289. window.addEventListener('load', () => {
  2290. initFields();
  2291. drawWireB();
  2292. drawCapacitor();
  2293. drawInductor();
  2294. });
  2295. })();
  2296. </script>
  2297. </body>
  2298. </html>