BrowserUk:
I used your code and examined the results of all the output arrays. From what I can see, it appears that the extra vertices are due to extra lines. Not extra in the sense that they're not valid, just in that they're unnecessary/unwanted. In the case of a square of four points (Pll, Pul, Plr, and Prr where u=upper, l=lower/left, r=right), you expect a line between Pll and Pul, you also expect a line between Pll and Plr. But a line between Pll and Prr is also valid. Since they intersect at a single point you don't need the last one. I suspect that the code is either experiencing just enough rounding error to insert the extra points, or that the code simply has all those three lines as boundaries, and it simply computes duplicates as it walks through the list of lines.
... roboticus
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|