Note that there are some explanatory texts on larger screens.

plurals
  1. POMathematica: Non-intersecting line segments
    primarykey
    data
    text
    <p>How can we tell <em>Mathematica</em> to gives us a set of non-intersecting lines? In this case two lines intersect if they have a point (not an endpoint) in common. Consider this simple case:</p> <pre><code>l1 = {{-1, 0}, {1, 0}}; l2 = {{0, -1}, {0, 1}}; lines = {l1, l2}; </code></pre> <p>The idea is to create a function which, given a set a lines, returns a set of non-intersecting lines. If such function exists say <code>split</code> then the output of</p> <pre><code>split[lines] </code></pre> <p>would be</p> <pre><code>{ {{-1, 0}, {0,0}}, {{ 0, 0}, {1,0}}, {{ 0,-1}, {0,0}}, {{ 0, 0}, {0,1}} } </code></pre> <p>The function detected that <code>{0,0}</code> is the intersection between the two lines in the set and in order to have non-intersecting lines it broke the line segments at the intersections thus generating 2 more lines. This process gets more complicated if the original input contains more lines. Does anyone know how to do this efficiently in <em>Mathematica</em> without using loops? It might help to know an algorithm to find if <a href="https://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect/563275#563275">two lines are intersecting</a>.</p> <p><strong>Note</strong></p> <p>This question is the second part of my attempt to find out <a href="https://stackoverflow.com/questions/6353337/mathematica-3d-wire-frames">how to make wire frames in <em>Mathematica</em> with hidden line removal</a>. Please feel free to add more appropriate tags.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload