From 876a0b2b157754deff9364ed024b116ed1a8d2d4 Mon Sep 17 00:00:00 2001 From: Peter Istvan <istipisti00@gmail.com> Date: Fri, 26 Jun 2020 09:44:25 +0300 Subject: [PATCH] =?UTF-8?q?Hiperbola=20k=C3=B6zel=C3=ADt=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/__pycache__/fizika.cpython-36.pyc | Bin 782 -> 893 bytes src/fizika.py | 12 +- src/plot.svg | 402 +++++++++++++++++++++----- src/teszt.py | 110 ++++--- 4 files changed, 412 insertions(+), 112 deletions(-) diff --git a/src/__pycache__/fizika.cpython-36.pyc b/src/__pycache__/fizika.cpython-36.pyc index 1fb8fd43c8e2029740b01aca44646d7f231a7ad1..41877cd3276a76d0d16aa9cf154ed7bf7a9c49ab 100644 GIT binary patch delta 468 zcmeBU`^%PY%*)I5)!|FrS7ru=#|%h-iGhK^fq{XcScQRsA%!7|A%!uDF@-UTDTOJD zIfXferG+7iC51JGt%V_qHHAHxL6ak$fq^08|4s%c5Cd!!l<~oSqo)yLy--PNQEE|s zadB$8kxNN_PDyGpC&&gikXl9sMj6H;5I>n2#Aje&U}s=pU}a!na0V$_1abyr3S&A` zEprV+3Zo=L2}3qhkx2<-4MPf(Bm)ZrGeb6OzE%lSHftUW69Xedkx316FhfO333Cc# z4O26diwi?+SS?ElV+oT4LoI6wOA2EROAV_CLk*KOLpoCpBaB_c(9B%RR>KUkq=pSd ziZj$OgDk0Gn{33SXTW-kJ;2e&*)cxi78isO>FbEZ_Vl~OT9lZVo(lGlCi~=kCN&=J zg2bHU#Q2Q-;^L~wQ<xNO1VP>s0Qr@XgHeN#g-L*sgHeG|kFiLIfq}tKldTBk`64a` l28JRY5Wx*1Kp|8lH2DFOqA)0mib2vWOe~Bnj4aF?8~~HLS5g1~ delta 334 zcmey%*2m^)%*)HwQvNwEh?#-mF#{4{Vqjo!U|?V<mSA9DNMVR#NMTH2YGH_COkqx8 zX<>+BN?{FV&}2(zU|`7jzmvgfW4aNegjh*xQEE|sadB$8kxM{+UP(!QPDyGp%jC6; zGWBc>3=FIc3=Ga7QzwB;WlUjAXR2kcVMt+=WJqDmW-2mCVX9$BVUlEEVPIy+X3f`1 zVa#UDV_{-oWGFJJVGd@f2q|GmVXR?lW^!SOb*p75VN7AHVX0w~W=LnMVFb}N49(27 ztToIaGiz8uq&Pzja|#oSBts4B<QOJBex_TjMTvRosYRR&3=EoVlXo$xO@7Oypv?nv z7#}DM7&#a<7+IJE7$q3>7>oEB7#RFCnTtS<2kR-~pX|x3$jb;)&%(gKz{1SI0RZNf BKN<i4 diff --git a/src/fizika.py b/src/fizika.py index fc4158d..c4f055c 100644 --- a/src/fizika.py +++ b/src/fizika.py @@ -1,7 +1,12 @@ +# Coulomb-állandó K = 8.98e9 +PALCA_X = 0.0 +PALCA_YMIN = 0.0 +PALCA_YMAX = 1.0 -def tererosseg2DPonttoltes(rToltes, qToltes, rHely): + +def tererosseg2Dtoltes(rToltes, qToltes, rHely): rVektor = [rHely[0] - rToltes[0], rHely[1] - rToltes[1]] rHossz = (rVektor[0] ** 2 + rVektor[1] ** 2) ** 0.5 return [K * qToltes * rVektor[0] / rHossz ** 3, K * qToltes * rVektor[1] / rHossz ** 3] @@ -11,10 +16,11 @@ def tererosseg2DPonttoltes(rToltes, qToltes, rHely): # A felbontás(>=1) megadja, hogy a pálcát hány pontszerű darabra bontja fel a numerikus közelítés def tererosseg2D(rHely, toltessuruseg, felbontas): E = [0, 0] - if rHely[0] == 0 and 1 >= rHely[1] >= 0: + if rHely[0] == PALCA_X and PALCA_YMAX >= rHely[1] >= PALCA_YMIN: return E else: for k in range(0, felbontas): - dE = tererosseg2DPonttoltes([0, k / felbontas], toltessuruseg / felbontas, rHely) + palca_hossz = PALCA_YMAX - PALCA_YMIN + dE = tererosseg2Dtoltes([0, k * palca_hossz / felbontas], toltessuruseg * palca_hossz / felbontas, rHely) E[0], E[1] = E[0] + dE[0], E[1] + dE[1] return E diff --git a/src/plot.svg b/src/plot.svg index 73cd53e..e84e834 100644 --- a/src/plot.svg +++ b/src/plot.svg @@ -25,6 +25,270 @@ L 414.72 41.472 L 57.6 41.472 z " style="fill:#ffffff;"/> + </g> + <g id="patch_3"> + <path clip-path="url(#p41e5f7c203)" d="M 317.654851 237.35927 +L 326.960495 238.873435 +L 324.925088 239.723607 +L 325.880168 240.044817 +L 325.665915 240.134309 +L 324.710835 239.813099 +L 322.675428 240.66327 +z +" style="stroke:#000000;stroke-linejoin:miter;"/> + </g> + <g id="patch_4"> + <path clip-path="url(#p41e5f7c203)" d="M 154.665149 237.35927 +L 149.644572 240.66327 +L 147.609165 239.813099 +L 146.654085 240.134309 +L 146.439832 240.044817 +L 147.394912 239.723607 +L 145.359505 238.873435 +z +" style="stroke:#000000;stroke-linejoin:miter;"/> + </g> + <g id="patch_5"> + <path clip-path="url(#p41e5f7c203)" d="M 311.251554 216.23603 +L 321.373781 216.489216 +L 320.219646 217.546407 +L 321.407291 217.728543 +L 321.285803 217.839826 +L 320.098159 217.65769 +L 318.944024 218.714882 +z +" style="stroke:#000000;stroke-linejoin:miter;"/> + </g> + <g id="patch_6"> + <path clip-path="url(#p41e5f7c203)" d="M 161.068446 216.23603 +L 153.375976 218.714882 +L 152.221841 217.65769 +L 151.034197 217.839826 +L 150.912709 217.728543 +L 152.100354 217.546407 +L 150.946219 216.489216 +z +" style="stroke:#000000;stroke-linejoin:miter;"/> + </g> + <g id="patch_7"> + <path clip-path="url(#p41e5f7c203)" d="M 307.574117 201.213794 +L 317.651584 200.776632 +L 317.026643 201.894626 +L 318.282593 201.993249 +L 318.216809 202.110932 +L 316.960859 202.012309 +L 316.335918 203.130302 +z +" style="stroke:#000000;stroke-linejoin:miter;"/> + </g> + <g id="patch_8"> + <path clip-path="url(#p41e5f7c203)" d="M 164.745883 201.213794 +L 155.984082 203.130302 +L 155.359141 202.012309 +L 154.103191 202.110932 +L 154.037407 201.993249 +L 155.293357 201.894626 +L 154.668416 200.776632 +z +" style="stroke:#000000;stroke-linejoin:miter;"/> + </g> + <g id="patch_9"> + <path clip-path="url(#p41e5f7c203)" d="M 307.932604 187.721494 +L 317.81318 186.859446 +L 317.530026 187.996771 +L 318.807695 188.041456 +L 318.77789 188.161175 +L 317.500221 188.11649 +L 317.217068 189.253815 +z +" style="stroke:#000000;stroke-linejoin:miter;"/> + </g> + <g id="patch_10"> + <path clip-path="url(#p41e5f7c203)" d="M 164.387396 187.721494 +L 155.102932 189.253815 +L 154.819779 188.11649 +L 153.54211 188.161175 +L 153.512305 188.041456 +L 154.789974 187.996771 +L 154.50682 186.859446 +z +" style="stroke:#000000;stroke-linejoin:miter;"/> + </g> + <g id="patch_11"> + <path clip-path="url(#p41e5f7c203)" d="M 308.0203 174.522389 +L 317.643012 173.31839 +L 317.644375 174.460657 +L 318.927595 174.460442 +L 318.927738 174.58068 +L 317.644519 174.580895 +L 317.645882 175.723162 +z +" style="stroke:#000000;stroke-linejoin:miter;"/> + </g> + <g id="patch_12"> + <path clip-path="url(#p41e5f7c203)" d="M 164.2997 174.522389 +L 154.674118 175.723162 +L 154.675481 174.580895 +L 153.392262 174.58068 +L 153.392405 174.460442 +L 154.675625 174.460657 +L 154.676988 173.31839 +z +" style="stroke:#000000;stroke-linejoin:miter;"/> + </g> + <g id="patch_13"> + <path clip-path="url(#p41e5f7c203)" d="M 307.930717 161.321909 +L 317.211102 159.78612 +L 317.497279 160.92334 +L 318.774828 160.878178 +L 318.804952 160.997885 +L 317.527403 161.043047 +L 317.81358 162.180266 +z +" style="stroke:#000000;stroke-linejoin:miter;"/> + </g> + <g id="patch_14"> + <path clip-path="url(#p41e5f7c203)" d="M 164.389283 161.321909 +L 154.50642 162.180266 +L 154.792597 161.043047 +L 153.515048 160.997885 +L 153.545172 160.878178 +L 154.822721 160.92334 +L 155.108898 159.78612 +z +" style="stroke:#000000;stroke-linejoin:miter;"/> + </g> + <g id="patch_15"> + <path clip-path="url(#p41e5f7c203)" d="M 307.568136 147.824571 +L 316.323139 145.903704 +L 316.952041 147.021385 +L 318.20764 146.922137 +L 318.273841 147.039788 +L 317.018241 147.139036 +L 317.647143 148.256717 +z +" style="stroke:#000000;stroke-linejoin:miter;"/> + </g> + <g id="patch_16"> + <path clip-path="url(#p41e5f7c203)" d="M 164.751864 147.824571 +L 154.672857 148.256717 +L 155.301759 147.139036 +L 154.046159 147.039788 +L 154.11236 146.922137 +L 155.367959 147.021385 +L 155.996861 145.903704 +z +" style="stroke:#000000;stroke-linejoin:miter;"/> + </g> + <g id="patch_17"> + <path clip-path="url(#p41e5f7c203)" d="M 311.22762 132.784667 +L 318.905551 130.299491 +L 320.065875 131.355731 +L 321.25245 131.172618 +L 321.374589 131.283801 +L 320.188015 131.466914 +L 321.348339 132.523153 +z +" style="stroke:#000000;stroke-linejoin:miter;"/> + </g> + <g id="patch_18"> + <path clip-path="url(#p41e5f7c203)" d="M 161.09238 132.784667 +L 150.971661 132.523153 +L 152.131985 131.466914 +L 150.945411 131.283801 +L 151.06755 131.172618 +L 152.254125 131.355731 +L 153.414449 130.299491 +z +" style="stroke:#000000;stroke-linejoin:miter;"/> + </g> + <g id="patch_19"> + <path clip-path="url(#p41e5f7c203)" d="M 319.434005 110.961861 +L 324.368456 107.639683 +L 326.425867 108.482382 +L 327.37255 108.1577 +L 327.58912 108.246405 +L 326.642436 108.571088 +L 328.699847 109.413786 +z +" style="stroke:#000000;stroke-linejoin:miter;"/> + </g> + <g id="patch_20"> + <path clip-path="url(#p41e5f7c203)" d="M 152.885995 110.961861 +L 143.620153 109.413786 +L 145.677564 108.571088 +L 144.73088 108.246405 +L 144.94745 108.1577 +L 145.894133 108.482382 +L 147.951544 107.639683 +z +" style="stroke:#000000;stroke-linejoin:miter;"/> + </g> + <g id="patch_21"> + <path clip-path="url(#p41e5f7c203)" d="M 258.955256 88.911901 +L 257.561448 85.145682 +L 260.557693 85.354588 +L 260.792378 84.881745 +L 261.107772 84.903735 +L 260.873087 85.376578 +L 263.869332 85.585484 +z +" style="stroke:#000000;stroke-linejoin:miter;"/> + </g> + <g id="patch_22"> + <path clip-path="url(#p41e5f7c203)" d="M 213.364744 88.911901 +L 208.450668 85.585484 +L 211.446913 85.376578 +L 211.212228 84.903735 +L 211.527622 84.881745 +L 211.762307 85.354588 +L 214.758552 85.145682 +z +" style="stroke:#000000;stroke-linejoin:miter;"/> + </g> + <g id="patch_23"> + <path clip-path="url(#p41e5f7c203)" d="M 236.16 87.475276 +L 232.951951 83.868119 +L 235.999598 83.868119 +L 235.999598 83.387165 +L 236.320402 83.387165 +L 236.320402 83.868119 +L 239.368049 83.868119 +z +" style="stroke:#000000;stroke-linejoin:miter;"/> + </g> + <g id="patch_24"> + <path clip-path="url(#p41e5f7c203)" d="M 260.028001 260.000361 +L 265.027931 263.308757 +L 262.037233 263.528546 +L 262.284144 264.000513 +L 261.969333 264.023649 +L 261.722423 263.551682 +L 258.731726 263.771471 +z +" style="stroke:#000000;stroke-linejoin:miter;"/> + </g> + <g id="patch_25"> + <path clip-path="url(#p41e5f7c203)" d="M 212.291999 260.000361 +L 213.588274 263.771471 +L 210.597577 263.551682 +L 210.350667 264.023649 +L 210.035856 264.000513 +L 210.282767 263.528546 +L 207.292069 263.308757 +z +" style="stroke:#000000;stroke-linejoin:miter;"/> + </g> + <g id="patch_26"> + <path clip-path="url(#p41e5f7c203)" d="M 236.16 261.580724 +L 239.368049 265.187881 +L 236.320402 265.187881 +L 236.320402 265.668835 +L 235.999598 265.668835 +L 235.999598 265.187881 +L 232.951951 265.187881 +z +" style="stroke:#000000;stroke-linejoin:miter;"/> </g> <g id="matplotlib.axis_1"> <g id="xtick_1"> @@ -32,10 +296,10 @@ z <defs> <path d="M 0 0 L 0 3.5 -" id="me0e2aabba0" style="stroke:#000000;stroke-width:0.8;"/> +" id="m6fd5b44d8f" style="stroke:#000000;stroke-width:0.8;"/> </defs> <g> - <use style="stroke:#000000;stroke-width:0.8;" x="107.838031" xlink:href="#me0e2aabba0" y="307.584"/> + <use style="stroke:#000000;stroke-width:0.8;" x="107.838031" xlink:href="#m6fd5b44d8f" y="307.584"/> </g> </g> <g id="text_1"> @@ -103,7 +367,7 @@ z <g id="xtick_2"> <g id="line2d_2"> <g> - <use style="stroke:#000000;stroke-width:0.8;" x="171.999016" xlink:href="#me0e2aabba0" y="307.584"/> + <use style="stroke:#000000;stroke-width:0.8;" x="171.999016" xlink:href="#m6fd5b44d8f" y="307.584"/> </g> </g> <g id="text_2"> @@ -145,7 +409,7 @@ z <g id="xtick_3"> <g id="line2d_3"> <g> - <use style="stroke:#000000;stroke-width:0.8;" x="236.16" xlink:href="#me0e2aabba0" y="307.584"/> + <use style="stroke:#000000;stroke-width:0.8;" x="236.16" xlink:href="#m6fd5b44d8f" y="307.584"/> </g> </g> <g id="text_3"> @@ -160,7 +424,7 @@ z <g id="xtick_4"> <g id="line2d_4"> <g> - <use style="stroke:#000000;stroke-width:0.8;" x="300.320984" xlink:href="#me0e2aabba0" y="307.584"/> + <use style="stroke:#000000;stroke-width:0.8;" x="300.320984" xlink:href="#m6fd5b44d8f" y="307.584"/> </g> </g> <g id="text_4"> @@ -175,7 +439,7 @@ z <g id="xtick_5"> <g id="line2d_5"> <g> - <use style="stroke:#000000;stroke-width:0.8;" x="364.481969" xlink:href="#me0e2aabba0" y="307.584"/> + <use style="stroke:#000000;stroke-width:0.8;" x="364.481969" xlink:href="#m6fd5b44d8f" y="307.584"/> </g> </g> <g id="text_5"> @@ -194,10 +458,10 @@ z <defs> <path d="M 0 0 L -3.5 0 -" id="mddb34a76f7" style="stroke:#000000;stroke-width:0.8;"/> +" id="m9ec01caf81" style="stroke:#000000;stroke-width:0.8;"/> </defs> <g> - <use style="stroke:#000000;stroke-width:0.8;" x="57.6" xlink:href="#mddb34a76f7" y="294.766569"/> + <use style="stroke:#000000;stroke-width:0.8;" x="57.6" xlink:href="#m9ec01caf81" y="294.766569"/> </g> </g> <g id="text_6"> @@ -240,7 +504,7 @@ z <g id="ytick_2"> <g id="line2d_7"> <g> - <use style="stroke:#000000;stroke-width:0.8;" x="57.6" xlink:href="#mddb34a76f7" y="264.706926"/> + <use style="stroke:#000000;stroke-width:0.8;" x="57.6" xlink:href="#m9ec01caf81" y="264.706926"/> </g> </g> <g id="text_7"> @@ -257,7 +521,7 @@ z <g id="ytick_3"> <g id="line2d_8"> <g> - <use style="stroke:#000000;stroke-width:0.8;" x="57.6" xlink:href="#mddb34a76f7" y="234.647284"/> + <use style="stroke:#000000;stroke-width:0.8;" x="57.6" xlink:href="#m9ec01caf81" y="234.647284"/> </g> </g> <g id="text_8"> @@ -273,7 +537,7 @@ z <g id="ytick_4"> <g id="line2d_9"> <g> - <use style="stroke:#000000;stroke-width:0.8;" x="57.6" xlink:href="#mddb34a76f7" y="204.587642"/> + <use style="stroke:#000000;stroke-width:0.8;" x="57.6" xlink:href="#m9ec01caf81" y="204.587642"/> </g> </g> <g id="text_9"> @@ -289,7 +553,7 @@ z <g id="ytick_5"> <g id="line2d_10"> <g> - <use style="stroke:#000000;stroke-width:0.8;" x="57.6" xlink:href="#mddb34a76f7" y="174.528"/> + <use style="stroke:#000000;stroke-width:0.8;" x="57.6" xlink:href="#m9ec01caf81" y="174.528"/> </g> </g> <g id="text_10"> @@ -305,7 +569,7 @@ z <g id="ytick_6"> <g id="line2d_11"> <g> - <use style="stroke:#000000;stroke-width:0.8;" x="57.6" xlink:href="#mddb34a76f7" y="144.468358"/> + <use style="stroke:#000000;stroke-width:0.8;" x="57.6" xlink:href="#m9ec01caf81" y="144.468358"/> </g> </g> <g id="text_11"> @@ -332,7 +596,7 @@ z <g id="ytick_7"> <g id="line2d_12"> <g> - <use style="stroke:#000000;stroke-width:0.8;" x="57.6" xlink:href="#mddb34a76f7" y="114.408716"/> + <use style="stroke:#000000;stroke-width:0.8;" x="57.6" xlink:href="#m9ec01caf81" y="114.408716"/> </g> </g> <g id="text_12"> @@ -363,7 +627,7 @@ z <g id="ytick_8"> <g id="line2d_13"> <g> - <use style="stroke:#000000;stroke-width:0.8;" x="57.6" xlink:href="#mddb34a76f7" y="84.349074"/> + <use style="stroke:#000000;stroke-width:0.8;" x="57.6" xlink:href="#m9ec01caf81" y="84.349074"/> </g> </g> <g id="text_13"> @@ -379,7 +643,7 @@ z <g id="ytick_9"> <g id="line2d_14"> <g> - <use style="stroke:#000000;stroke-width:0.8;" x="57.6" xlink:href="#mddb34a76f7" y="54.289431"/> + <use style="stroke:#000000;stroke-width:0.8;" x="57.6" xlink:href="#m9ec01caf81" y="54.289431"/> </g> </g> <g id="text_14"> @@ -394,7 +658,7 @@ z </g> </g> <g id="line2d_15"> - <path clip-path="url(#p46b98a4912)" d="M 239.368049 222.623427 + <path clip-path="url(#p41e5f7c203)" d="M 239.368049 222.623427 L 241.9295 222.682582 L 244.483932 222.775031 L 247.028442 222.900159 @@ -474,10 +738,10 @@ L 391.777985 265.652118 L 393.47961 266.372197 L 395.178414 267.09321 L 396.874472 267.815131 -" style="fill:none;stroke:#1f77b4;stroke-linecap:square;stroke-width:1.5;"/> +" style="fill:none;stroke:#000000;stroke-linecap:square;stroke-width:1.5;"/> </g> <g id="line2d_16"> - <path clip-path="url(#p46b98a4912)" d="M 232.951951 222.623427 + <path clip-path="url(#p41e5f7c203)" d="M 232.951951 222.623427 L 230.3905 222.682582 L 227.836068 222.775031 L 225.291558 222.900159 @@ -557,10 +821,10 @@ L 80.542015 265.652118 L 78.84039 266.372197 L 77.141586 267.09321 L 75.445528 267.815131 -" style="fill:none;stroke:#ff7f0e;stroke-linecap:square;stroke-width:1.5;"/> +" style="fill:none;stroke:#000000;stroke-linecap:square;stroke-width:1.5;"/> </g> <g id="line2d_17"> - <path clip-path="url(#p46b98a4912)" d="M 239.368049 210.599571 + <path clip-path="url(#p41e5f7c203)" d="M 239.368049 210.599571 L 241.933588 210.624703 L 244.49785 210.664108 L 247.060277 210.717722 @@ -627,10 +891,10 @@ L 390.051486 230.765048 L 392.275703 231.244952 L 394.496726 231.72693 L 396.714635 232.210918 -" style="fill:none;stroke:#2ca02c;stroke-linecap:square;stroke-width:1.5;"/> +" style="fill:none;stroke:#000000;stroke-linecap:square;stroke-width:1.5;"/> </g> <g id="line2d_18"> - <path clip-path="url(#p46b98a4912)" d="M 232.951951 210.599571 + <path clip-path="url(#p41e5f7c203)" d="M 232.951951 210.599571 L 230.386412 210.624703 L 227.82215 210.664108 L 225.259723 210.717722 @@ -697,10 +961,10 @@ L 82.268514 230.765048 L 80.044297 231.244952 L 77.823274 231.72693 L 75.605365 232.210918 -" style="fill:none;stroke:#d62728;stroke-linecap:square;stroke-width:1.5;"/> +" style="fill:none;stroke:#000000;stroke-linecap:square;stroke-width:1.5;"/> </g> <g id="line2d_19"> - <path clip-path="url(#p46b98a4912)" d="M 239.368049 198.575714 + <path clip-path="url(#p41e5f7c203)" d="M 239.368049 198.575714 L 241.934255 198.588491 L 244.500131 198.608539 L 247.06553 198.635844 @@ -764,10 +1028,10 @@ L 390.09002 209.30142 L 392.537396 209.591002 L 394.983133 209.882524 L 397.427263 210.175931 -" style="fill:none;stroke:#9467bd;stroke-linecap:square;stroke-width:1.5;"/> +" style="fill:none;stroke:#000000;stroke-linecap:square;stroke-width:1.5;"/> </g> <g id="line2d_20"> - <path clip-path="url(#p46b98a4912)" d="M 232.951951 198.575714 + <path clip-path="url(#p41e5f7c203)" d="M 232.951951 198.575714 L 230.385745 198.588491 L 227.819869 198.608539 L 225.25447 198.635844 @@ -831,10 +1095,10 @@ L 82.22998 209.30142 L 79.782604 209.591002 L 77.336867 209.882524 L 74.892737 210.175931 -" style="fill:none;stroke:#8c564b;stroke-linecap:square;stroke-width:1.5;"/> +" style="fill:none;stroke:#000000;stroke-linecap:square;stroke-width:1.5;"/> </g> <g id="line2d_21"> - <path clip-path="url(#p46b98a4912)" d="M 239.368049 186.551857 + <path clip-path="url(#p41e5f7c203)" d="M 239.368049 186.551857 L 241.934444 186.557445 L 244.500775 186.566203 L 247.067016 186.578135 @@ -897,10 +1161,10 @@ L 390.127902 191.331135 L 392.66862 191.466977 L 395.208922 191.603909 L 397.748814 191.741904 -" style="fill:none;stroke:#e377c2;stroke-linecap:square;stroke-width:1.5;"/> +" style="fill:none;stroke:#000000;stroke-linecap:square;stroke-width:1.5;"/> </g> <g id="line2d_22"> - <path clip-path="url(#p46b98a4912)" d="M 232.951951 186.551857 + <path clip-path="url(#p41e5f7c203)" d="M 232.951951 186.551857 L 230.385556 186.557445 L 227.819225 186.566203 L 225.252984 186.578135 @@ -963,10 +1227,10 @@ L 82.192098 191.331135 L 79.65138 191.466977 L 77.111078 191.603909 L 74.571186 191.741904 -" style="fill:none;stroke:#7f7f7f;stroke-linecap:square;stroke-width:1.5;"/> +" style="fill:none;stroke:#000000;stroke-linecap:square;stroke-width:1.5;"/> </g> <g id="line2d_23"> - <path clip-path="url(#p46b98a4912)" d="M 239.368049 174.528 + <path clip-path="url(#p41e5f7c203)" d="M 239.368049 174.528 L 241.934489 174.527972 L 244.500928 174.52793 L 247.067367 174.527872 @@ -1029,10 +1293,10 @@ L 390.787956 174.504787 L 393.354395 174.504116 L 395.920834 174.50344 L 398.487273 174.502758 -" style="fill:none;stroke:#bcbd22;stroke-linecap:square;stroke-width:1.5;"/> +" style="fill:none;stroke:#000000;stroke-linecap:square;stroke-width:1.5;"/> </g> <g id="line2d_24"> - <path clip-path="url(#p46b98a4912)" d="M 232.951951 174.528 + <path clip-path="url(#p41e5f7c203)" d="M 232.951951 174.528 L 230.385511 174.527972 L 227.819072 174.52793 L 225.252633 174.527872 @@ -1095,10 +1359,10 @@ L 81.532044 174.504787 L 78.965605 174.504116 L 76.399166 174.50344 L 73.832727 174.502758 -" style="fill:none;stroke:#17becf;stroke-linecap:square;stroke-width:1.5;"/> +" style="fill:none;stroke:#000000;stroke-linecap:square;stroke-width:1.5;"/> </g> <g id="line2d_25"> - <path clip-path="url(#p46b98a4912)" d="M 239.368049 162.504143 + <path clip-path="url(#p41e5f7c203)" d="M 239.368049 162.504143 L 241.934443 162.498489 L 244.500771 162.489636 L 247.067008 162.477574 @@ -1161,10 +1425,10 @@ L 390.113843 157.674197 L 392.654018 157.536939 L 395.193769 157.398582 L 397.733102 157.259151 -" style="fill:none;stroke:#1f77b4;stroke-linecap:square;stroke-width:1.5;"/> +" style="fill:none;stroke:#000000;stroke-linecap:square;stroke-width:1.5;"/> </g> <g id="line2d_26"> - <path clip-path="url(#p46b98a4912)" d="M 232.951951 162.504143 + <path clip-path="url(#p41e5f7c203)" d="M 232.951951 162.504143 L 230.385557 162.498489 L 227.819229 162.489636 L 225.252992 162.477574 @@ -1227,10 +1491,10 @@ L 82.206157 157.674197 L 79.665982 157.536939 L 77.126231 157.398582 L 74.586898 157.259151 -" style="fill:none;stroke:#ff7f0e;stroke-linecap:square;stroke-width:1.5;"/> +" style="fill:none;stroke:#000000;stroke-linecap:square;stroke-width:1.5;"/> </g> <g id="line2d_27"> - <path clip-path="url(#p46b98a4912)" d="M 239.368049 150.480286 + <path clip-path="url(#p41e5f7c203)" d="M 239.368049 150.480286 L 241.934252 150.467412 L 244.50012 150.447225 L 247.065504 150.419732 @@ -1294,10 +1558,10 @@ L 390.049553 139.688258 L 392.495531 139.397019 L 394.939853 139.103833 L 397.382554 138.808754 -" style="fill:none;stroke:#2ca02c;stroke-linecap:square;stroke-width:1.5;"/> +" style="fill:none;stroke:#000000;stroke-linecap:square;stroke-width:1.5;"/> </g> <g id="line2d_28"> - <path clip-path="url(#p46b98a4912)" d="M 232.951951 150.480286 + <path clip-path="url(#p41e5f7c203)" d="M 232.951951 150.480286 L 230.385748 150.467412 L 227.81988 150.447225 L 225.254496 150.419732 @@ -1361,10 +1625,10 @@ L 82.270447 139.688258 L 79.824469 139.397019 L 77.380147 139.103833 L 74.937446 138.808754 -" style="fill:none;stroke:#d62728;stroke-linecap:square;stroke-width:1.5;"/> +" style="fill:none;stroke:#000000;stroke-linecap:square;stroke-width:1.5;"/> </g> <g id="line2d_29"> - <path clip-path="url(#p46b98a4912)" d="M 239.368049 138.456429 + <path clip-path="url(#p41e5f7c203)" d="M 239.368049 138.456429 L 241.933575 138.431123 L 244.497806 138.391438 L 247.060176 138.337446 @@ -1431,10 +1695,10 @@ L 389.936017 118.186404 L 392.15709 117.704459 L 394.374952 117.220441 L 396.589684 116.734415 -" style="fill:none;stroke:#9467bd;stroke-linecap:square;stroke-width:1.5;"/> +" style="fill:none;stroke:#000000;stroke-linecap:square;stroke-width:1.5;"/> </g> <g id="line2d_30"> - <path clip-path="url(#p46b98a4912)" d="M 232.951951 138.456429 + <path clip-path="url(#p41e5f7c203)" d="M 232.951951 138.456429 L 230.386425 138.431123 L 227.822194 138.391438 L 225.259824 138.337446 @@ -1501,10 +1765,10 @@ L 82.383983 118.186404 L 80.16291 117.704459 L 77.945048 117.220441 L 75.730316 116.734415 -" style="fill:none;stroke:#8c564b;stroke-linecap:square;stroke-width:1.5;"/> +" style="fill:none;stroke:#000000;stroke-linecap:square;stroke-width:1.5;"/> </g> <g id="line2d_31"> - <path clip-path="url(#p46b98a4912)" d="M 239.368049 126.432573 + <path clip-path="url(#p41e5f7c203)" d="M 239.368049 126.432573 L 241.929385 126.372737 L 244.483545 126.27925 L 247.027563 126.152733 @@ -1585,10 +1849,10 @@ L 393.025927 82.471923 L 394.717723 81.748599 L 396.406777 81.024375 L 398.093162 80.299277 -" style="fill:none;stroke:#e377c2;stroke-linecap:square;stroke-width:1.5;"/> +" style="fill:none;stroke:#000000;stroke-linecap:square;stroke-width:1.5;"/> </g> <g id="line2d_32"> - <path clip-path="url(#p46b98a4912)" d="M 232.951951 126.432573 + <path clip-path="url(#p41e5f7c203)" d="M 232.951951 126.432573 L 230.390615 126.372737 L 227.836455 126.27925 L 225.292437 126.152733 @@ -1669,10 +1933,10 @@ L 79.294073 82.471923 L 77.602277 81.748599 L 75.913223 81.024375 L 74.226838 80.299277 -" style="fill:none;stroke:#7f7f7f;stroke-linecap:square;stroke-width:1.5;"/> +" style="fill:none;stroke:#000000;stroke-linecap:square;stroke-width:1.5;"/> </g> <g id="line2d_33"> - <path clip-path="url(#p46b98a4912)" d="M 239.368049 114.408716 + <path clip-path="url(#p41e5f7c203)" d="M 239.368049 114.408716 L 240.939469 113.649944 L 242.225312 112.817917 L 243.337461 111.951179 @@ -1738,10 +2002,10 @@ L 273.87162 56.445459 L 274.277518 55.495657 L 274.682364 54.545792 L 275.086192 53.595866 -" style="fill:none;stroke:#bcbd22;stroke-linecap:square;stroke-width:1.5;"/> +" style="fill:none;stroke:#000000;stroke-linecap:square;stroke-width:1.5;"/> </g> <g id="line2d_34"> - <path clip-path="url(#p46b98a4912)" d="M 232.951951 114.408716 + <path clip-path="url(#p41e5f7c203)" d="M 232.951951 114.408716 L 231.380531 113.649944 L 230.094688 112.817917 L 228.982539 111.951179 @@ -1807,10 +2071,10 @@ L 198.44838 56.445459 L 198.042482 55.495657 L 197.637636 54.545792 L 197.233808 53.595866 -" style="fill:none;stroke:#17becf;stroke-linecap:square;stroke-width:1.5;"/> +" style="fill:none;stroke:#000000;stroke-linecap:square;stroke-width:1.5;"/> </g> <g id="line2d_35"> - <path clip-path="url(#p46b98a4912)" d="M 236.16 113.20633 + <path clip-path="url(#p41e5f7c203)" d="M 236.16 113.20633 L 236.16 112.244421 L 236.16 111.282513 L 236.16 110.320604 @@ -1873,10 +2137,10 @@ L 236.16 56.453726 L 236.16 55.491817 L 236.16 54.529909 L 236.16 53.568 -" style="fill:none;stroke:#1f77b4;stroke-linecap:square;stroke-width:1.5;"/> +" style="fill:none;stroke:#000000;stroke-linecap:square;stroke-width:1.5;"/> </g> <g id="line2d_36"> - <path clip-path="url(#p46b98a4912)" d="M 239.368049 234.647284 + <path clip-path="url(#p41e5f7c203)" d="M 239.368049 234.647284 L 241.025858 235.379535 L 242.386305 236.19466 L 243.563049 237.049307 @@ -1942,10 +2206,10 @@ L 275.716325 292.415517 L 276.143119 293.364032 L 276.568807 294.312616 L 276.993422 295.261268 -" style="fill:none;stroke:#ff7f0e;stroke-linecap:square;stroke-width:1.5;"/> +" style="fill:none;stroke:#000000;stroke-linecap:square;stroke-width:1.5;"/> </g> <g id="line2d_37"> - <path clip-path="url(#p46b98a4912)" d="M 232.951951 234.647284 + <path clip-path="url(#p41e5f7c203)" d="M 232.951951 234.647284 L 231.294142 235.379535 L 229.933695 236.19466 L 228.756951 237.049307 @@ -2011,10 +2275,10 @@ L 196.603675 292.415517 L 196.176881 293.364032 L 195.751193 294.312616 L 195.326578 295.261268 -" style="fill:none;stroke:#2ca02c;stroke-linecap:square;stroke-width:1.5;"/> +" style="fill:none;stroke:#000000;stroke-linecap:square;stroke-width:1.5;"/> </g> <g id="line2d_38"> - <path clip-path="url(#p46b98a4912)" d="M 236.16 235.84967 + <path clip-path="url(#p41e5f7c203)" d="M 236.16 235.84967 L 236.16 236.811579 L 236.16 237.773487 L 236.16 238.735396 @@ -2077,24 +2341,24 @@ L 236.16 292.602274 L 236.16 293.564183 L 236.16 294.526091 L 236.16 295.488 -" style="fill:none;stroke:#d62728;stroke-linecap:square;stroke-width:1.5;"/> +" style="fill:none;stroke:#000000;stroke-linecap:square;stroke-width:1.5;"/> </g> - <g id="patch_3"> + <g id="patch_27"> <path d="M 57.6 307.584 L 57.6 41.472 " style="fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;"/> </g> - <g id="patch_4"> + <g id="patch_28"> <path d="M 414.72 307.584 L 414.72 41.472 " style="fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;"/> </g> - <g id="patch_5"> + <g id="patch_29"> <path d="M 57.6 307.584 L 414.72 307.584 " style="fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;"/> </g> - <g id="patch_6"> + <g id="patch_30"> <path d="M 57.6 41.472 L 414.72 41.472 " style="fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;"/> @@ -2102,7 +2366,7 @@ L 414.72 41.472 </g> </g> <defs> - <clipPath id="p46b98a4912"> + <clipPath id="p41e5f7c203"> <rect height="266.112" width="357.12" x="57.6" y="41.472"/> </clipPath> </defs> diff --git a/src/teszt.py b/src/teszt.py index c746b15..35043ae 100644 --- a/src/teszt.py +++ b/src/teszt.py @@ -1,4 +1,6 @@ +import matplotlib import matplotlib.pyplot as plt +import src.fizika as fiz from src.fizika import tererosseg2D from scipy.integrate import ode as ode @@ -6,12 +8,10 @@ toltessuruseg = 1 felbontas = 1000 vonalsuruseg = 10 -XMIN = -.5 -XMAX = .5 -YMIN = -.5 -YMAX = 1.5 - -palca = [[0, 0], [0, 1]] +XMIN = fiz.PALCA_X - 0.5 +XMAX = fiz.PALCA_X + 0.5 +YMIN = fiz.PALCA_YMIN - 0.5 +YMAX = fiz.PALCA_YMAX + 0.5 def irany(t, rHely): @@ -34,12 +34,14 @@ def iranymezo(): for j in range(0, YDENSITY): xcoord = XMIN + XRANGE * i ycoord = YMIN + YRANGE * j - if xcoord != 0 or (xcoord == 0 and 1 < ycoord or ycoord < 0): + if xcoord != fiz.PALCA_X or (xcoord == fiz.PALCA_X and fiz.PALCA_YMAX < ycoord or ycoord < fiz.PALCA_YMIN): # print(str([xcoord, ycoord])) plt.quiver(xcoord, ycoord, irany(0, [xcoord, ycoord])[0], irany(0, [xcoord, ycoord])[1], width=0.01) def erovonal(kezdopont, dt): + if toltessuruseg < 0: + dt = -dt ev = [kezdopont] r = ode(irany) r.set_integrator('vode') @@ -52,45 +54,73 @@ def erovonal(kezdopont, dt): return ev +def erovonal_rajzolas(kezdopont, dt): + ev = erovonal(kezdopont, dt) + ev_x = [ev[i][0] for i in range(0, len(ev))] + ev_y = [ev[i][1] for i in range(0, len(ev))] + plt.plot(ev_x, ev_y, color='black') + hossz = len(ev) + idx = int((hossz - 1)/2) + if toltessuruseg < 0: + kov = idx - 1 + else: + kov = idx + 1 + plt.arrow(ev_x[idx], ev_y[idx], (ev_x[kov] - ev_x[idx])/2, (ev_y[kov] - ev_y[idx])/2, color='black', head_width=0.02)#, head_length=0.02) + + def tererovonalak(): + dx = 0.01 + dt = 0.008 # pálca belsejéből induló erővonalak for k in range(1, vonalsuruseg): - ev = erovonal([0.01, k/vonalsuruseg], 0.008) - ev_x = [ev[i][0] for i in range(0, len(ev))] - ev_y = [ev[i][1] for i in range(0, len(ev))] - plt.plot(ev_x, ev_y) - ev = erovonal([-0.01, k/vonalsuruseg], 0.008) - ev_x = [ev[i][0] for i in range(0, len(ev))] - ev_y = [ev[i][1] for i in range(0, len(ev))] - plt.plot(ev_x, ev_y) - # pálca végeiből induló erővonalak - ev = erovonal([0.01, 1.0], 0.008) - ev_x = [ev[i][0] for i in range(0, len(ev))] - ev_y = [ev[i][1] for i in range(0, len(ev))] - plt.plot(ev_x, ev_y) - ev = erovonal([-0.01, 1.0], 0.008) - ev_x = [ev[i][0] for i in range(0, len(ev))] - ev_y = [ev[i][1] for i in range(0, len(ev))] - plt.plot(ev_x, ev_y) - ev = erovonal([0.0, 1.01], 0.008) - ev_x = [ev[i][0] for i in range(0, len(ev))] - ev_y = [ev[i][1] for i in range(0, len(ev))] - plt.plot(ev_x, ev_y) - ev = erovonal([0.01, 0.0], 0.008) - ev_x = [ev[i][0] for i in range(0, len(ev))] - ev_y = [ev[i][1] for i in range(0, len(ev))] - plt.plot(ev_x, ev_y) - ev = erovonal([-0.01, 0.0], 0.008) - ev_x = [ev[i][0] for i in range(0, len(ev))] - ev_y = [ev[i][1] for i in range(0, len(ev))] - plt.plot(ev_x, ev_y) - ev = erovonal([0.0, -0.01], 0.008) - ev_x = [ev[i][0] for i in range(0, len(ev))] - ev_y = [ev[i][1] for i in range(0, len(ev))] - plt.plot(ev_x, ev_y) + # jobbra induló erővonal + erovonal_rajzolas([0.0 + dx, k/vonalsuruseg], dt) + # balra induló erővonal + erovonal_rajzolas([0.0 - dx, k/vonalsuruseg], dt) + + print("Palca megvan") + + # pálca [0, 1] végéből induló erővonalak + erovonal_rajzolas([fiz.PALCA_X + dx, fiz.PALCA_YMAX], dt) + erovonal_rajzolas([fiz.PALCA_X - dx, fiz.PALCA_YMAX], dt) + erovonal_rajzolas([fiz.PALCA_X, fiz.PALCA_YMAX + dx], dt) + + print("[0, 1] megvan") + + # pálca [0, 0] végéből induló erővonalak + erovonal_rajzolas([fiz.PALCA_X + dx, fiz.PALCA_YMIN], dt) + erovonal_rajzolas([fiz.PALCA_X - dx, fiz.PALCA_YMIN], dt) + erovonal_rajzolas([fiz.PALCA_X, fiz.PALCA_YMIN - dx], dt) + + print("[0, 1] megvan") + + +def fokuszpont_tavolsagosszeg(x, y, f1x, f1y, f2x, f2y): + d1 = ((x - f1x)**2 + (y - f1y)**2)**0.5 + d2 = ((x - f2x)**2 + (y - f2y)**2)**0.5 + return abs(d1 - d2) + + +def hiperbola(): + ivhossz = 0.0 + P_X = fiz.PALCA_X + 0.01 + P_Y = (fiz.PALCA_YMAX * 3 + fiz.PALCA_YMIN)/4 + ev = erovonal([P_X, P_Y], 0.0005) + for p in ev: + print(str(fokuszpont_tavolsagosszeg(p[0], p[1], fiz.PALCA_X, fiz.PALCA_YMIN, fiz.PALCA_X, fiz.PALCA_YMAX))) + + for i in range(0, len(ev)-1): + ivhossz += ((ev[i][0] - ev[i+1][0])**2 + (ev[i][1] - ev[i+1][1])**2)**0.5 + + print("Ivhossz = " + str(ivhossz)) # iranymezo() + +toltessuruseg = float(input("lambda = ")) tererovonalak() plt.savefig("plot.svg") + +hiperbola() +print("Hiperbola megvan") -- GitLab