Skip to content

Commit

Permalink
Add a more interesting example for the 2D data structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
André Nusser committed Jan 22, 2025
1 parent 3c32f14 commit cda09d1
Show file tree
Hide file tree
Showing 25 changed files with 412 additions and 16 deletions.
16 changes: 12 additions & 4 deletions Frechet_distance/examples/Frechet_distance/Frechet_DS_2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,23 @@ using Curves = std::vector<Curve>;
int main()
{
Curves curves;
const std::filesystem::path data{"./data"};
for (auto const& dir_entry : std::filesystem::directory_iterator{data}){
std::ifstream in(dir_entry.path());

const std::filesystem::path data{"./data_2d"};
std::vector<std::string> filenames;
for (auto const& dir_entry : std::filesystem::directory_iterator{data}) {
filenames.push_back(dir_entry.path());
}
std::sort(filenames.begin(), filenames.end());

for (auto const& filename : filenames) {
std::cout << filename << std::endl;
std::ifstream in(filename);
curves.push_back(Curve());
CGAL::IO::read_linestring_WKT(in, curves.back());
}

// last curve is the query curve
Curve query = curves.back();

curves.pop_back();

CGAL::Frechet_distance::Neighbor_search<Curve, Traits> ds;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int main()
{

Curves curves;
const std::filesystem::path data{"./data"};
const std::filesystem::path data{"./data_3d"};
for (auto const& dir_entry : std::filesystem::directory_iterator{data}){
std::ifstream in(dir_entry.path());
curves.push_back(Curve());
Expand Down
2 changes: 2 additions & 0 deletions Frechet_distance/examples/Frechet_distance/data_2d/0.wkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
LINESTRING(6.112736426119762 2.5849084464443317,6.501049052879937 2.390391196918605,6.883833621191689 4.334182329531962,7.639112858623561 4.634677324131037,9.691271973819742 5.0957391854984895,11.904041889400174 7.457813982738608,11.30475904837998 9.221831012645808,12.296720789522718 8.465625336792279,11.3207832271736 8.014256670719847,13.04799700450235 10.541649605085587,12.300080072924043 12.737768821184451,10.984339257084162 10.903617159410555,12.716617366098665 14.235674883475793,12.821662505363737 16.421178652993788,11.839123527180595 15.515532938905183,13.628492284122434 16.55693104057619,15.493538853828085 16.683964523464393,16.275208717635653 16.255696297793957,18.858812339402956 16.80817069567398,22.235205116182488 16.28750871944834,22.90601643170122 17.805603796398028,24.417199016263403 20.0550904367781,25.757592249946025 17.41739857761013,27.10905957048304 19.673488489872295,25.952437469177035 17.01088844747414,26.387832960426003 18.54349559831854,26.929749055464796 19.095489805656012,25.82342848997007 17.903050856831406,26.290184536448784 18.149866370177104,25.663217476841055 19.172746737482793,26.537461204748098 18.85081255764949,27.469105872909328 18.12041090796789,28.009534738591192 19.43657505082113,29.847351736473414 20.41694899615554,30.486554274610448 20.928621687009652,30.491547890940137 22.26049494051073,31.24434340842259 22.232356743890033,28.332460591596295 24.31958744800812,28.80370324387856 23.831761593566185,30.43244788708311 23.663343237495393,30.148612366570386 21.5853595340168,34.56761385235253 20.232991274455237,37.019173653846906 21.948310496402765,36.771895970419145 21.672116576722477,38.305044193604076 24.072813320631848,38.215691747139616 25.245543953994428,40.27577696386372 26.50149591740307,38.80301159039378 28.533901620798943,38.02674030668347 29.324640233227306,38.31472929979067 28.851969187295943,39.4646206910235 30.71321530361502,42.01701190374664 32.05245582410859,40.07661986990507 31.05867972580265,40.03763507126249 30.934055179538525,39.45615647553251 33.717567454159386,39.453528101704784 34.438132713745084,40.508308894471085 32.739901143973796,40.39303085233719 32.358212288322584,39.680772959580054 34.081031617009785,39.55186085623523 37.97747084181259,41.11637591166774 38.029459096525954,41.53011718460247 36.04710225923277,40.18936807967981 37.692381847670156,41.620207917541734 38.948600287828796,43.92792185551297 38.78421284149372,43.34296080598699 38.589744553990066,42.99654963518208 39.873736110190286,43.798680003206165 40.78096274589837,45.43584633879475 40.399265130378254,43.45743934535254 41.9964067266641,42.23323067470436 42.58727403657232,41.95099722767706 44.10468566381274,40.651668619936586 46.82649921912456,40.5737268634038 47.796125454708005,38.60974737967981 49.68465905157728,38.689409346492035 48.997096076152786,38.10194905704237 48.82055753105994,36.688280838559585 48.31206855564419,37.89240786312759 48.56654262167785,40.102184310977634 49.15265993054243,39.83955484720906 51.45158141073415,41.97560726056646 55.50236471976186,38.873072181634136 55.626498937665374,42.833451477983935 54.20964124504376,44.28884597868468 54.052215669865774,44.03801607431774 55.00252616281501,42.10068924768651 53.85377994750452,40.87397833085806 53.909203285527866)

2 changes: 2 additions & 0 deletions Frechet_distance/examples/Frechet_distance/data_2d/1.wkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
LINESTRING(6.112736426119762 2.5849084464443317,9.55004184253794 4.346711112361094,11.021672898753518 5.175861725684602,8.81645594695718 5.805660090303784,8.952641136956633 7.280822834631713,8.553472536489505 7.02096504930979,10.851479338265268 7.183492137662747,12.825544133108801 6.546563178189812,13.305927006829108 5.68908048211941,12.506989504265004 6.439512509733016,12.826977810223545 7.725191567225053,13.82979001582113 8.645867901247579,14.700539069810704 8.768825228923944,15.693594208914497 10.150378065831454,17.6792258584685 11.564404878404725,18.04040215861766 12.837595224279333,19.430446414570014 13.895599124340885,18.72728829781045 15.2808091709534,18.434029123330962 17.65856240003161,17.83707339164928 18.00314471214978,17.812017540950144 19.846176298247975,20.017676666684952 20.79742722248111,21.670677566618007 21.41745142238163,23.35119189070371 24.251310008561497,24.49990721940751 25.79751109217751,25.61931179191424 24.442414560189807,24.50066204813484 27.938091996739278,24.813857871531518 31.401052958842424,26.610627840574075 31.756870288757103,27.49699471589814 32.90472571825882,26.73716466147739 34.14274199067649,29.006030846950978 36.11350861544451,30.404003810442838 36.89758911096305,31.437317520476252 37.55774370432037,30.66401264285286 36.09229818724383,32.51577254733746 38.47654723229892,33.69893147202734 38.985439576385666,34.20453801830198 38.33416917174882,34.34907986763562 38.132531195672605,34.056398385133505 38.36149667599551,35.03302625657435 39.0113740308418,35.161996686768575 40.1704043625404,34.63654392062766 40.00441944105327,36.0321821630311 42.728356861069415,35.05526077742724 42.34580673425689,35.33389036074344 42.00185144746638,35.67818268947223 42.63883881365268,37.2403571449757 43.67454141579547,37.26015016832056 44.77703463486736,41.33195032667662 47.03006290695366,40.821275447159366 48.833229539384035,40.132158229914594 49.69010610526692,39.15809499961496 52.33435060225923,39.942185797917865 54.626193900783775,40.87397833085806 53.909203285527866)

2 changes: 2 additions & 0 deletions Frechet_distance/examples/Frechet_distance/data_2d/2.wkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
LINESTRING(0.01920316881197575 2.7173302153220606,1.952283026968674 3.9940842018488003,4.303908177656949 5.520392238978189,6.567305156718921 5.830410573746775,8.183158119580595 7.217471914920616,11.404103956920435 4.7760701064579685,12.247715248915135 5.824709349643745,12.510176656645118 6.843199189239857,16.40710916027942 6.312724622378933,17.313254043895363 7.403486522709083,21.35959718229617 9.576700646653457,20.99140426615736 12.705063719737312,21.816527918671436 14.232190941933966,20.601532323558786 17.023858803349363,20.926655964446493 16.758853859774423,21.27091153542478 16.8893880748203,22.519986855586176 17.538037467095375,23.421903899177703 17.60764672044448,26.100221992817097 18.13118305295047,27.14341332118527 20.281227172023414,27.845867479502218 21.339728132773406,28.13481941821367 22.084692762602156,30.33706587999551 23.14306073671815,31.721426937344507 22.578668625978107,33.60050511681923 23.980627851267172,34.271676804247434 26.235487290300757,35.80774663763664 25.029670586838726,36.74968163746145 25.435374004597325,37.8015836374533 26.85256861790902,39.81014522065776 25.11806786062004,39.17891665077497 26.166918939333755,38.93793151902782 26.669969724656145,39.33777637915905 27.104389610600958,39.95792604849322 28.474790239720875,41.277707748202765 29.609357122661994,40.69850198113569 28.61092318392047,40.15993662629622 29.592681609653496,43.099231796166784 30.451189148782493,43.89423994739242 34.72666701932899,45.18673915415366 34.370698545515,45.84890824423053 33.84609509496513,46.07182189116178 33.78288238443588,45.66776277442876 35.8186415879669,45.14823919273282 34.401156895166494,45.616199722790526 36.130440468950084,47.10588431771261 35.84141786615285,49.80072865313393 36.92355454287793,51.20240223800068 35.96822132206141,50.45585965479887 35.41170179547352,51.74718541987573 34.35279396029649)

2 changes: 2 additions & 0 deletions Frechet_distance/examples/Frechet_distance/data_2d/3.wkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
LINESTRING(1.9145887719423273 -8.911758100941418,1.985590594301069 -8.9911849956399,3.1559849028801183 -7.5506025470747815,3.4836266208533733 -6.5720557049784665,4.167618765677456 -5.529060559762609,5.193051826685755 -5.31195816235046,6.616657156257481 -2.414102032114985,6.96485486910747 -0.1784476968572486,7.856250484144893 0.6521738419873252,8.671308105066949 0.9378241932567412,8.542196956075914 1.9246440264253317,9.211636890775223 3.4778780084546383,8.479107839516608 6.546751154988448,8.828375666724188 6.790847737653216,8.606360819633595 9.304528546722839,11.405050796408974 11.024341291812766,13.557217711917673 12.358284526485003,12.627075746709458 12.234881387850947,11.428256299180376 11.115597241473978,12.288602484234545 12.47682056569042,12.451777288631916 12.30453490094954,12.854172456747131 14.277252743280803,13.298154172727871 13.001783370162016,12.419310244839117 11.738792783297134,14.567683974977745 11.969670516857034,15.573074640594278 11.439125391256262,16.974603464557696 13.057565122470795,18.78839471440719 16.05099399148112,22.424554923395252 15.644588814300048,23.131661197870464 19.149435790962425,23.079476042889844 18.78135234828112,24.562984087725372 19.37866073066471,22.104975761146537 21.057470568653486,25.65460022869865 23.934451375869614,23.952426368711844 26.431385959347942,23.723388146860533 26.0273350326587,25.342503499660904 27.27405979791461,25.30459400242636 28.759917082703996,25.360668015315856 28.453236645537242,26.767747335628524 29.891220097621403,29.605730083127753 32.02138336496878,29.383219304410485 34.995511276625955,29.322796836137407 37.93948461915676,31.111742535096795 38.05514539680048,29.15165939799821 38.38671316626802,30.36271488658267 41.55370948945938,31.007800930588463 43.10405073091346,31.653845734456844 42.60799301185085,33.70445678000675 43.00537866961486,36.615782716498856 44.19291052760875,35.95605084127132 44.12922022523878,37.08027133102593 43.632023225221474,34.912298551914624 43.27215098872872,37.02276484825042 46.67942984599948,36.952088032905905 47.17612254802147,36.481632589751946 47.818788800700354,36.737653271606526 48.866581214342695,39.14650191433347 48.2865185281983,39.660193414639714 49.11229625590246,40.04820251170985 46.367465358662585,40.97022969919812 47.5417501557382,39.15328720572451 49.37404195885611,39.65484072999086 51.059382798972656,42.18037284538068 51.63478460737583,41.380822801817516 52.5816549787608,40.87397833085806 53.909203285527866)

2 changes: 2 additions & 0 deletions Frechet_distance/examples/Frechet_distance/data_2d/4.wkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
LINESTRING(0.01920316881197575 2.7173302153220606,-1.9725132885568686 4.396808298114495,0.460914306264967 6.257615627113183,1.5634378010765109 7.17184076954219,1.6719407452628006 7.757756191529365,1.374106897735216 7.8279174504669085,2.6371846628749935 9.406151171793926,2.286356264439272 9.586460939563569,2.266315678663256 11.94154467220665,4.297083565768492 13.499522893061481,5.403004061299473 12.41673755395625,6.99769192599981 13.97468200116899,8.39693956779986 13.534650906160646,9.282953169667099 14.936916598041263,8.601757660127623 13.926999021622544,10.216118425046922 14.707673997387298,11.127982086268055 13.914796316052543,12.198060878031887 13.84544965631178,12.08518364882348 13.970306281752682,10.69110722453816 15.7443825392419,14.218571649141198 16.21824116011263,13.910450659205376 16.09132104487624,14.843832293104862 17.658037833539108,15.651978834439761 18.743974188068353,17.458465397139094 20.05173025410321,18.32967373833948 21.216981030415702,21.512723603891217 20.668507181975436,23.271080874626477 20.413364284939544,22.931140889638638 23.05198354866531,23.8841863731413 25.758177872831766,25.52616153095304 25.728205567593463,26.127440580955554 26.916541783969922,25.871612264608103 29.289570428860422,28.725150986851165 29.407341099952802,30.63401087325989 29.680797126645004,31.839520101654667 28.309082297027082,33.17904947178293 29.414406737670987,34.32131549107053 27.876288314133912,33.82121242971697 30.346718168247357,33.713345254828795 27.614114036000554,33.35634761240047 26.42010068437059,34.825590210090375 27.228500369962312,35.626558548248106 27.07054007329538,34.58781059480957 28.56452714870953,35.00499568095852 26.89796567554231,34.36962604489664 25.779289403741746,36.20590346657988 26.468115971375887,38.33457483554684 27.73494964363518,38.9360173601088 28.337013109584447,40.6098887173223 26.551004488728342,43.60783520335697 29.27421273917809,45.699870120177245 30.867939269862664,47.12196827165821 29.488842968224454,46.26765944518667 30.68792864991955,47.45717400030481 32.86487461159349,50.02045392743377 32.54293385374996,49.64296325979909 32.47364757301509,48.67582514238965 35.23023815264972,48.35295375181058 35.90735738904394,49.544900929631346 34.583232826358184,48.962385727367426 32.2946342733971,49.08485154617404 33.89954770358362,49.84899241477491 35.15095500155454,50.146925910979846 33.99335372748221,52.22791137136446 35.26179088915292,51.74718541987573 34.35279396029649)

2 changes: 2 additions & 0 deletions Frechet_distance/examples/Frechet_distance/data_2d/5.wkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
LINESTRING(6.112736426119762 2.5849084464443317,5.78204410839637 3.9004712926793164,5.538122816832845 5.875910605084722,6.168758338790276 5.161436055620873,5.589123844315058 7.19493929787285,6.4601123279936585 8.202038111274769,8.203692488468885 10.904811907056768,8.629716679512498 11.670637935109912,9.248067696875983 11.440472928535268,10.600492138567263 14.418992021483795,12.981972483512092 13.82783110123843,12.786264154798861 17.6249978956967,13.206395840110243 20.723683514294457,13.505488290336583 22.186832371862973,14.969997920702356 23.51058739741749,15.818562632292029 25.35326473733941,17.284751706103467 25.603887918729964,19.476481447308416 26.31701842178673,21.428940130044293 26.710648041683097,23.76210340334577 29.4077249902112,23.779168778334352 32.741464374069174,25.823296433867426 34.29771315954704,26.775851416629823 34.62300719079836,27.123190346650258 34.57087796584977,27.676870720012207 37.12456846016908,30.584247921741667 38.112927225895014,31.978412751255433 39.53695446540909,32.24904944893567 41.3373331515645,31.940928768406867 41.27854313017137,33.49502076646082 43.62873212729947,35.23037693858399 47.53312969647888,36.7349325194801 49.40354907917367,38.97199640396194 50.097194523333954,39.110375764912895 53.28769899449196,42.04804827482476 50.71531721898658,45.80280311298796 52.24022327616226,43.95508124329042 51.52992308065822,42.79939474878151 54.294648857519704,43.19896862698752 52.78505657177217,41.556412961183355 52.3260002842739,41.308898542577495 53.81710573183599,40.87397833085806 53.909203285527866)

Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
6.112736426119762 2.5849084464443317
6.501049052879937 2.390391196918605
6.883833621191689 4.334182329531962
7.639112858623561 4.634677324131037
9.691271973819742 5.0957391854984895
11.904041889400174 7.457813982738608
11.30475904837998 9.221831012645808
12.296720789522718 8.465625336792279
11.3207832271736 8.014256670719847
13.04799700450235 10.541649605085587
12.300080072924043 12.737768821184451
10.984339257084162 10.903617159410555
12.716617366098665 14.235674883475793
12.821662505363737 16.421178652993788
11.839123527180595 15.515532938905183
13.628492284122434 16.55693104057619
15.493538853828085 16.683964523464393
16.275208717635653 16.255696297793957
18.858812339402956 16.80817069567398
22.235205116182488 16.28750871944834
22.90601643170122 17.805603796398028
24.417199016263403 20.0550904367781
25.757592249946025 17.41739857761013
27.10905957048304 19.673488489872295
25.952437469177035 17.01088844747414
26.387832960426003 18.54349559831854
26.929749055464796 19.095489805656012
25.82342848997007 17.903050856831406
26.290184536448784 18.149866370177104
25.663217476841055 19.172746737482793
26.537461204748098 18.85081255764949
27.469105872909328 18.12041090796789
28.009534738591192 19.43657505082113
29.847351736473414 20.41694899615554
30.486554274610448 20.928621687009652
30.491547890940137 22.26049494051073
31.24434340842259 22.232356743890033
28.332460591596295 24.31958744800812
28.80370324387856 23.831761593566185
30.43244788708311 23.663343237495393
30.148612366570386 21.5853595340168
34.56761385235253 20.232991274455237
37.019173653846906 21.948310496402765
36.771895970419145 21.672116576722477
38.305044193604076 24.072813320631848
38.215691747139616 25.245543953994428
40.27577696386372 26.50149591740307
38.80301159039378 28.533901620798943
38.02674030668347 29.324640233227306
38.31472929979067 28.851969187295943
39.4646206910235 30.71321530361502
42.01701190374664 32.05245582410859
40.07661986990507 31.05867972580265
40.03763507126249 30.934055179538525
39.45615647553251 33.717567454159386
39.453528101704784 34.438132713745084
40.508308894471085 32.739901143973796
40.39303085233719 32.358212288322584
39.680772959580054 34.081031617009785
39.55186085623523 37.97747084181259
41.11637591166774 38.029459096525954
41.53011718460247 36.04710225923277
40.18936807967981 37.692381847670156
41.620207917541734 38.948600287828796
43.92792185551297 38.78421284149372
43.34296080598699 38.589744553990066
42.99654963518208 39.873736110190286
43.798680003206165 40.78096274589837
45.43584633879475 40.399265130378254
43.45743934535254 41.9964067266641
42.23323067470436 42.58727403657232
41.95099722767706 44.10468566381274
40.651668619936586 46.82649921912456
40.5737268634038 47.796125454708005
38.60974737967981 49.68465905157728
38.689409346492035 48.997096076152786
38.10194905704237 48.82055753105994
36.688280838559585 48.31206855564419
37.89240786312759 48.56654262167785
40.102184310977634 49.15265993054243
39.83955484720906 51.45158141073415
41.97560726056646 55.50236471976186
38.873072181634136 55.626498937665374
42.833451477983935 54.20964124504376
44.28884597868468 54.052215669865774
44.03801607431774 55.00252616281501
42.10068924768651 53.85377994750452
40.87397833085806 53.909203285527866
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
6.112736426119762 2.5849084464443317
9.55004184253794 4.346711112361094
11.021672898753518 5.175861725684602
8.81645594695718 5.805660090303784
8.952641136956633 7.280822834631713
8.553472536489505 7.02096504930979
10.851479338265268 7.183492137662747
12.825544133108801 6.546563178189812
13.305927006829108 5.68908048211941
12.506989504265004 6.439512509733016
12.826977810223545 7.725191567225053
13.82979001582113 8.645867901247579
14.700539069810704 8.768825228923944
15.693594208914497 10.150378065831454
17.6792258584685 11.564404878404725
18.04040215861766 12.837595224279333
19.430446414570014 13.895599124340885
18.72728829781045 15.2808091709534
18.434029123330962 17.65856240003161
17.83707339164928 18.00314471214978
17.812017540950144 19.846176298247975
20.017676666684952 20.79742722248111
21.670677566618007 21.41745142238163
23.35119189070371 24.251310008561497
24.49990721940751 25.79751109217751
25.61931179191424 24.442414560189807
24.50066204813484 27.938091996739278
24.813857871531518 31.401052958842424
26.610627840574075 31.756870288757103
27.49699471589814 32.90472571825882
26.73716466147739 34.14274199067649
29.006030846950978 36.11350861544451
30.404003810442838 36.89758911096305
31.437317520476252 37.55774370432037
30.66401264285286 36.09229818724383
32.51577254733746 38.47654723229892
33.69893147202734 38.985439576385666
34.20453801830198 38.33416917174882
34.34907986763562 38.132531195672605
34.056398385133505 38.36149667599551
35.03302625657435 39.0113740308418
35.161996686768575 40.1704043625404
34.63654392062766 40.00441944105327
36.0321821630311 42.728356861069415
35.05526077742724 42.34580673425689
35.33389036074344 42.00185144746638
35.67818268947223 42.63883881365268
37.2403571449757 43.67454141579547
37.26015016832056 44.77703463486736
41.33195032667662 47.03006290695366
40.821275447159366 48.833229539384035
40.132158229914594 49.69010610526692
39.15809499961496 52.33435060225923
39.942185797917865 54.626193900783775
40.87397833085806 53.909203285527866
Loading

0 comments on commit cda09d1

Please sign in to comment.