Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This will use quite a bit of vector math but is quite simple really.</p> <p>First you will need to find the total distance of the path. Depending on how the points of the path are stored is how you will do it. Here is a basic example on a 2 Dimensional Path in Pseudo-code.</p> <pre><code>// This would generally be done with vectors, however I'm not sure // if you would like to make your own class for them as I do so I will use arrays. // The collection of points int Points[4][2] = { {0,0}, {1,2}, {5,4}, {6,5} }; int Points2 = Points; // goes to 3 because there are 4 points for(int i=0; i&lt;3; i++) { x = Points[i+1][0] - Points[i][0]; y = Points[i+1][1] - Points[i][1]; d += sqrt(( x * x ) + ( y * y )); } // divide distance by number of points to get uniform distance dist = d/4; // now that you have the new distance you must find the points // on your path that are that far from your current point // same deal here... goes to 3 because there are 4 points for(int i=0; i&lt;3; i++) { // slope m = ( Points[i+1][1] - Points[i][1] ) / ( Points[i+1][0] - Points[i][0] ); // y intercept b = -(M * Points[i][0]) + Points[i][1]; // processor heavy which makes this problem difficult // if some one knows a better way please say something // check every degree grabbing the points till one matches // if it doesn't then check next segment. for(float j=0; j&lt;360; j += 0.1) { x = dist * sin(j); y = sqrt((dist * dist) - ( x * x )); if (y - (M * x + C)) { // then the point is on the line so set it Points2[i+1][0] = x; Points2[i+1][1] = y; } } } </code></pre> <p>The last step is what makes it unreasonable but this should work for you. There may be a small math error somewhere I double checked this several times but there could be something I missed. So if anyone notices something please inform me and I will edit it.</p> <p>Hope this helps, Gale</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