<?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[[gelöst] Rotation aus Matrix lesen]]></title><description><![CDATA[<p>Hi,</p>
<p>ich versuche schon seit einiger Zeit die Rotation (X, Y, Z) aus einer<br />
3x3 - Matrix zu lesen. Klappt aber leider nicht ganz. Dabei geht es um<br />
die Physik - Engine &quot;Tokamak&quot;, bei der ich von allen physikalischen Objekten<br />
die Position und Rotation auslesen moechte. Das Problem ist, das die Rotation<br />
falsch ist und somit z.B. ein Würfel manchmal auf einer Ecke steht, obwohl er nirgends angelehnt ist.</p>
<p>Hier mal der Code:</p>
<pre><code class="language-cpp">neT3 transformData;
		GLfloat angle_x, angle_y, angle_z;

		// Matrix auslesen
		transformData = Object[i].physic.rigidBody-&gt;GetTransform();

		// Rotation berechnen
                if(transformData.rot[0][2] &lt; 1.0f) {
                    if(transformData.rot[0][2] &gt; -1.0f) {
                        angle_x = (float)atan2(-transformData.rot[1][2], transformData.rot[2][2]);
                        angle_y = (float)asin((double)transformData.rot[0][2]);
                        angle_z = (float)atan2(-transformData.rot[0][1], transformData.rot[0][0]);
                    }
                    else {
                        angle_x = (float)-atan2(transformData.rot[1][0], transformData.rot[1][1]);
                        angle_y = (float)(-NE_PI/ 2);
                        angle_z = 0.0f;
                    }
                }
                else {
                    angle_x = (float)atan2(transformData.rot[1][0], transformData.rot[1][1]);
                    angle_y = (float)(NE_PI / 2);
                    angle_z = 0.0f;
                }

                angle_x = NE_RAD_TO_DEG(angle_x);
                angle_y = NE_RAD_TO_DEG(angle_y);
                angle_z = NE_RAD_TO_DEG(angle_z);
</code></pre>
<p>Das mit dem berechnen der Rotation hab ich von<br />
dem Tokamak - Forum, das aber leider seit 5 Jahren gesperrt ist :/.<br />
Weiß jemand wie man das richtig macht?<br />
Freue mich auf jede Antwort <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>
<p>Mfg, Pk3</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/269868/gelöst-rotation-aus-matrix-lesen</link><generator>RSS for Node</generator><lastBuildDate>Sun, 30 Aug 2026 22:17:08 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/269868.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 02 Jul 2010 11:39:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [gelöst] Rotation aus Matrix lesen on Sat, 03 Jul 2010 17:46:27 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>ich versuche schon seit einiger Zeit die Rotation (X, Y, Z) aus einer<br />
3x3 - Matrix zu lesen. Klappt aber leider nicht ganz. Dabei geht es um<br />
die Physik - Engine &quot;Tokamak&quot;, bei der ich von allen physikalischen Objekten<br />
die Position und Rotation auslesen moechte. Das Problem ist, das die Rotation<br />
falsch ist und somit z.B. ein Würfel manchmal auf einer Ecke steht, obwohl er nirgends angelehnt ist.</p>
<p>Hier mal der Code:</p>
<pre><code class="language-cpp">neT3 transformData;
		GLfloat angle_x, angle_y, angle_z;

		// Matrix auslesen
		transformData = Object[i].physic.rigidBody-&gt;GetTransform();

		// Rotation berechnen
                if(transformData.rot[0][2] &lt; 1.0f) {
                    if(transformData.rot[0][2] &gt; -1.0f) {
                        angle_x = (float)atan2(-transformData.rot[1][2], transformData.rot[2][2]);
                        angle_y = (float)asin((double)transformData.rot[0][2]);
                        angle_z = (float)atan2(-transformData.rot[0][1], transformData.rot[0][0]);
                    }
                    else {
                        angle_x = (float)-atan2(transformData.rot[1][0], transformData.rot[1][1]);
                        angle_y = (float)(-NE_PI/ 2);
                        angle_z = 0.0f;
                    }
                }
                else {
                    angle_x = (float)atan2(transformData.rot[1][0], transformData.rot[1][1]);
                    angle_y = (float)(NE_PI / 2);
                    angle_z = 0.0f;
                }

                angle_x = NE_RAD_TO_DEG(angle_x);
                angle_y = NE_RAD_TO_DEG(angle_y);
                angle_z = NE_RAD_TO_DEG(angle_z);
</code></pre>
<p>Das mit dem berechnen der Rotation hab ich von<br />
dem Tokamak - Forum, das aber leider seit 5 Jahren gesperrt ist :/.<br />
Weiß jemand wie man das richtig macht?<br />
Freue mich auf jede Antwort <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>
<p>Mfg, Pk3</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1920386</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1920386</guid><dc:creator><![CDATA[Pk3]]></dc:creator><pubDate>Sat, 03 Jul 2010 17:46:27 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst] Rotation aus Matrix lesen on Fri, 02 Jul 2010 11:58:03 GMT]]></title><description><![CDATA[<p>Wieso interessieren Dich Eulerwinkel?<br />
Die sind doch so extrem unpraktisch.</p>
<p>Was willst Du wirklich?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1920410</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1920410</guid><dc:creator><![CDATA[Sebastian Pizer]]></dc:creator><pubDate>Fri, 02 Jul 2010 11:58:03 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst] Rotation aus Matrix lesen on Fri, 02 Jul 2010 12:47:31 GMT]]></title><description><![CDATA[<p>Ich will nur die X-, Y- und Z-Rotation aus dieser Matrix lesen.<br />
Keine Ahnung was es da sonst noch für &quot;Rotationsmoeglichkeiten&quot; gibt.<br />
Jedenfalls brauch ich diese um die Objekte in OpenGL darzustellen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> .</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1920448</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1920448</guid><dc:creator><![CDATA[Pk3]]></dc:creator><pubDate>Fri, 02 Jul 2010 12:47:31 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst] Rotation aus Matrix lesen on Fri, 02 Jul 2010 13:57:21 GMT]]></title><description><![CDATA[<p>Pk3 schrieb:</p>
<blockquote>
<p>Ich will nur die X-, Y- und Z-Rotation aus dieser Matrix lesen.</p>
</blockquote>
<p>Wozu?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1920471</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1920471</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Fri, 02 Jul 2010 13:57:21 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst] Rotation aus Matrix lesen on Fri, 02 Jul 2010 14:08:48 GMT]]></title><description><![CDATA[<p>Weil ohne die Rotationsdaten das Objekt net richtig angezeigt wird <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/1920475</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1920475</guid><dc:creator><![CDATA[Pk3]]></dc:creator><pubDate>Fri, 02 Jul 2010 14:08:48 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst] Rotation aus Matrix lesen on Fri, 02 Jul 2010 14:30:39 GMT]]></title><description><![CDATA[<p>Um dein Objekt mit OpenGL zu rendern brauchst du keine Eulerwinkel sondern ne Matrix und die hast du. Wo liegt also das Problem!?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1920491</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1920491</guid><dc:creator><![CDATA[dot]]></dc:creator><pubDate>Fri, 02 Jul 2010 14:30:39 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst] Rotation aus Matrix lesen on Fri, 02 Jul 2010 15:00:12 GMT]]></title><description><![CDATA[<p>Ja, kann man natürlich auch machen, aber angenommen man will die Rotation<br />
eines Objektes ändern, dann währe es doch angebracht, den Eulerwinkel zu verwenden, oder nicht <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/1920511</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1920511</guid><dc:creator><![CDATA[Pk3]]></dc:creator><pubDate>Fri, 02 Jul 2010 15:00:12 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst] Rotation aus Matrix lesen on Fri, 02 Jul 2010 15:02:14 GMT]]></title><description><![CDATA[<p>Kannst du nicht <code>glRotate()</code> verwenden?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1920512</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1920512</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Fri, 02 Jul 2010 15:02:14 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst] Rotation aus Matrix lesen on Fri, 02 Jul 2010 15:02:15 GMT]]></title><description><![CDATA[<p>Du verwendest doch eine Physikengine, warum genau willst du die Rotation denn nochmals verändern!?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1920513</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1920513</guid><dc:creator><![CDATA[dot]]></dc:creator><pubDate>Fri, 02 Jul 2010 15:02:15 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst] Rotation aus Matrix lesen on Fri, 02 Jul 2010 15:14:09 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/12954">@Nexus</a><br />
Doch, mach ich auch, aber genau da is der Punkt: Dafür brauch ich die X,Y und Z-Rotation.</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/6496">@dot</a><br />
Ich verwende die PhysikEngine in meiner Engine, also ne Engine in einer Engine :D.<br />
Und da kann es schonmal vorkommen das man von einem Objekt die Rotation verändern will.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1920518</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1920518</guid><dc:creator><![CDATA[Pk3]]></dc:creator><pubDate>Fri, 02 Jul 2010 15:14:09 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst] Rotation aus Matrix lesen on Fri, 02 Jul 2010 15:22:31 GMT]]></title><description><![CDATA[<p>Verrat uns doch bitte einfach was genau du tun willst. Die Rotation einfach irgendwie verändern kannst du auch indem du die Rotationsmatrix mit einer weiteren Rotationsmatrix multiplizierst...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1920519</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1920519</guid><dc:creator><![CDATA[dot]]></dc:creator><pubDate>Fri, 02 Jul 2010 15:22:31 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst] Rotation aus Matrix lesen on Fri, 02 Jul 2010 15:42:52 GMT]]></title><description><![CDATA[<p>Ich bin grad dabei eine Engine zu basteln. Darin ist ein PhysicSystem welches mit der Physic-Engine &quot;Tokamak&quot; verbunden ist. Bei dieser Physic-Engine kann man Objekte &quot;registrieren&quot;. In meinen PhysicSystem sind PhysikObjekte, in denen Position, Rotation, EntityLinks usw. stehen und diese Objekte sind &quot;verlinkt&quot; mit den Objekten der PhysikEngine. Und in jedem Frame wird die Position und Rotation vom Objekt der Physic - Engine zu meinem PhysicSystem - Objekt übertragen.</p>
<p>Das RenderSystem nimmt dann die Position und Rotation eines PhysicObjects und rendert es. Das mit der Position funktioniert, nur das mit dem Rotieren nicht...</p>
<p>Hier ein kleiner Codeausschnitt vom RenderSystem:</p>
<pre><code class="language-cpp">glLoadIdentity();
	    // Rotation für die Kameraansicht
	    glRotatef(Render.Camera.Angle.Y, 1.0f, 0.0f, 0.0f);
            glRotatef(360 - Render.Camera.Angle.X, 0.0, 1.0f, 0.0f);

	    // Positionieren
            glTranslatef(Render.Camera.Pos.X + PhysicSystem.Object[i].Pos.X, Render.Camera.Pos.Y + PhysicSystem.Object[i].Pos.Y, Render.Camera.Pos.Z + PhysicSystem.Object[i].Pos.Z);

	    // Rotation
	    glRotatef(PhysicSystem.Object[i].Angle.X, 1.0f, 0.0f, 0.0f);
            glRotatef(PhysicSystem.Object[i].Angle.Y, 0.0, 1.0f, 0.0f);
            glRotatef(PhysicSystem.Object[i].Angle.Z, 0.0, 0.0f, 1.0f);

	    // Rendern
	    // ...
</code></pre>
<p>Hoffe ihr versteht, wie ichs meine :).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1920523</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1920523</guid><dc:creator><![CDATA[Pk3]]></dc:creator><pubDate>Fri, 02 Jul 2010 15:42:52 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst] Rotation aus Matrix lesen on Fri, 02 Jul 2010 16:28:00 GMT]]></title><description><![CDATA[<p>Pk3 schrieb:</p>
<blockquote>
<p>Hier ein kleiner Codeausschnitt vom RenderSystem:</p>
<pre><code class="language-cpp">...
</code></pre>
</blockquote>
<p>Das ist sehr ungeschickt. Du hast sicherlich Kamera-Pose und Objekte-Pose als Matrix/Translationsvektor vorliegen (wenn nicht, warum nicht?!). Dann benutze die doch einfach. Die Rotationsmatrizen in Eulerwinkel umrechnen, nur damit Du glRotate aufrufen kannst ist ... um's politisch korrekt auszudrücken ... &quot;ungeschickt&quot;.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1920550</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1920550</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Fri, 02 Jul 2010 16:28:00 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst] Rotation aus Matrix lesen on Sat, 03 Jul 2010 08:08:37 GMT]]></title><description><![CDATA[<p>Habs so umgeändert, dass ich kein &quot;glRotatef(...)&quot; verwenden muss, also mit &quot;glMultMatrixf(...)&quot;. Klappt jetzt auch. Vielen Dank <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/1920735</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1920735</guid><dc:creator><![CDATA[Pk3]]></dc:creator><pubDate>Sat, 03 Jul 2010 08:08:37 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst] Rotation aus Matrix lesen on Sat, 03 Jul 2010 17:48:41 GMT]]></title><description><![CDATA[<p>Weil ein Vektorprodukt nicht kommutativ ist, ist es nur dann sinnvoll die Eulerwinkel zu berechnen, wenn man die Reihenfolge der Multiplikationen kennt, die zur vorliegenden Rotationsmatrix geführt haben. Die Reihenfolge der Multiplikationen kann je nach Aufgabenfeld anders definiert sein. Die Vorgehensweise zur Berechnung der einzelnen Winkel bei beliebiger Reihenfolge der Multiplikationen ist nahezu identisch.</p>
<p>Wenn man die Matrizen symbolisch:</p>
<pre><code>R[t]x,y,z[/t] = R[t]x[/t]R[t]y[/t]R[t]z[/t]
</code></pre>
<p>multipliziert, dann kann man mit trigonometrischen Funktionen arbeiten.</p>
<p>Im Oberen Beispiel wären die Rotationswinkel der Achsen:</p>
<pre><code>tan[x] = -R[1][2]/R[2][2]
sin[y] =  R[0][2]
tan[z] = -R[0][1]/R[0][0]
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1920888</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1920888</guid><dc:creator><![CDATA[darkfate]]></dc:creator><pubDate>Sat, 03 Jul 2010 17:48:41 GMT</pubDate></item></channel></rss>