<?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[Formel korrekt umgesetzt?]]></title><description><![CDATA[<p>Hallo, ich bin nicht in C++ geübt, und muss dennoch ein kleines Programm schreiben.. Ich habe eine Formel zur berechnung des Schnittwinkels zweier Geraden und wollte hier mal fragen, ob ich diese korrekt in ordentlicher C++-Syntax umgesetzt habe, da ich immer nur -1.#IND000000000 als ergebnis bekomme. Da hört mein C++ Wissen leider auf..</p>
<p>Gegeben ist</p>
<pre><code>- Start(xS, yS)
- Ziel(xZ, yZ)
- Punkt(xP, yP)

g1 = Start,Ziel
g2 = Start,Punkt

Die Geraden schneiden sich also im Punkt &quot;Start&quot;!
</code></pre>
<p>Gesucht ist</p>
<pre><code>- Schnittwinkel Alpha zwischen (Start,Ziel) und (Start,Punkt)
- Länge zwischen &quot;Start&quot; und Schnittpunkt der Orthogonalen von &quot;Start&quot;/&quot;Ziel&quot;, die durch &quot;Punkt&quot; geht
- Länge der Orthogonalen zwischen &quot;Punkt&quot; und Schnittpunkt der Gerade &quot;Start&quot;/&quot;Ziel&quot;
</code></pre>
<p>Diese Formel verwende ich</p>
<pre><code>(Punkt-Start) * (Ziel-Start)
alpha = acos ----------------------------------
             || (Punkt-Start) * (Ziel-Start) ||

                  sqrt( ((xP-xS) * (xZ-xS)) + ((yP-yS) * (yZ-yS))
      = acos -------------------------------------------------------------
             sqrt( (xP-xS)^2 + (yP-yS)^2 ) * sqrt( (xZ-xS)^2 + (yZ-yS)^2 )
</code></pre>
<p>Und so siehts aus</p>
<pre><code class="language-cpp">double alpha = acos( sqrt(((xP-xS)*(xZ-xS)) + ((yP-yS)*(yZ-yS))) / sqrt(((xP-xS)*(xP-xS)) + ((yP-yS)*(yP-yS))) * sqrt(((xZ-xS)*(xZ-xS)) + ((yZ-yS)*(yZ-yS))) );
</code></pre>
<p>So, in Alpha steht -1.#IND00000000. Vielleicht kann mir jemand sagen woran es liegt?!</p>
<p>Danke und schöne Grüße</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/206023/formel-korrekt-umgesetzt</link><generator>RSS for Node</generator><lastBuildDate>Sat, 10 Oct 2026 03:22:43 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/206023.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 20 Feb 2008 14:10:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Formel korrekt umgesetzt? on Wed, 20 Feb 2008 14:10:00 GMT]]></title><description><![CDATA[<p>Hallo, ich bin nicht in C++ geübt, und muss dennoch ein kleines Programm schreiben.. Ich habe eine Formel zur berechnung des Schnittwinkels zweier Geraden und wollte hier mal fragen, ob ich diese korrekt in ordentlicher C++-Syntax umgesetzt habe, da ich immer nur -1.#IND000000000 als ergebnis bekomme. Da hört mein C++ Wissen leider auf..</p>
<p>Gegeben ist</p>
<pre><code>- Start(xS, yS)
- Ziel(xZ, yZ)
- Punkt(xP, yP)

g1 = Start,Ziel
g2 = Start,Punkt

Die Geraden schneiden sich also im Punkt &quot;Start&quot;!
</code></pre>
<p>Gesucht ist</p>
<pre><code>- Schnittwinkel Alpha zwischen (Start,Ziel) und (Start,Punkt)
- Länge zwischen &quot;Start&quot; und Schnittpunkt der Orthogonalen von &quot;Start&quot;/&quot;Ziel&quot;, die durch &quot;Punkt&quot; geht
- Länge der Orthogonalen zwischen &quot;Punkt&quot; und Schnittpunkt der Gerade &quot;Start&quot;/&quot;Ziel&quot;
</code></pre>
<p>Diese Formel verwende ich</p>
<pre><code>(Punkt-Start) * (Ziel-Start)
alpha = acos ----------------------------------
             || (Punkt-Start) * (Ziel-Start) ||

                  sqrt( ((xP-xS) * (xZ-xS)) + ((yP-yS) * (yZ-yS))
      = acos -------------------------------------------------------------
             sqrt( (xP-xS)^2 + (yP-yS)^2 ) * sqrt( (xZ-xS)^2 + (yZ-yS)^2 )
</code></pre>
<p>Und so siehts aus</p>
<pre><code class="language-cpp">double alpha = acos( sqrt(((xP-xS)*(xZ-xS)) + ((yP-yS)*(yZ-yS))) / sqrt(((xP-xS)*(xP-xS)) + ((yP-yS)*(yP-yS))) * sqrt(((xZ-xS)*(xZ-xS)) + ((yZ-yS)*(yZ-yS))) );
</code></pre>
<p>So, in Alpha steht -1.#IND00000000. Vielleicht kann mir jemand sagen woran es liegt?!</p>
<p>Danke und schöne Grüße</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1459477</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1459477</guid><dc:creator><![CDATA[ungewiss]]></dc:creator><pubDate>Wed, 20 Feb 2008 14:10:00 GMT</pubDate></item><item><title><![CDATA[Reply to Formel korrekt umgesetzt? on Wed, 20 Feb 2008 14:13:39 GMT]]></title><description><![CDATA[<p>Ach ja, ich habe WinXP und VisualStudio 2003..</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1459480</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1459480</guid><dc:creator><![CDATA[ungewiss]]></dc:creator><pubDate>Wed, 20 Feb 2008 14:13:39 GMT</pubDate></item><item><title><![CDATA[Reply to Formel korrekt umgesetzt? on Wed, 20 Feb 2008 14:42:38 GMT]]></title><description><![CDATA[<p>Du weißt das acos etc mit Radiant arbeiten?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1459505</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1459505</guid><dc:creator><![CDATA[Fellhuhn]]></dc:creator><pubDate>Wed, 20 Feb 2008 14:42:38 GMT</pubDate></item><item><title><![CDATA[Reply to Formel korrekt umgesetzt? on Wed, 20 Feb 2008 14:49:33 GMT]]></title><description><![CDATA[<p>Ich würde mal Zwischenergebnisse erzeugen und prüfen ob</p>
<p>- nicht durch 0 geteilt wird<br />
- Wurzel nicht aus negativer Zahl berechnet wird<br />
- bei acos(x) x zwischen -1 und 1 liegt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1459512</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1459512</guid><dc:creator><![CDATA[MiP]]></dc:creator><pubDate>Wed, 20 Feb 2008 14:49:33 GMT</pubDate></item><item><title><![CDATA[Reply to Formel korrekt umgesetzt? on Wed, 20 Feb 2008 15:02:58 GMT]]></title><description><![CDATA[<p>Fellhuhn schrieb:</p>
<blockquote>
<p>Du weißt das acos etc mit Radiant arbeiten?</p>
</blockquote>
<p>acos arbeitet nicht mit Radiant, es gibt nur einen Radiantwert zurück. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1459526</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1459526</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Wed, 20 Feb 2008 15:02:58 GMT</pubDate></item><item><title><![CDATA[Reply to Formel korrekt umgesetzt? on Wed, 20 Feb 2008 15:49:50 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/17700">@Fellhuhn</a>: radiant habe ich erwartet</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/18651">@MiP</a>: aufsplitten in zwischenergebnisse hat mich zur lösung gebracht! beim nächsten mal weiß ich bescheid.</p>
<ul>
<li></li>
</ul>
<p>der fehler lag übrigens in meiner formel, nicht an der syntax oder so. beim skalarprodukt muss ja gar keine wurzel gezogen werden! hatte das irgendwie falsch im kopf..</p>
<p>ich danke trotzdem! schöne grüße dann</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1459573</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1459573</guid><dc:creator><![CDATA[ungewiss]]></dc:creator><pubDate>Wed, 20 Feb 2008 15:49:50 GMT</pubDate></item></channel></rss>