Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think the problem is simple and easily solvable actually :)</p> <p>The basic idea is: </p> <ul> <li><p>First check if the distance between your current point (P) and the end point of the line segment you are on is >= the distance between P and the next point (Q). </p></li> <li><p>If it is, great, we use some simple trigonometry to figure it out.</p></li> <li><p>Else, we move to the adjacent line segment (in your ordering) and <strong>deduct the distance between P and the endpoint of the line segment you are on</strong> and continue the process.</p></li> </ul> <h2>Pseudocode:</h2> <h3>Defined previously</h3> <pre><code>struct LineSegment { Point start,end; int ID; double len; // len = EuclideanDistance(start,end); LineSegment *next_segment; double theta; // theta = atan2(slope_of_line_segment); } Function [LineSegment nextseg] = FindNextLineSegment(LineSegment lineseg) Input: LineSegment object of the current line segment Output: LineSegment object of the adjacent line segment in your ordering. nextseg.ID = -1 if there are no more segments </code></pre> <h3>Function: Find the next point along your path</h3> <pre><code>Function [Point Q, LineSegment Z] = FindNextPt(Point P, LineSegment lineseg, int dist): Input: The current point P, the distance between this point and the next, and the LineSegment of the line segment which contains P. Output: The next point Q, and the line segment it is on Procedure: distToEndpt = EuclideanDistance(P,lineseg-&gt;end); if( distToEndpt &gt;= d ) { Point Q(lineseg-&gt;start.x + dist*cos(lineseg.theta), lineseg-&gt;start.y + dist*sin(lineseg.theta)); Z = lineseg; } else { nextseg = lineseg-&gt;next_segment; if( nextseg.ID !=-1 ) { [Q, Z] = FindNextPt(nextseg-&gt;start,nextseg-&gt;ID,dist-distToEndpt); } else { return [P,lineseg]; } } return [Q,Z] </code></pre> <h3>Entry point</h3> <pre><code>Function main() Output: vector of points Procedure: vector&lt;LineSegment&gt; line_segments; // Define it somehow giving it all the properties // .... vector&lt;Point&gt; equidistant_points; const int d = DIST; [Q Z] = FindNextPoint(line_segments[0].start,line_segments[0],DIST); while( Z.ID != -1 ) { equidistant_points.push_back(Q); [Q Z] = FindNextPt(Q,Z,d); } </code></pre>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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