Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can distinguish two cases :</p> <p>Either the line is entering a figure through another line. In that case, the easiest way is to represent your lines (including the border of your obstacles) by their equations (they would look like <code>a*x + b*y +c = 0</code>). Then deciding whether or not two lines intersect is quite a simple matter :</p> <ul> <li><p>Two lines ax+by+c=0 and dx+ey+f=0 intersect if and only if they are not parallel, i.e iff a*e-b*d != 0</p></li> <li><p>Then you have to check whether or not the intersection point of these two lines is inside the segments which you actually consider. The intersection point have coordinates :</p> <ul> <li>y = ( cd - af ) / (ae - db)</li> <li>x = ( bf - ec ) / (ae - db)</li> </ul></li> <li>The only remaining task is to check whether or not these x and y belong to the segment (if they are within the intervals defining the segment) And you repeat this operation for all segments defining you obstacles.</li> </ul> <p>If you have circles, it becomes trickier (this is why you usually only consider polygons as obstacles), but basically it is the same idea : - You have a line ax+by+c=0 and a circle (x-a)^2 + (y-b)^2 = r^2 (a circle of center (a,b) and radius r). Then you have to determine whether they intersect, the point of intersection and if it belongs to the segment which you consider. I'll leave the calculs to you.</p> <p>If you are interested in different methods for finding a path between two points, with obstacles, there are other algorithms which you can use, although these will not provide you with the shortest path, but only with a path :</p> <ul> <li><a href="http://en.wikipedia.org/wiki/Sweep_line_algorithm" rel="nofollow">http://en.wikipedia.org/wiki/Sweep_line_algorithm</a></li> <li><a href="http://en.wikipedia.org/wiki/Voronoi_diagram" rel="nofollow">http://en.wikipedia.org/wiki/Voronoi_diagram</a></li> </ul> <p>The interest of those algorithm compared to the visibility diagram you're building is that these two works in whatever dimension you are : if you want to upgrade your algorithm to dimensions, your algorithm will have a higher complexity (it will take more time to find a path) then these two and will not yield the shortest path.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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