Created
March 7, 2024 20:14
-
-
Save uwezi/7d4b6d05db55c140972b4f69ec7359eb to your computer and use it in GitHub Desktop.
[nearest neighbors] find the path through a list of points using nearest neighbors. #manim #chatgpt #sorting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://discord.com/channels/581738731934056449/1214983872413044786/1214983872413044786 | |
| from manim import * | |
| class PathAutoSorted(MovingCameraScene): | |
| def construct(self): | |
| # thanks ChatGPT | |
| def closest_neighbor(given_point, points): | |
| # Convert points to numpy array for efficient calculations | |
| points_array = np.array(points) | |
| # Calculate Euclidean distance between given_point and all points | |
| distances = np.linalg.norm(points_array - given_point, axis=1) | |
| # Find index of closest point | |
| closest_index = np.argmin(distances) | |
| return closest_index | |
| pts = [(-4.5958215363727914,1.4503174778870562,0),(-4.5773831653244095,1.4744245018861677,0),(-4.559917132097422,1.4994254002265157,0),(-4.540539631060153,1.522980174893792,0),(-4.524815883276274,1.54911463385556,0),(-4.60559984274426,1.4386139430843976,0),(-4.568852936880162,1.48706662216167,0),(-4.532538387514478,1.5359635528862146,0),(-4.5878089220076435,1.4632938415304948,0),(-4.550302708825722,1.5112639333925764,0),(-4.517885715875228,1.5626999488009274,0),(-4.505968847955872,1.590732141303889,0),(-4.492565362896428,1.617940832112355,0),(-4.476022024812223,1.643511235536529,0),(-4.458866637826155,1.668730339609512,0),(-4.511194441240329,1.576404504471641,0),(-4.484999215913796,1.6311824869261813,0),(-4.500712580037515,1.6050485532126664,0),(-4.467528546803311,1.6561780754614455,0),(-4.450439250045424,1.6814412458543284,0),(-4.440251193553307,1.710128181925561,0),(-4.431579136137383,1.7393662651378088,0),(-4.418931810907212,1.7671186575874809,0),(-4.403588264901726,1.793465963096209,0),(-4.444449356064418,1.6954665505735718,0),(-4.425051041729175,1.7531492976694707,0),(-4.394450756563493,1.8056763661911137,0),(-4.435660643739493,1.724671732206639,0),(-4.410886576468728,1.7800748223441196,0),(-4.386049500133442,1.8184045590230862,0),(-4.36974453561235,1.8441330808879737,0),(-4.359126615120243,1.8726402889509486,0),(-4.345911834027287,1.9000881444148265,0),(-4.333047258393529,1.9275647130477929,0),(-4.377223491253745,1.8308419851887698,0),(-4.353207895425826,1.8866957775426074,0),(-4.3275110505873675,1.9417752163991289,0),(-4.363393017667984,1.857998369279267,0),(-4.340903813835714,1.9144932732282773,0),(-4.320618361363291,1.955379584728148,0),(-4.307421155794707,1.9825825446813519,0),(-4.293534587352909,2.0096975752961055,0),(-4.286178002410458,2.0392835876121245,0),(-4.2763644545097765,2.0680898822807254,0),(-4.266140855771273,2.0968242761092744,0),(-4.312209976610561,1.9681030696368285,0),(-4.289395831354366,2.0243760868403955,0),(-4.271061508266234,2.0823890697929386,0),(-4.299804365100114,1.9957951334468476,0),(-4.282246212579703,2.0540188864247746,0),(-4.261045544753921,2.1111987607263925,0),(-4.2506157761610055,2.139861098020165,0),(-4.237753739132454,2.1675037866150517,0),(-4.227207372203402,2.1958250254530545,0),(-4.209331185851541,2.2205237380380773,0),(-4.255733959070417,2.1254947412768175,0),(-4.234414411833341,2.1823845424950714,0),(-4.200845631172216,2.233195887191064,0),(-4.243778836646442,2.1534935688323666,0),(-4.218624139990098,2.2084312194521902,0),(-4.194148903608827,2.246897779115651,0),(-4.188282889510429,2.2768004544858553,0),(-4.1801513288256995,2.306152122197588,0),(-4.167960671089335,2.3340034917353933,0),(-4.153205008060319,2.360660943566159,0),(-4.190562782243874,2.2617209952284645,0),(-4.175181809978075,2.3205705785918913,0),(-4.147581017593009,2.374836935016316,0),(-4.183423980572683,2.2912565606803335,0),(-4.16120190806331,2.3476748897886055,0),(-4.140904087329425,2.3885484850609533,0),(-4.132096247633296,2.4177399614858963,0),(-4.11939579933511,2.4454716747872083,0),(-4.102472009671764,2.4708454115260277,0),(-4.08990872520598,2.498638680940933,0),(-4.13688061629181,2.4032590147312547,0),(-4.111072388214803,2.4582509091028353,0),(-4.085991821854213,2.5133779438297044,0),(-4.125769644374401,2.4316166359281346,0),(-4.096088419502362,2.484695963100619,0),(-4.083308231791806,2.5283908165310978,0),(-4.074513662953494,2.5574785707962673,0),(-4.064154670300377,2.5861571322192587,0),(-4.0552056961009395,2.6152674336712143,0),(-4.045809352101904,2.6442831984035315,0),(-4.077652838533345,2.542554309372324,0),(-4.060488178811163,2.6009606737729163,0),(-4.041233533079625,2.6588313901346945,0),(-4.068974978950142,2.571688109208276,0),(-4.050325688826529,2.629716431261809,0),(-4.035374661350975,2.672911930764889,0),(-4.026675223869583,2.702008983307676,0),(-4.020819688072995,2.7319429396659674,0),(-4.011564502475591,2.760994971654882,0),(-4.003126185095882,2.790290543960634,0),(-4.032382712935943,2.687866403241482,0),(-4.016582920990578,2.7465934620819312,0),(-3.997998023040571,2.8046533416096233,0),(-4.0236730914642305,2.7169614146615415,0),(-4.007805250663098,2.775775229710194,0),(-3.992820860310645,2.8189985494658805,0),(-3.9794547790361436,2.8463053374955627,0),(-3.9679919393984378,2.850000000000001,0),(-3.9560437865391966,2.850000000000001,0),(-3.946408781046931,2.850000000000001,0),(-3.9872414436980206,2.8331921435362384,0),(-3.9614033492399994,2.850000000000001,0),(-3.931258806418787,2.848248922863514,0),(-3.9735807158991703,2.850000000000001,0),(-3.9510691098197444,2.850000000000001,0),(-3.9175461681933035,2.841574227719291,0),(-3.8990726100102715,2.8173206933984045,0),(-3.884436682439987,2.790586651767949,0),(-3.868559699325877,2.7645876502201268,0),(-3.8532822406057186,2.73819201049283,0),(-3.907943596541087,2.829726079339253,0),(-3.8771489034991853,2.7771897759947946,0),(-3.8477856846850007,2.7239661229851286,0),(-3.891229698649795,2.804241062525819,0),(-3.8607173193802184,2.7515077007110773,0),(-3.839315736685969,2.711283537157899,0),(-3.8281025077983646,2.68291968334753,0),(-3.81733931609661,2.654579446401964,0),(-3.798606144989212,2.6305112021699664,0),(-3.7805121429986457,2.6059575927946237,0),(-3.833861438216265,2.697041394391634,0),(-3.808120327638655,2.6424304442131654,0),(-3.7720586879235487,2.5932640078138287,0),(-3.8242947321653302,2.6681518518513423,0),(-3.7894457465677602,2.618317962111163,0),(-3.762322550759082,2.5815253692434483,0),(-3.7423058604737918,2.5585428452198054,0),(-3.7272124341212765,2.53215785667242,0),(-3.7117861657365854,2.5058512568973472,0),(-3.6976666834355094,2.478932580727387,0),(-3.7527740920390675,2.5696335679314717,0),(-3.7197526609890517,2.5188559851053403,0),(-3.688871520480862,2.466473322684769,0),(-3.7358547758796723,2.544723601031686,0),(-3.705844588070298,2.4918054156193463,0),(-3.6825135783892295,2.4526109789171815,0),(-3.670577598720452,2.42456252543295,0),(-3.657620250810698,2.3972307419136367,0),(-3.644352921394283,2.36979579131782,0),(-3.6300411617910497,2.343030757828065,0),(-3.6770429493587047,2.4383751009891523,0),(-3.6515653938908703,2.383233359656523,0),(-3.622865437798136,2.329573529749859,0),(-3.665873801977651,2.4100552066395355,0),(-3.635862674797867,2.3571267852359132,0),(-3.6184448012171826,2.3149774352519987,0),(-3.6094073336092007,2.2858454593317736,0),(-3.5957622289645244,2.258572750120245,0),(-3.585771405571079,2.2297568211328773,0),(-3.5696109268683722,2.2039820349146657,0),(-3.6138952379704286,2.300421011356168,0),(-3.590965956505957,2.2440957416974214,0),(-3.5618453537882933,2.190856339614633,0),(-3.602315572094403,2.2723437956939634,0),(-3.578624221228294,2.216284413837164,0),(-3.554513281735481,2.1774836539537903,0),(-3.5376302409939457,2.1521910443611167,0),(-3.527723064868633,2.1233848986873824,0),(-3.512836914061125,2.096766859309087,0),(-3.497289028131328,2.0705442911884724,0),(-3.547055772348352,2.164180513117423,0),(-3.520491314824325,2.10995769519343,0),(-3.490098999436438,2.05709470049812,0),(-3.5319432758584375,2.1380401988062085,0),(-3.504634573381755,2.0839095808353623,0),(-3.4830042698965054,2.0435945962345765,0),(-3.470347666627,2.0160366210745244,0),(-3.4593117696879006,1.987641408701147,0),(-3.4488336229504144,1.9590312745456164,0),(-3.434940385962548,1.9319371997635728,0),(-3.478163670537687,2.0291323488221322,0),(-3.454740096813614,1.9730919135380192,0),(-3.4289225378849704,1.9179238665809737,0),(-3.4655323260617954,2.0015659439095663,0),(-3.4426879884507846,1.9450735104349752,0),(-3.4226191396764625,1.9040366359932603,0),(-3.411784035778761,1.8755493060841937,0),(-3.4042248620264304,1.8460462539165292,0),(-3.394837458907658,1.81711796197701,0),(-3.382664836375952,1.7891773875828016,0),(-3.4166437955826523,1.8900051262622333,0),(-3.3984277805665535,1.8319401612995465,0),(-3.4071967503004323,1.86100472584578,0),(-3.388189071535418,1.803392549497963,0),(-3.3755872567619623,1.775668284386106,0),(-3.3616671951534074,1.7487671876346584,0),(-3.3457226151997146,1.7227780584578631,0),(-3.3312970976378136,1.6961845850064121,0),(-3.3163375192337297,1.669614318512428,0),(-3.367031357259826,1.7630435235534925,0),(-3.336805197244837,1.7104060069145923,0),(-3.3080364411119367,1.6568205659594346,0),(-3.3533415195075365,1.7359894285427404,0),(-3.3241502521814263,1.6827119979351088,0),(-3.3007754558729885,1.6434091493403338,0),(-3.28874308881426,1.6154358967866986,0),(-3.2764315976055434,1.5876011457048018,0),(-3.2641992115069236,1.5598509315645988,0),(-3.2514177633493007,1.5322870668689315,0),(-3.2939543239207896,1.6297687622027917,0),(-3.2688225675703286,1.574384086111438,0),(-3.2451087948795925,1.5184023659639942,0),(-3.2816721417090426,1.601923320814422,0),(-3.2590273239496654,1.5455038210030114,0),(-3.2409021910197606,1.5037431543092774,0),(-3.2302230585968212,1.4753693556481928,0),(-3.21662540961174,1.4480977887661635,0),(-3.2034171018032183,1.4206600835965622,0),(-3.1876478614943817,1.394662477266867,0),(-3.237131188351884,1.488965889973474,0),(-3.2092325366394054,1.4347586196921076,0),(-3.1789084322479586,1.3821640622146256,0),(-3.2240106660644856,1.461441176248303,0),(-3.1965627144430226,1.4070363771886962,0),(-3.1723581250630777,1.3683915723106526,0),(-3.16246878733123,1.3395478136452812,0),(-3.1528377818973063,1.310695067630942,0),(-3.1434507133335603,1.2816957807243332,0),(-3.128740301795599,1.2551064680393336,0),(-3.1677769365110664,1.3538450705379839,0),(-3.1476068320650907,1.2963693855800171,0),(-3.1228507944347834,1.2410387139393266,0),(-3.1565806678838215,1.3254794785716348,0),(-3.137250083027623,1.2677623609653357,0),(-3.1155742576166157,1.2276357286634574,0),(-3.1066360235764345,1.1984734417461231,0),(-3.0933176227034185,1.1710748633628862,0),(-3.083181103408182,1.1423407129652885,0),(-3.070111556375941,1.1148844742512602,0),(-3.1110358589089913,1.213075820025627,0),(-3.0875906524478265,1.1569401608876695,0),(-3.062522198439106,1.101656108952481,0),(-3.099296308054199,1.1851049497435078,0),(-3.0755690573633188,1.1291253901397873,0),(-3.0569392408585405,1.0874639073253571,0),(-3.0431295394454594,1.0603130386908715,0),(-3.0279240971824217,1.0339005954950324,0),(-3.0123266727986064,1.0076887483095327,0),(-2.9975954237619926,0.9811216725433637,0),(-3.0507354436309506,1.0735318973364756,0),(-3.020079448842386,1.020822006320641,0),(-2.993872930835779,0.9663321137674693,0),(-3.034990935513524,1.0474153207372787,0),(-3.003760903713351,0.9950706818035493,0),(-2.987275472104396,0.9525821486526399,0),(-2.974801586688992,0.9248111479049863,0),(-2.962396448949328,0.8969483473700026,0),(-2.9470441675769137,0.8706400123569387,0),(-2.930376204243643,0.8451076304163595,0),(-2.981894947086342,0.9383119716074368,0),(-2.9554073374500645,0.8833932626110568,0),(-2.9241283141845087,0.831195338291037,0),(-2.9684350153452512,0.9109527651820132,0),(-2.93904210347985,0.8576571400800572,0),(-2.916327443307352,0.8180905904518274,0),(-2.9021846999430014,0.7914005306688281,0),(-2.8925133909822414,0.7624746454932392,0),(-2.882307666010051,0.7338308405134529,0),(-2.8697478732002497,0.7061148714739233,0),(-2.907382918234443,0.8057381221320363,0),(-2.8862833173508617,0.7485543658653394,0),(-2.8643505784212935,0.6918510286733177,0),(-2.8971910877900147,0.7769904008971406,0),(-2.8750693638208,0.7204071679985106,0),(-2.860631662552254,0.6770605700215265,0),(-2.8453039823189257,0.6507826848640161,0),(-2.8328851151313548,0.6230111762660671,0),(-2.8223330890161415,0.5946284673082577,0),(-2.8126750429998335,0.5657747260534494,0),(-2.8539225966469854,0.6633647152818583,0),(-2.8293265060587798,0.6081813312284435,0),(-2.8077882392684352,0.5513280256806263,0),(-2.8380875752470787,0.6373472291090098,0),(-2.81851386599236,0.5798635921694032,0),(-2.8045821625872573,0.5364179929950232,0),(-2.79481545648039,0.5076486486956401,0),(-2.782708577477729,0.47986855863059796,0),(-2.7738294252197075,0.4508238342256532,0),(-2.7664759843474167,0.42131781886266306,0),(-2.7984206150281623,0.5224672462749241,0),(-2.7769236367820795,0.4657574827141712,0),(-2.758998742828755,0.40802575876488495,0),(-2.7903526129658136,0.49306540385315967,0),(-2.7713083618440337,0.43578281558238385,0),(-2.7509009394136976,0.39510238528028635,0),(-2.735292130223742,0.3688989713762668,0),(-2.7268812434636613,0.3395841005475614,0),(-2.7214302864303983,0.3096056528161313,0),(-2.7152402267192177,0.2798681086713252,0),(-2.742961933420905,0.382080857481378,0),(-2.7234720388837306,0.3247191980418767,0),(-2.7111427430458783,0.2651780225613646,0),(-2.730847663267526,0.35431011549767066,0),(-2.7196947871799066,0.2944538857666124,0),(-2.708010882226147,0.25025222441931644,0),(-2.6939516876407503,0.22318589522782323,0),(-2.6825312110878436,0.19505305661748337,0),(-2.6702446938913487,0.167141497149838,0),(-2.655107050908379,0.14066767891991463,0),(-2.700837587502323,0.23679370127684288,0),(-2.676654144060021,0.18098010079712307,0),(-2.6483870690160805,0.12697717689338084,0),(-2.686893297371398,0.20966675586258096,0),(-2.662422509492704,0.15404946011945447,0),(-2.644011917588136,0.11236738386425488,0),(-2.633274199512053,0.08381976169654369,0),(-2.6218003198958404,0.055574988254327364,0),(-2.614666325128751,0.025981986744663177,0),(-2.605795047891947,-0.0030008057362729164,0),(-2.638780848472999,0.09804174536944428,0),(-2.617296773795155,0.04100426161183155,0),(-2.5979216103538336,-0.016062083763509614,0),(-2.6270893626608203,0.06987932427532322,0),(-2.6118625711005383,0.010991090650012535,0),(-2.59203473215542,-0.030130938281499528,0),(-2.5799986426554913,-0.05801537669252255,0),(-2.563779672678976,-0.08378148722952583,0),(-2.5522948372167034,-0.11200095457103246,0),(-2.5402058778858336,-0.13995734812831337,0),(-2.587310444863457,-0.044631597299431676,0),(-2.5573641868487087,-0.09761729381725265,0),(-2.535596725415948,-0.1544950135488921,0),(-2.571108388848164,-0.07040696212831879,0),(-2.5455033957043933,-0.1256561486215107,0),(-2.5306891168904584,-0.16893465969870783,0),(-2.5172813400084486,-0.19623479154983434,0),(-2.5080673821876553,-0.22526400518191592,0),(-2.494141604519991,-0.25239675632092545,0),(-2.4774159202749977,-0.27789000854726104,0),(-2.525017099856239,-0.1830915034548164,0),(-2.501321752370783,-0.23894188808626393,0),(-2.4695153160780348,-0.29093487173911836,0),(-2.511882659857146,-0.21049811006255323,0),(-2.486127929766136,-0.26537246513820273,0),(-2.463580000782354,-0.3049833604376297,0),(-2.453739486369403,-0.3338394629254812,0),(-2.4469222638652415,-0.36356927466567124,0),(-2.435920524596774,-0.3919865561832847,0),(-2.428285646371239,-0.4215015669085915,0),(-2.4582255909885005,-0.31926335687078167,0),(-2.4420420585298075,-0.37801820536158565,0),(-2.421792712562346,-0.43530119780672294,0),(-2.4502696534117243,-0.3486903302946672,0),(-2.431637578883236,-0.40662364531966105,0),(-2.4133426253679517,-0.4479970250258718,0),(-2.401386507927201,-0.47591726902172243,0),(-2.386789476178556,-0.5025939723331736,0),(-2.3733835239746215,-0.5299500410628996,0),(-2.366384946697615,-0.5595569265000757,0),(-2.406075695660486,-0.4614052215861139,0),(-2.3807641498436607,-0.5166040917091589,0),(-2.3636039136923666,-0.5745520543019672,0),(-2.3951289546134555,-0.48982521742890905,0),(-2.3688176967368673,-0.5445013717239189,0),(-2.361495742952819,-0.5896564781077354,0),(-2.3490274286310955,-0.6174605778260395,0),(-2.3390303284301064,-0.6462635262031043,0),(-2.326786213359815,-0.6740002925051307,0),(-2.321822438160009,-0.7040953523362256,0),(-2.3558779468848834,-0.6038349254737353,0),(-2.331383944673907,-0.6594590109544983,0),(-2.3197253459790814,-0.7192013182687977,0),(-2.3436063470607733,-0.6317153972559465,0),(-2.3243131371917807,-0.68904927574781,0),(-2.3136681319859935,-0.7331976806895582,0),(-2.3025649711148235,-0.7614709663476988,0),(-2.2895696055736354,-0.7890374359461296,0),(-2.2802348077582177,-0.8179531849781925,0),(-2.2754129167675496,-0.8480429930448917,0),(-2.3094074072618844,-0.7478412535867954,0),(-2.2861694446523337,-0.8039044096825898,0),(-2.2739569953074295,-0.8632241753135192,0),(-2.295502005226424,-0.7749877157805559,0),(-2.2771792415726333,-0.8328947885620397,0),(-2.270776979549339,-0.8781397880112813,0),(-2.26203823011612,-0.9073407265377882,0),(-2.2473017972552207,-0.9340440078172222,0),(-2.2325312382154556,-0.960728209215826,0),(-2.2173508364813777,-0.987182598454813,0),(-2.2658632466201443,-0.8925773512084376,0),(-2.24007783734497,-0.9474754040806952,0),(-2.212495960149564,-1.0016400594412431,0),(-2.2548243681238818,-0.9207775489868747,0),(-2.2248241045772335,-0.9738883039515762,0),(-2.2051188707013636,-1.0149879639076598,0),(-2.1906012572650257,-1.041801829832424,0),(-2.17981581263273,-1.070317763383019,0),(-2.171924816806624,-1.0996915949507216,0),(-2.1663523862857637,-1.1296444126968053,0),(-2.198202770304518,-1.028580445567463,0),(-2.176978016584745,-1.085302252562213,0),(-2.1616141698194986,-1.1441405262135433,0),(-2.1847728944911573,-1.0558950264090536,0),(-2.1684213979971365,-1.1145345750765814,0),(-2.1584850530265594,-1.1590668998678333,0),(-2.1509053598037156,-1.188589244288019,0),(-2.141598104713904,-1.217632956654118,0),(-2.130267977977345,-1.245795403162744,0),(-2.120082365377845,-1.2744444023057542,0),(-2.1552540226223265,-1.1739715449457364,0),(-2.137313531640813,-1.2322695695120394,0),(-2.114643945035434,-1.2886926157569412,0),(-2.146459162837534,-1.2031775730102974,0),(-2.1240366656096246,-1.259715128323365,0),(-2.1115082711761053,-1.3036176133053248,0),(-2.107982813434291,-1.3339148256998774,0),(-2.09962751163357,-1.3631110139464726,0),(-2.0882765507016208,-1.3913064066008618,0),(-2.071817882248347,-1.416958359145521,0),(-2.1097681838075095,-1.3187688541231917,0),(-2.0951370569666143,-1.377685780471373,0),(-2.0650242990649317,-1.4306124878215427,0),(-2.10517525341122,-1.34890500945753,0),(-2.0805524844961583,-1.4044565702357739,0),(-2.0606624382388943,-1.4452262543622267,0),(-2.0468219072767635,-1.4723924874564733,0),(-2.041036423403925,-1.502334959463193,0),(-2.0349393364484274,-1.5322103185273288,0),(-2.026302840880603,-1.5614315214243737,0),(-2.0533468219465916,-1.4586079493458652,0),(-2.0375958173886226,-1.517192625249541,0),(-2.019398672035638,-1.5750300674838447,0),(-2.043647770981319,-1.4873093524471235,0),(-2.0299628937468905,-1.5466263866601333,0),(-2.0143791193288973,-1.5894311817808562,0),(-2.005510233235354,-1.6185412867024251,0),(-1.998886723757618,-1.6482480054561384,0),(-1.9878108192408317,-1.6765548261198755,0),(-1.97768781507614,-1.7052717668564503,0),(-2.008953249110168,-1.6036841791758198,0),(-1.9921707993975986,-1.6619404983760504,0),(-1.9704991878417633,-1.7187221066609497,0),(-2.0031735347009922,-1.633612047875334,0),(-1.9835947253235073,-1.6912113111845712,0),(-1.96616073667646,-1.7333428400166206,0),(-1.9543603228426518,-1.7614487103413996,0),(-1.9375901970452938,-1.786900405020874,0),(-1.9257085325213112,-1.8149278637265176,0),(-1.9158289299536324,-1.8437722114604822,0),(-1.9607575490447546,-1.747604451629195,0),(-1.9325275963247148,-1.8012864425682789,0),(-1.9103667778110505,-1.8580113440303627,0),(-1.946456061154826,-1.7744913576778003,0),(-1.9203593366109468,-1.829209814065455,0),(-1.9043313292138504,-1.8720171057947899,0),(-1.8936887008926373,-1.9005280558039053,0),(-1.8857837749397375,-1.929780094274128,0),(-1.8734376134271595,-1.9576700212054818,0),(-1.8595846815987247,-1.9847495206976211,0),(-1.8980486286288103,-1.885913712421232,0),(-1.8794844183730754,-1.9436691586492898,0),(-1.8549199014768336,-1.9992694321569158,0),(-1.891420971060194,-1.9156093489771844,0),(-1.8675212220343278,-1.9717264900102052,0),(-1.8508223322692574,-2.0139594944086716,0),(-1.8356814325362094,-2.040404003029026,0),(-1.822316136984904,-2.0677766613778776,0),(-1.812894525506775,-2.096499360328969,0),(-1.8012128285416702,-2.124653007963987,0),(-1.8438329230287882,-2.0275144256457005,0),(-1.8195405320513036,-2.082772794867011,0),(-1.797627715771869,-2.139476468045869,0),(-1.8282943035598729,-2.0537463539410017,0),(-1.80653485187077,-2.1103609097955633,0),(-1.791271541980765,-2.153339622705203,0),(-1.7830457493000036,-2.1825615850178424,0),(-1.775514326057992,-2.2120977627908105,0),(-1.7675373374516474,-2.2415082290884136,0),(-1.755204025152527,-2.2693994362744485,0),(-1.785733714942947,-2.1675494951209062,0),(-1.7721631343829405,-2.2269758512677753,0),(-1.749203583536797,-2.2834202316437406,0),(-1.7798203933461394,-2.197467459072798,0),(-1.7616301605031286,-2.2555685727140236,0),(-1.7448511356289043,-2.2980368044150987,0),(-1.7310999483389133,-2.3251820467695197,0),(-1.7159634758573434,-2.3515957210521825,0),(-1.706394265372999,-2.3804854714600183,0),(-1.6991356058850624,-2.4100184455149822,0),(-1.7389103712775111,-2.3120829897083572,0),(-1.7102102628543663,-2.3657197623475668,0),(-1.6977160135085365,-2.4252030679948406,0),(-1.7243498946434528,-2.3388577470250724,0),(-1.7016296099632253,-2.3949729164106452,0),(-1.6965250295158323,-2.4404073292232096,0),(-1.6925862338145043,-2.470653613546817,0),(-1.6893810381467786,-2.500967570344475,0),(-1.6788786247595062,-2.5296038590332475,0),(-1.6679285377716406,-2.5580599462308116,0),(-1.6945489331512649,-2.455529599076948,0),(-1.6840737107664638,-2.515265132320193,0),(-1.6604316240172552,-2.5713409208385225,0),(-1.6904521006394393,-2.485754390942781,0),(-1.6737936416711385,-2.5439820004069555,0),(-1.6538002357625585,-2.585074554450455,0),(-1.6449357639730857,-2.61425934583595,0),(-1.6353113249161741,-2.643141100752975,0),(-1.627985637627282,-2.6726987432687994,0),(-1.6206901924813182,-2.7023015924987166,0),(-1.6494374960713483,-2.5996880586420605,0),(-1.630803405549972,-2.6577104749797273,0),(-1.6143050200693825,-2.7161514147228902,0),(-1.641019362680041,-2.6289987421357712,0),(-1.6239037456185041,-2.6873931694229576,0),(-1.606865686256885,-2.7294647281646127,0),(-1.5953697382500982,-2.757716322903093,0),(-1.5849153732730275,-2.786142623333951,0),(-1.5716421724600629,-2.813540012635823,0),(-1.5627080926659043,-2.84257485286593,0),(-1.6010221424552633,-2.7435516369174184,0),(-1.5774300965386727,-2.799430160147878,0),(-1.5479687053050522,-2.8386584179311862,0),(-1.5918347756298608,-2.7725518222760446,0),(-1.5684849543260966,-2.8284604675895406,0),(-1.538973631687882,-2.8263427103594294,0),(-1.5274131627102454,-2.79855608924643,0),(-1.5205350678241292,-2.768846335191485,0),(-1.5164535239679677,-2.738631181142415,0),(-1.506106197308037,-2.709952897856681,0),(-1.5309032117213517,-2.8134022187174885,0),(-1.5189198130020156,-2.753681278177713,0),(-1.5039448039298142,-2.6948559981406484,0),(-1.524272147037928,-2.7836322149867883,0),(-1.5117111514177821,-2.724136426747581,0),(-1.500386277772428,-2.680026133206721,0),(-1.489345109720921,-2.6516512448320015,0),(-1.4828453678066764,-2.621852148276615,0),(-1.477173820162874,-2.5919747021049435,0),(-1.466730256793342,-2.563392920022915,0),(-1.4957134870871998,-2.6655087977217438,0),(-1.4788550762373494,-2.607132583895727,0),(-1.4611508150789312,-2.5491993358199436,0),(-1.4859265711000709,-2.636788486135545,0),(-1.4729333012019017,-2.577325265210886,0),(-1.4553557501509935,-2.5350924146515137,0),(-1.4500373317717021,-2.50507292686454,0),(-1.4409382319973716,-2.476012951743099,0),(-1.4338840304374165,-2.4463966371233625,0),(-1.4247732001635798,-2.417287488699247,0),(-1.4522303068486706,-2.5201652713703857,0),(-1.438316418212922,-2.460989167437838,0),(-1.4230658180991935,-2.402132527503072,0),(-1.4463246765581772,-2.490280895440938,0),(-1.4293512960057864,-2.4318349641101524,0),(-1.4235480448258302,-2.386889317219295,0),(-1.4196139933704548,-2.3566636885460577,0),(-1.4109866681173324,-2.3274225298412916,0),(-1.3992054940414937,-2.2993073399909867,0),(-1.3869720549829172,-2.2714162763615855,0),(-1.421018616465481,-2.3718497030440173,0),(-1.405577987807451,-2.313163000407371,0),(-1.3812778438178626,-2.2572683450082356,0),(-1.414851508642649,-2.3421755298780704,0),(-1.3923248306534557,-2.285696885416953,0),(-1.3775948234392001,-2.2424689070708776,0),(-1.371520753826504,-2.212611132052382,0),(-1.3644614752440378,-2.182979911494751,0),(-1.351376521278205,-2.155439884364652,0),(-1.3383665765573602,-2.1278537814346783,0),(-1.3738699238396372,-2.227679954256547,0),(-1.3582922029503552,-2.1690325790710308,0),(-1.3342184640987578,-2.1131779112593825,0),(-1.3687615995233722,-2.19761196307864,0),(-1.34472834593007,-2.1417143691862774,0),(-1.3284910870399336,-2.099043373615817,0),(-1.3201599290561723,-2.069824614344366,0),(-1.3151640597169176,-2.0397789774978627,0),(-1.310182354527792,-2.0096935771428246,0),(-1.3052614851297772,-1.9796663863115416,0),(-1.325616436257231,-2.084065911038703,0),(-1.3123599399250907,-2.024788149816763,0),(-1.3039845117295976,-1.9644691055907486,0),(-1.3184653668646256,-2.0546682143314894,0),(-1.3087691832513504,-1.9945083557313736,0),(-1.2996809401502045,-1.949838067554014,0),(-1.2949376477892625,-1.9197739297642278,0),(-1.2914950759336465,-1.8895381840169185,0),(-1.2905236155939404,-1.8590796629968558,0),(-1.2864811936018152,-1.8288478676938995,0),(-1.296321412884695,-1.9349618590678561,0),(-1.291658394571749,-1.874288222397498,0),(-1.2859802959373483,-1.8136052595213763,0),(-1.2921861491799536,-1.904773354516114,0),(-1.2886125399512116,-1.843949038678636,0),(-1.2863060241791975,-1.7983579022590899,0),(-1.286509793463242,-1.7679944205358877,0),(-1.286212238974196,-1.737509827811854,0),(-1.28224507261343,-1.7074646426381859,0),(-1.2786142548036827,-1.6772414376201157,0),(-1.287854377649624,-1.783185868647805,0),(-1.2859386649049476,-1.7222614456157,0),(-1.2790945391164101,-1.6619981660109668,0),(-1.2868491213474544,-1.7527473598697025,0),(-1.279471276229404,-1.6924681745209489,0),(-1.2774176691692714,-1.646839798369571,0),(-1.2698586758860853,-1.617297929528996,0),(-1.2634239734122863,-1.587571087556836,0),(-1.2581576660470895,-1.557534139010008,0),(-1.2551430019578431,-1.5271874991630638,0),(-1.2732985379877182,-1.6321557675646285,0),(-1.2604794450311452,-1.5726072058751333,0),(-1.2503235928827483,-1.51271817649273,0),(-1.265520389158229,-1.6026771473803472,0),(-1.2569426890819029,-1.542331776254653,0),(-1.2462933783470738,-1.4980094928953522,0),(-1.2426653098432325,-1.4677243758188279,0),(-1.2412589526153115,-1.4373128869078524,0),(-1.2409036447931865,-1.4068405125147516,0),(-1.2362617935617484,-1.3767171406066196,0),(-1.244465196759091,-1.482868629166598,0),(-1.241725491805278,-1.422069188421082,0),(-1.2344233227015422,-1.3615775228020806,0),(-1.242898615219755,-1.4524753243410267,0),(-1.2380005884310719,-1.3918685298093871,0),(-1.2306761908605455,-1.3467941874092293,0),(-1.2236721535776511,-1.317111428272676,0),(-1.2163501273869726,-1.2875082904982582,0),(-1.2073907582277883,-1.2583903966948322,0),(-1.1987961627079737,-1.2292340887909357,0),(-1.2274071896608587,-1.3318978243118897,0),(-1.2125840797766816,-1.2727297625685774,0),(-1.198261288553376,-1.213992635054166,0),(-1.2197064063278025,-1.3023852321880909,0),(-1.2018806725935702,-1.2441697441544273,0),(-1.1948702058484275,-1.1991235879946018,0),(-1.19115257157921,-1.168989111262518,0),(-1.1848652513638311,-1.1391725032293616,0),(-1.1804947492733318,-1.109151838554675,0),(-1.1765497945562304,-1.0789177329523607,0),(-1.1944534290021283,-1.1838784478039794,0),(-1.1811145409861459,-1.124390075349136,0),(-1.1769570730391434,-1.0636723360533389,0),(-1.1886637458446228,-1.1539427246918426,0),(-1.1781109692125395,-1.0940884526473464,0),(-1.1758430948666836,-1.0484622389135239,0),(-1.1726456641452772,-1.0182973146114367,0),(-1.1676278856583173,-0.9884324381010372,0),(-1.1620575414594094,-0.9584577853022074,0),(-1.161396035102637,-0.9279902319913086,0),(-1.1758328058984588,-1.033211406263846,0),(-1.165294185638478,-0.9733612123184827,0),(-1.159048523559832,-0.9129211513316354,0),(-1.1683410208406664,-1.0036665918544634,0),(-1.1610861167381255,-0.9432379187987779,0),(-1.1565484241630581,-0.8978766338791678,0),(-1.1481866945483732,-0.8685631398260898,0),(-1.1425202467816027,-0.8386280218673824,0),(-1.1337287892857748,-0.8094433588170689,0),(-1.1273931115334053,-0.7796167287436049,0),(-1.151851364454812,-0.8833671324243109,0),(-1.1386740862110627,-0.8238701408800264,0),(-1.1251368030119533,-0.7645337226033369,0),(-1.144636124954223,-0.8537313679181744,0),(-1.1301874028613272,-0.7946093915606646,0),(-1.124063291842607,-0.7493207157953249,0),(-1.1166603370408377,-0.7197504213082604,0),(-1.1127870135052438,-0.6895830529488146,0),(-1.1056002143752097,-0.6599429497355639,0),(-1.101762896073839,-0.6298842854841,0),(-1.1198425923507809,-0.7346655563567162,0),(-1.1089955102943876,-0.6748110352879326,0),(-1.0987908335858672,-0.6149258481680255,0),(-1.1158631535092047,-0.7045204344143647,0),(-1.1019560403416373,-0.6451338985173266,0),(-1.0962010944153615,-0.5998965017617414,0),(-1.0906049506909283,-0.5699231624944697,0),(-1.0864790400233282,-0.5397275641741341,0),(-1.0827946481370496,-0.5097159990584466,0),(-1.0756268940796936,-0.48007941536096044,0),(-1.0937944169499882,-0.5848367572104881,0),(-1.0866270970232854,-0.524477446748485,0),(-1.071511419437815,-0.46539435932281753,0),(-1.0891596962784444,-0.5547409610054059,0),(-1.0788194922466172,-0.49499233993382336,0),(-1.0709127857489202,-0.45015527667070687,0),(-1.0654788805360484,-0.4201439311404919,0),(-1.0558653763284185,-0.39125930842267204,0),(-1.044865664343074,-0.3628346362673353,0),(-1.0365090756693303,-0.33361433037044647,0),(-1.0680092468656788,-0.43518338753389973,0),(-1.0498145014830613,-0.3772602043092958,0),(-1.03453991895124,-0.3184911553006755,0),(-1.0615736545378094,-0.40540156999059407,0),(-1.0419310668140052,-0.34786880385768587,0),(-1.03102377003759,-0.30365118565150256,0),(-1.028489167593603,-0.2733431885858661,0),(-1.0199148684525117,-0.24407681807796938,0),(-1.0165670895423762,-0.2138013717480431,0),(-1.0065574754343631,-0.18502297159820205,0),(-1.0286036531433618,-0.28859359498799975,0),(-1.0190332908210784,-0.22885148316371906,0),(-1.0023858545790425,-0.1703537663773731,0),(-1.0244704494763806,-0.2586313597714172,0),(-1.0122239917968345,-0.19918201798859064,0),(-1.0011631081297276,-0.15515202655944357,0),(-1.0005587912384908,-0.12468519997211056,0),(-0.999179550334802,-0.09431444432225128,0),(-0.9904044555639349,-0.06519408274796887,0),(-0.9816456342849773,-0.03611465874917864,0),(-1.000197889283187,-0.1399317652295708,0),(-0.9958997644850514,-0.07942045200483955,0),(-0.9796221226031769,-0.020998660507416635,0),(-1.0010994572114906,-0.1094439505916634,0),(-0.9846690492324321,-0.051062801256756045,0),(-0.9790604231311892,-0.005758171798897101,0),(-0.977110471035544,0.024680869415085068,0),(-0.9721916918101425,0.05475244794204913,0),(-0.9716068607986368,0.08522413530663127,0),(-0.9664091437014171,0.11507388056561758,0),(-0.9781454619970793,0.009465193416928397,0),(-0.9712898290014071,0.06997659474394105,0),(-0.9632602354934399,0.12999609151001407,0),(-0.9753236466187873,0.039826669521881096,0),(-0.9707375718306772,0.10045017678370348,0),(-0.9589294226570333,0.1446190892378181,0),(-0.950408026932851,0.173841323543864,0),(-0.9472954055111242,0.20418174532879477,0),(-0.9451190363263859,0.2346056176403144,0),(-0.9373760198350318,0.2640803563003353,0),(-0.9556042901425688,0.1595030233996111,0),(-0.946178054086618,0.21939159503763442,0),(-0.9335577360607767,0.2788454743625318,0),(-0.9490257337810002,0.18902938688366114,0),(-0.9418663527946092,0.24950555227820595,0),(-0.9331710581302999,0.29409140767438346,0),(-0.9254303225293428,0.3235695604482705,0),(-0.9161020189160194,0.35248627472707456,0),(-0.9104627663502352,0.38225336135449334,0),(-0.9104757867851818,0.41275497653724036,0),(-0.9298873348819332,0.3089845323968679,0),(-0.9115475074768926,0.36704115115809266,0),(-0.9079880459066629,0.42780154251399005,0),(-0.9194930182213628,0.337617208647374,0),(-0.9104405050686641,0.3975041812277551,0),(-0.9048242041652679,0.44272059435406136,0),(-0.9020167984630119,0.4730852827410102,0),(-0.894592032968367,0.5026150982357529,0),(-0.8906636609143468,0.5328565216987745,0),(-0.8847715064533084,0.5627503259919636,0),(-0.9037567733048149,0.4579340290001068,0),(-0.892323722556521,0.5176963040975813,0),(-0.8831493983121601,0.5779146514814063,0),(-0.8974349748918056,0.48763158450928373,0),(-0.8870246940579967,0.5476668533152417,0),(-0.8804490972711356,0.5929245274522188,0),(-0.8758564023209372,0.6228804006182368,0),(-0.864506840206654,0.6511890404094658,0),(-0.8591696696401661,0.6811863684439132,0),(-0.8544566515715672,0.7110622005134657,0),(-0.8491598034199508,0.7409286736409241,0),(-0.8798579933238582,0.6081639040305061,0),(-0.8625390999199292,0.666312399842321,0),(-0.8502290321976962,0.7257153652501703,0),(-0.8699957748619305,0.6369602105657491,0),(-0.8548640608782265,0.6958168071099423,0),(-0.8465342684147061,0.755951808077771,0),(-0.8378020107030424,0.785120778708447,0),(-0.8361578958255032,0.815541218430357,0),(-0.832197226774853,0.8456490965346254,0),(-0.822597578339467,0.8745687696610709,0),(-0.8430344263326117,0.7707956319709512,0),(-0.8355954491870485,0.8307816795831645,0),(-0.8211740888101575,0.8897530272962431,0),(-0.8362317550712639,0.8002905611598274,0),(-0.8280430666415848,0.8603232559980668,0),(-0.8184697760661561,0.9047621810016978,0),(-0.8100801618139859,0.9340832414334989,0),(-0.8080281375583858,0.9643842270450399,0),(-0.8062184144425237,0.9947289383816699,0),(-0.7993117619886139,1.0244351591765675,0),(-0.8140385902997087,0.9193550763646674,0),(-0.8083735924036115,0.9796311501222132,0),(-0.7943033744843864,1.0388401602865585,0),(-0.807643919754232,0.9491382315363723,0),(-0.8029777102106044,1.0096314830788875,0),(-0.7932088487752309,1.0540516696082312,0),(-0.7909695485170913,1.0843577605002108,0),(-0.790050063250356,1.1145403673324865,0),(-0.7860489103829988,1.1447773724937007,0),(-0.7828159428788002,1.1750432069999297,0),(-0.7907814286977293,1.0691080846575938,0),(-0.7879218515204962,1.129641980398786,0),(-0.7926603658322597,1.0995145787407936,0),(-0.7854116391740997,1.1600148882944354,0)] | |
| # find starting point | |
| pt2 = np.array(pts) | |
| start = None | |
| maxsum = 0 | |
| for pt in pts[0:100]: | |
| sum = np.sum(np.sort(np.linalg.norm(pt2 - pt, axis=1))[0:3]) | |
| if sum > maxsum: | |
| maxsum = sum | |
| start = pt | |
| print(start) | |
| sorted = [start] | |
| pts.remove(start) | |
| while (len(pts)>0): | |
| idx = closest_neighbor(sorted[-1], pts[0:20]) | |
| sorted.append(pts[idx]) | |
| pts.remove(pts[idx]) | |
| path = VMobject() | |
| path.set_points_smoothly(sorted).set_stroke(width=.1) | |
| self.add(path) | |
| for pt in sorted: | |
| self.add(Dot(point=pt,radius=.0025,color=RED)) | |
| self.play(self.camera.frame.animate.scale(0.01).move_to(path.get_start())) | |
| d = Dot(radius=0.005, color=ORANGE, fill_opacity=0.5, stroke_width=0) | |
| self.add(d) | |
| self.play( | |
| MoveAlongPath(d, path), | |
| MoveAlongPath(self.camera.frame, path), | |
| rate_func=rate_functions.linear, | |
| run_time=30 | |
| ) | |
| self.wait() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
