.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_auto_examples/gjk/plot_ellipse.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr__auto_examples_gjk_plot_ellipse.py: ================================== Distance between ellipses with GJK ================================== .. GENERATED FROM PYTHON SOURCE LINES 6-43 .. image-sg:: /_auto_examples/gjk/images/sphx_glr_plot_ellipse_001.png :alt: plot ellipse :srcset: /_auto_examples/gjk/images/sphx_glr_plot_ellipse_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none 1.1380681820644796 0.9560431486287693 3.4787490765284548 0.8714331192002726 1.2847367112009944 2.2859197788209324 2.4850621798637467 2.0142118662294313 3.453240596372337 1.5134263461844075 2.440841699310029 1.911058749323634 1.1018562910679097 3.180002090623733 1.4148355023819972 0.5734294611723642 1.9461815865421936 1.4834718067293728 1.0787386728621942 2.20010682799413 2.7221712386067924 3.178388422343659 1.4935082282658245 2.7327285631785427 2.5107697105168394 0.7501269295619475 1.1808138522998919 0.33369626874392805 2.2083462139508407 2.6486760244348324 3.0053572981736463 1.3705398410214722 1.1992016441859819 1.156807236490297 3.1892504440832283 2.877845009591963 3.940274812790122 2.5151928193554913 1.8075206383497509 2.7668596858440604 2.4099109044303555 1.3429119748999785 2.32420271450498 1.7627034678654616 3.0183474599431523 2.7009797297253226 2.009059441169124 1.7339089960712952 1.18220279059975 0.8927045682949588 3.8671903952714333 0.0 0.9500216833835372 2.4982220932575547 3.1670809331276004 0.9553160572620066 3.0458894257432134 2.325527092560804 1.9622156765815917 2.7209594445603353 2.5509881997793897 3.0417167424264817 1.5717640700524251 1.9002328651282012 0.6655570858590263 1.6352849664239901 1.182345666195692 2.200586398703262 2.2243306825198634 1.4083463318649285 1.3647562207143888 1.8540858118560155 1.0999126541302588 3.9290090570676597 2.797633063948219 1.7721151544530966 2.7239505327541624 2.6052856806849305 0.7140338368602869 1.9917720184328367 2.5330714087854114 1.173121684918774 1.2968073223766199 2.044232651354548 1.8689494625366225 2.0942423471523655 2.199200300868366 2.2520173396980656 2.882054803147735 1.995586769918877 1.4825104004346459 1.8927776047163896 1.5418700694089114 1.6808516062002408 2.476372085808733 1.183824383272544 1.9022956660496624 2.3979942720502025 1.368747139346188 2.8202571987848786 1.3230935718306212 1.4547924941443606 2.0092938662364035 2.8558498703610202 2.526433401951627 2.4250160004298467 0.996130986806111 3.044466631412352 2.2287791978854843 2.4590825589637566 1.0107799240314612 1.0997997917028488 1.5212135279065908 3.5367408498633166 0.189230132174133 2.2583539449662893 1.4284825524482159 1.8719189690757416 1.9733250306970318 2.38792017153392 1.816595626460519 1.7155882139624874 2.164670090439777 2.787372053165911 0.38052110195907823 2.988721025247855 1.1755076385051493 0.7316338001526715 1.8041578726888705 1.4056220846341037 2.2548243935629504 2.71274235982263 1.7620375788954397 1.7335068167049803 2.285060141099423 2.277081700877924 1.856055541662396 2.2633656510799116 1.9818050363013502 1.2793948530148729 2.2703292768511836 1.8099881985994486 2.349432823755916 1.3337246160302154 1.171400431859551 1.8233308760425064 0.7745970927963195 1.9753388354201993 2.103451374703058 0.2620798637968282 1.2538848082870966 1.4896826501311664 1.0510685115243052 0.7340234872831904 1.1544907870974546 0.4315733712990613 0.7851254367275105 0.9023306798395923 1.474331807274315 0.25721838673131736 2.6101497251808583 0.8666930796103177 1.6440360752224008 0.855962153159912 1.5170647696438448 1.5137601980586703 0.485628677550673 1.3515616203301468 1.525830728281711 2.3126492185197343 1.0964630549363217 2.1351949083674424 1.842713033626688 1.5488218210285554 3.1291343892364676 1.8595512905967113 2.0116456174367148 2.1425344262131065 0.0 2.8095656729330702 1.0719764939499956 1.5256946007558072 2.7341645375845567 2.9442676805728927 0.46317051463305947 1.7975819483816915 1.3485118913261844 1.3640416564303244 2.905834698830627 0.918146229184466 3.699640737543353 1.1519674266189375 2.8118363520027083 1.136707019555616 0.0 2.7805500527438527 1.0239496313186083 0.6689803325917578 0.34599140827068603 0.6502008784543589 2.611444407836993 2.049786800788696 0.7089684437846641 0.5678513668483516 2.0988724388735687 3.148629064490753 0.41222446291714476 1.2520997946892547 0.7469520171490697 1.4586981219436996 1.112688265147935 0.5306737786828428 3.296778155249589 2.4393679258932606 2.909471949097217 2.4933719917234844 3.6256508368430453 2.6286967784817996 2.2921067371667876 2.3056723617946795 2.828901150716149 2.3118388211293674 0.476180762184175 1.8117551149144029 2.853849169323443 1.0101798848780297 0.7740579503597168 1.8374589459248687 2.844284436835364 2.3110589016606715 1.8908109717320545 1.9719654423785595 2.0556105371338402 0.7902044808110819 3.3354119549155667 1.178545202383281 2.761812486991978 2.571238952573167 1.3003209911390567 3.3802072860558927 2.951976174702144 0.48213706175428944 3.1496193371163583 2.17334913600245 1.8533919398286796 1.7666665647710869 2.200523373361199 2.1256058385588363 1.3325194444064952 1.9996056375230715 1.2896086086936953 0.08443831952078491 3.1997807295379928 0.5825300357453106 1.5970196185457421 1.8762462676450609 0.7501352401273 2.290975589678995 1.6596958929997245 0.813598809385291 3.60294431313911 1.3984547684200312 1.9639585910334567 1.1911695494207668 2.483391875972592 2.3414058505379485 0.6129038579441033 1.84505912258552 1.3742926470327044 4.596406861916084 1.6379546772727154 0.6217004532188546 1.6712188187371397 2.8859082990167493 2.4050324809757235 3.1131628213037805 0.6592151706779881 2.0743682703939323 1.7659302907132202 1.0519832333863075 0.9164695168844965 3.861647422327036 0.2606418010701342 1.9649099010412219 1.8369789588652126 3.6792415168729984 3.1317681696595665 2.922587890082959 1.7103047231474784 0.778288818776021 2.8577275405893747 1.6163973291554625 3.031427926737323 1.538162672167794 2.412753527305657 1.0399527746682171 1.8434303644493628 2.031611561419965 2.220318157105544 1.0284849812967318 1.0306374705781103 1.9071834579980058 1.073516544336576 2.3045781860924146 1.2583475415143197 2.1149548259719957 1.5832316714210393 1.632474113627427 2.677073341094757 1.1655995380089268 2.8338108045873365 1.4314612765034749 1.2801051219071482 3.651548451267326 1.5401951196478714 1.775341907279202 2.5634697058311353 0.9167357817359144 1.9984988183885695 1.5013205961911915 2.474786889949378 2.44896759510521 1.9590214938092916 1.945809200345134 1.4603044199659247 2.3756650145864833 2.0014930882708533 3.0512855993820276 1.5610402955526008 2.4253135911054864 1.0073341449830662 2.5830196208133067 3.772593485235241 2.842615698855749 1.182342181067893 1.1652303082197335 1.5867701944231045 0.1744527488184708 0.9859915375861118 0.540131632968558 1.8944824506082618 2.5585236756733787 2.7402504854145064 2.0990159725611273 2.0199117485319515 2.045257732835031 2.0471975351243756 2.366490086672593 0.5581076145878626 1.5830980874225706 2.6745601345424403 1.0294789811530782 0.9730683018249061 2.499492208019349 0.546717676770934 3.128232631801456 3.7578016391041027 2.113294773538998 2.0856310955247492 2.268750326567148 2.6474400715319075 2.4346648982966324 0.8276307073563341 0.7600446042425738 1.3763221152757596 1.3187039622508263 1.8531421648697357 2.831570873903792 2.9020192296585576 0.8958078820370455 2.6201777717176435 1.388025463561026 2.1519924918366375 1.6266295555816452 3.0289053394578214 1.853713535993745 1.1386681603456303 1.3654762935975544 1.664576113338338 0.24732152972576826 1.4322926746282174 1.5509865191597834 1.325361489524832 2.310895854947818 2.719745994851736 1.2334510265844414 1.7984406583225634 2.122285845532798 2.675357255015577 3.7601315334451866 2.982892842532034 1.2442781776944236 2.3847211760607667 2.157815828799383 1.2358712133739198 2.614685447996094 1.8733155937818222 2.315439513600705 1.718487738652154 1.8821014707534403 1.6908503438396938 2.368501674528276 1.6557199472727622 2.3385635342245035 2.5695739154082875 3.3897889994892676 2.310176328083349 2.3037518759592492 2.3244343148402478 2.2464778944299697 1.014218249689743 1.978405056953609 2.0106835452189458 2.4671455146494194 1.9498311026460722 1.651039513640464 0.5351464995338758 2.3441325019084873 2.9450050220305344 1.7150025695052147 0.20883372861571442 1.9498038524390722 1.9997343590753516 2.3451235852192913 1.4730497874524164 0.6196257313652938 1.2438839961628354 1.6001886200444455 3.4739048165207893 1.4356174137535993 2.2511301628650147 1.9853957686246362 1.3043132745773751 3.1113616006719678 2.3013035429607815 0.9339909831759545 3.077784079227648 0.6258343459546732 3.010424343253076 1.5195026989069933 1.2138768576239123 1.7822239188007163 2.869270368970506 2.632242228667016 1.5282643744924793 2.108819731521681 2.054436753314777 3.085005989759926 2.1861200705296118 1.7354185432742 0.2634590782361101 0.5373693816987523 2.663503427437395 2.8813885173614726 1.6368695930189157 0.9375889990469928 0.08334406251958196 3.0513782763361097 2.027058350879274 2.989305261451198 1.734145014707289 1.5371119929007033 1.6220864039882428 0.13289079744245655 3.1537977582464323 2.295834481129281 1.034240676401637 0.588056822667295 1.7160274518140137 1.308244330102301 2.674025105883658 1.4097232551299974 2.7398024559952803 0.7351249954980296 1.8517761141627345 1.4163371954956951 2.3629528490824323 1.7296843811229432 0.7109730058876328 2.3792752040799234 1.354765151211891 1.671836547782685 2.2599033343155774 2.1643634996882666 1.044648357322768 0.6561863663069027 2.0086412528261026 3.071403475509733 0.9422645757649742 1.6369923727800548 1.2284291731115196 1.1396822566616815 1.7017752533568646 1.210903661236053 2.3854876376427647 1.5341336094377407 2.266148008811635 3.031964758457088 0.8351294115225274 3.6365067510316984 2.2052502392923 3.518014262134643 2.197187120192077 1.1398093572711887 1.708841557988887 1.811441120213396 2.0864597678374928 1.9237964212342684 1.9108269056481966 0.29050958205570654 1.6974750807892938 2.691859486280771 2.262017807897819 1.3109430142540082 1.4135285055341473 2.6965643631020018 2.2473632200807403 0.8967951639146216 1.402413396526541 1.566796684753736 1.6720971713187351 2.2075104117442192 1.4903802629955696 2.145500955724337 2.581200507743038 0.8526886227691907 1.0472979885849487 2.167006525016049 1.2395181130487438 1.5124782049484151 0.19390204162832114 0.474465803232954 1.0071736316385798 2.3303270560219063 1.368520624492018 2.9373518117021815 4.674643047284212 1.1994123769153886 1.1130200995373505 3.0937804060614296 1.1655458945899526 3.715430074685255 0.9676272631608166 1.2207748548230943 1.1628143994831135 2.4976248740106506 1.4595776262002047 2.146353022040776 1.4711859436063284 2.7989002285781774 1.0704554982820018 2.4355953013879943 1.54683039121238 1.6474046045354296 4.06980313166926 1.7389930315359663 1.3342709332473763 3.8529230227221634 2.7779942928682777 2.0678358088309468 1.7178781160727064 3.1096217532133834 0.12551033313935714 1.2158975662131368 2.202931199733062 0.9923660321698716 0.4443211641652796 1.9356971396036802 2.329167143596501 0.9370862847735246 2.034306373684202 2.0180550460082323 0.35418298357098577 2.029421319703871 2.3912600725686097 2.394791996276453 1.261261527297343 2.6611875684913513 0.32666056898336754 1.3645231730595109 2.245724859906339 2.4884378057544074 1.8439496603672412 2.102872565090015 2.4356054758930723 2.9715914092884925 1.7615730280225341 2.8322178512487004 3.7535185325232936 0.6590109173045317 3.5709218929800555 0.7241760825144349 0.569997167976413 3.152236902281361 2.4101440398153984 1.4099337371950236 1.0655215921460228 1.9963525814626581 1.3105607969444097 2.5558040019011186 4.46726966068303 1.5230802127991527 1.2992742207580976 2.835651014884549 2.6110359175493607 3.2464572012988064 2.130316534127515 1.2469709764239745 0.602451941213283 1.435083095390983 2.0750282178968535 1.4153869754144148 0.8855061368754047 0.30579133262759967 2.4769374495498364 3.5748348362882902 0.8466911189472544 1.7116062337600655 0.0 1.2508555628704814 3.303365892913763 0.9244950409335417 2.4559335213448863 3.8927625210692978 2.018558875855055 0.8062790626578563 0.3514998475117389 3.1339841814423886 3.1194788064154717 1.1035208027677585 2.862785495037164 2.4480963346518205 2.1519217505664803 2.2865620753266804 0.8765735528685406 0.7026107310646201 2.714031228243678 1.153995125329549 1.7563644562887133 1.778892409763168 0.8629452844068543 2.4992234423488835 2.226777044028569 1.9065597970507073 1.5067259842308165 0.9489456348352939 3.584681663861188 1.4979896517835882 2.591058682593436 2.431910068153015 2.1473863536086117 0.003467123526748957 2.4493425564965148 2.144168230333062 1.4834395628591712 2.4944282899424635 1.1917111604456407 0.6555884584609114 2.741671026633456 3.322241668275656 2.9630425043667192 2.2763436166129862 1.0103337400017711 1.7577962367085966 0.967002260871803 2.936508097984696 2.769842479202429 1.9553820474024763 2.3571987088162416 2.211004837501901 2.175054202863895 2.7009047957444223 1.1436116861599734 0.908450884211761 0.547467599531438 2.2775216604047057 2.19052575260539 1.6855487241516083 2.601949730701938 3.5243926479744685 2.75454736320033 1.4908727865769011 2.2925619679149167 2.5150389351355806 2.718034525856477 1.3325868567887469 0.18387439091535357 1.9526605303010673 1.342384758181703 1.6200331259859406 1.7649824816820403 1.026627414322354 2.037457251798263 1.2891161484026974 0.9968358989464359 1.44348088198884 1.8398239226503905 2.18911593208319 2.360248248928313 1.6982706224779534 accumulated_time=0.10126018524169922 | .. code-block:: default print(__doc__) import time import numpy as np import matplotlib.pyplot as plt import pytransform3d.plot_utils as ppu from distance3d import gjk, colliders from distance3d import random from distance3d import plotting random_state = np.random.RandomState(0) center, axes, radii = random.rand_ellipse(random_state) ax = ppu.make_3d_axis(ax_s=2) accumulated_time = 0.0 for i in range(700): center2, axes2, radii2 = random.rand_ellipse(random_state) start = time.time() c1 = colliders.Ellipse(center, axes, radii) c2 = colliders.Ellipse(center2, axes2, radii2) dist, closest_point_capsule, closest_point_capsule2, _ = gjk.gjk(c1, c2) end = time.time() accumulated_time += end - start print(dist) if i > 5: continue plotting.plot_segment( ax, closest_point_capsule, closest_point_capsule2, c="k", lw=1) plotting.plot_ellipse( ax=ax, center=center2, axes=axes2, radii=radii2, surface_alpha=0.5) print(f"{accumulated_time=}") plotting.plot_ellipse( ax=ax, center=center, axes=axes, radii=radii, surface_alpha=0.5, color="yellow") plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.246 seconds) .. _sphx_glr_download__auto_examples_gjk_plot_ellipse.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_ellipse.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_ellipse.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_