<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[linie in Abschnitte teilen]]></title><description><![CDATA[<p>Hallo,<br />
ich versuche die Linien mit unterschiedlichen Länge und &quot;Richtungen&quot; (d.h sie sind nicht vertikal oder horisontal) zu teilen. Die x und y Koordinaten sind nicht immer absteigend oder aufsteigend. Mein Codefragment:</p>
<pre><code>for (int k = 0; k &lt; (int)p.size(); k++)
        {
            int end = k;
            for(int l = k; l &lt; (int)p.size(); l++)
            {
                if((fabs(pP[l].x - pP[k].x) &lt;= 60) &amp;&amp; fabs(pP[l].y - pP[k].y) &lt;= 60))
           end = l;
                    break;
                }
            }
            if(end &gt;= (int)points.size()-1) break;

          cout &lt;&lt; &quot;\t&quot; &lt;&lt; k &lt;&lt; &quot;\t&quot; &lt;&lt; end &lt;&lt; '\n';
// hier erwarte ich dass k = 0 und end = index des 60 px weiter entfernten Punktes(entlang x oder y Achse). kommt aber immer gleiche Werte für k und end raus.  
          }
</code></pre>
<p>was mache ich falsch?<br />
Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/260821/linie-in-abschnitte-teilen</link><generator>RSS for Node</generator><lastBuildDate>Mon, 07 Sep 2026 22:43:22 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/260821.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 09 Feb 2010 15:59:20 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to linie in Abschnitte teilen on Tue, 09 Feb 2010 16:04:53 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich versuche die Linien mit unterschiedlichen Länge und &quot;Richtungen&quot; (d.h sie sind nicht vertikal oder horisontal) zu teilen. Die x und y Koordinaten sind nicht immer absteigend oder aufsteigend. Mein Codefragment:</p>
<pre><code>for (int k = 0; k &lt; (int)p.size(); k++)
        {
            int end = k;
            for(int l = k; l &lt; (int)p.size(); l++)
            {
                if((fabs(pP[l].x - pP[k].x) &lt;= 60) &amp;&amp; fabs(pP[l].y - pP[k].y) &lt;= 60))
           end = l;
                    break;
                }
            }
            if(end &gt;= (int)points.size()-1) break;

          cout &lt;&lt; &quot;\t&quot; &lt;&lt; k &lt;&lt; &quot;\t&quot; &lt;&lt; end &lt;&lt; '\n';
// hier erwarte ich dass k = 0 und end = index des 60 px weiter entfernten Punktes(entlang x oder y Achse). kommt aber immer gleiche Werte für k und end raus.  
          }
</code></pre>
<p>was mache ich falsch?<br />
Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1853216</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1853216</guid><dc:creator><![CDATA[ns]]></dc:creator><pubDate>Tue, 09 Feb 2010 16:04:53 GMT</pubDate></item><item><title><![CDATA[Reply to linie in Abschnitte teilen on Tue, 09 Feb 2010 16:38:16 GMT]]></title><description><![CDATA[<p>Ich brauche mehr Details.</p>
<p>Wie ist die Linie gegeben? Was soll die Zahl 60 bedeuten? Was soll das break in Zeile 8? Dir ist schon klar, dass du dadurch die Schleife beim ersten Durchlauf verlässt? Hast du dort möglicherweise Klammern vergessen?</p>
<p>Überhaupt: Deine ganze Klammerung ist Müll und passt überhaupt nicht zur Code-Einrückung und zu den umgebenden Konstrollstrukturen. Ich vermute, dass dort der Fehler liegt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1853241</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1853241</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Tue, 09 Feb 2010 16:38:16 GMT</pubDate></item><item><title><![CDATA[Reply to linie in Abschnitte teilen on Tue, 09 Feb 2010 18:33:24 GMT]]></title><description><![CDATA[<p>Wie SeppJ schon meinte, wtf ist das:</p>
<pre><code class="language-cpp">for(int l = k; l &lt; (int)p.size(); l++)
            {
                if((fabs(pP[l].x - pP[k].x) &lt;= 60) &amp;&amp; fabs(pP[l].y - pP[k].y) &lt;= 60))
           end = l;
                    break;
                }
            }
</code></pre>
<p>Nicht nur das es total scheiße aussieht, es ist auch noch falsch:</p>
<pre><code class="language-cpp">for (int k = 0; k &lt; p.size(); k++)
{
    int end = k;
    for(int l = k; l &lt; p.size(); l++)
    {
        if((fabs(pP[l].x - pP[k].x) &lt;= 60) &amp;&amp; (fabs(pP[l].y - pP[k].y) &lt;= 60)) //hier fehlte eine Klammer
        { //hier ebenso
            end = l;
            break;
        }
    }
    if(end &gt;= points.size() - 1) break;

    cout &lt;&lt; &quot;\t&quot; &lt;&lt; k &lt;&lt; &quot;\t&quot; &lt;&lt; end &lt;&lt; '\n';
}
</code></pre>
<p>Wenn du Glück hast, funktioniert es jetzt vielleicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1853276</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1853276</guid><dc:creator><![CDATA[freaky]]></dc:creator><pubDate>Tue, 09 Feb 2010 18:33:24 GMT</pubDate></item></channel></rss>