Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have given up with the winding number code, it really has got me! If anyone does find the solution I would still be amazingly grateful. I am now trying with point in poly detection using the crossing number algorithm. I kept the pesudo code in the comments, again from softsurfer....</p> <pre><code>int cn_PnPoly( Point P, Building &amp; b, int n ) { int cn = 0; // the crossing number counter int rem = 0; vector&lt;float&gt;x; vector&lt;float&gt;y; x.swap(b.getX()); y.swap(b.getY()); //// loop through all edges of the polygon //for (int i=0; i&lt;n; i++) { // edge from V[i] to V[i+1] // if (((V[i].y &lt;= P.y) &amp;&amp; (V[i+1].y &gt; P.y)) // an upward crossing // || ((V[i].y &gt; P.y) &amp;&amp; (V[i+1].y &lt;= P.y))) { // a downward crossing // // compute the actual edge-ray intersect x-coordinate // float vt = (float)(P.y - V[i].y) / (V[i+1].y - V[i].y); // if (P.x &lt; V[i].x + vt * (V[i+1].x - V[i].x)) // P.x &lt; intersect // ++cn; // a valid crossing of y=P.y right of P.x // } //} //return (cn&amp;1); // 0 if even (out), and 1 if odd (in) // loop through all edges of the polygon for (int i=0; i&lt;n-1; i++) { // edge from V[i] to V[i+1] if (((y.at(i) &lt;= P.y) &amp;&amp; (y.at(i+1) &gt; P.y)) // an upward crossing || ((y.at(i) &gt; P.y) &amp;&amp; (y.at(i+1) &lt;= P.y))) { // a downward crossing // compute the actual edge-ray intersect x-coordinate float vt = (float)(P.y - y.at(i)) / (y.at(i+1) - y.at(i)); if (P.x &lt; x.at(i) + vt * (x.at(i+1) - x.at(i))) // P.x &lt; intersect ++cn; // a valid crossing of y=P.y right of P.x } } rem = cn % 1; return (rem); // 0 if even (out), and 1 if odd (in) } </code></pre> <p>Again this always returns zero, I am unsure why!?! Have I converted the algorithm incorrectly? Does it matter which direction the points are tested (i.e. clockwise, anti-clockwise)?</p>
    singulars
    1. This table or related slice is empty.
    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