python - Finding out presence of loops(interconnections) in a line -


i have set of 2d coordinates. can positive, negative , in fractions well. points like,

50.2345,-23.452 1.345,-14.206 

so on , forth. question if plot these coordinates on graph, how determine whether line intersect form loop or remain zig zag line(without intersecting itself).

this can calculated nested loop.

assume have 5 points: [0,0],[1,1],[2,1],[2,0],[0,1]

this gives 4 edges, last of overlap first. edge([0,0],[1,1]) intersect edge([2,0],[0,1]).

iterate on each edge (line segment) , test intersection other line segments.

pseudocode:

 for(edge1 in edges)  {         for(edge2 in edges)      {         if ( testintersect(edge1,edge2) ) return true;      }  }  return false; 

Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -