Matrizen...





  • Mögliche Fehlerursachen
    - mein verständnis über den Aufbau der Viewmatrix
    - Falsches Koordinatensystem
    - Rotationsmatrix falsch...

    usw.



  • (0.984808) (0.000000) (0.173648) (0.000000)
    (0.000000) (1.000000) (0.000000) (0.000000)
    (-0.173648) (0.000000) (0.984808) (0.000000)
    (-0.868241) (0.000000) (4.924039) (1.000000)
    

    was mir kommisch vorkommt ist der Wert -0.868241 (links unten)
    muss das nicht +0.868241 heißen?



  • Vertexwahn schrieb:

    die angegebene Matrix ist: rotationsmatrix * translationmatrix und ⚠ nicht ⚠

    translationmatrix * rotationsmatrix.

    Die Matrixmultiplikation ist nicht kommutativ!

    Hab ich deshalb vertauscht da es eine Kameramatrix ist.

    Mit den Werten kann ich jetzt nicht wirklich viel anfangen, weiß also nicht ob diese so korrekt sind wie sie sollen.
    Könntest du mir trotzdem zeigen wie man die Roll, Pitch, ... ausrechnet? Kann es dann ja selbst überprüfen ob das rauskommt was soll.

    Die *.pdf werd ich mir mal zu geüte ziehen.



  • Hab ich deshalb vertauscht da es eine Kameramatrix ist.

    Das ist schwachsinn! Die View Matrix gibt im Regelfall nur die Verschiebung und Rotation der Kamera in Bezug auf das Weltkoordinatensystem an.

    ich hab eine Idee - schick mir doch einfach mal das OpenGL Programm mit dem du die Werte der Viewmatrix ermittelt hast - dann kann ich das selber etwas rumschrauen...
    (vertexwahn@gmx.de)



  • OK, werd ich heute Nachmittag machen.



  • kurz und schmerzlos - deine Matrixmultiplikation ist falsch implementiert:

    inline GLMatrix16f operator*	(const GLMatrix16f &m1, const GLMatrix16f...
    

    darauf bin ich durch folgende Ausgabe gekommen:

    18.09.58: Hier kommt die Maus aeh... die modelview matrix (= cam_pos*cam_rot):
    18.09.58: (0.984808) (0.000000) (0.173648) (0.000000)
    18.09.58: (0.000000) (1.000000) (0.000000) (0.000000)
    18.09.58: (-0.173648) (0.000000) (0.984808) (0.000000)
    18.09.58: (-0.868241) (0.000000) (4.924039) (1.000000)
    18.09.58: cam_pos:
    18.09.58: (1.000000) (0.000000) (0.000000) (0.000000)
    18.09.58: (0.000000) (1.000000) (0.000000) (0.000000)
    18.09.58: (0.000000) (0.000000) (1.000000) (0.000000)
    18.09.58: (0.000000) (0.000000) (5.000000) (1.000000)
    18.09.58: cam_rot:
    18.09.58: (0.984808) (0.000000) (0.173648) (0.000000)
    18.09.58: (0.000000) (1.000000) (0.000000) (0.000000)
    18.09.58: (-0.173648) (0.000000) (0.984808) (0.000000)
    18.09.58: (0.000000) (0.000000) (0.000000) (1.000000)



  • so hab deinen Code ein wenig verändert:

    18.59.39: Hier kommt die Maus aeh... die modelview matrix:
    18.59.39: (0.984808) (0.000000) (0.173648) (0.000000)
    18.59.39: (0.000000) (1.000000) (0.000000) (0.000000)
    18.59.39: (-0.173648) (0.000000) (0.984808) (0.000000)
    18.59.39: (0.000000) (0.000000) (5.000000) (1.000000)
    18.59.39: cam_pos:
    18.59.39: (1.000000) (0.000000) (0.000000) (0.000000)
    18.59.39: (0.000000) (1.000000) (0.000000) (0.000000)
    18.59.39: (0.000000) (0.000000) (1.000000) (0.000000)
    18.59.39: (0.000000) (0.000000) (5.000000) (1.000000)
    18.59.39: cam_rot:
    18.59.39: (0.984808) (0.000000) (0.173648) (0.000000)
    18.59.39: (0.000000) (1.000000) (0.000000) (0.000000)
    18.59.39: (-0.173648) (0.000000) (0.984808) (0.000000)
    18.59.39: (0.000000) (0.000000) (0.000000) (1.000000)

    jetzt passt die Model View Matrix!

    void GL_CameraEx::UpdateCameraEx(bool rotate_around, bool print_matrix)
    {
    	float modelview[16];
    	glGetFloatv(GL_MODELVIEW_MATRIX, modelview);
    	GLMatrix16f mv_cur(modelview);
    	//if(rotate_around == false)		// Notiz: in diesem fall ist es egal ob man erst rot * pos oder pos * rot
    	//	mv_cur = mv_cur * cam_pos * cam_rot;
    
    	//else
    	//	mv_cur = mv_cur * cam_rot * cam_pos;
    	mv_cur = cam_rot;
    	mv_cur.m41 = cam_pos.m41;
    	mv_cur.m42 = cam_pos.m42;
    	mv_cur.m43 = cam_pos.m43;
    
    	if(print_matrix == true)
    	{
    		WriteDebugFile("Hier kommt die Maus aeh... die modelview matrix:\n");
    		WriteDebugFile("(%f) (%f) (%f) (%f)\n", mv_cur.m11, mv_cur.m12, mv_cur.m13, mv_cur.m14);
    		WriteDebugFile("(%f) (%f) (%f) (%f)\n", mv_cur.m21, mv_cur.m22, mv_cur.m23, mv_cur.m24);
    		WriteDebugFile("(%f) (%f) (%f) (%f)\n", mv_cur.m31, mv_cur.m32, mv_cur.m33, mv_cur.m34);
    		WriteDebugFile("(%f) (%f) (%f) (%f)\n", mv_cur.m41, mv_cur.m42, mv_cur.m43, mv_cur.m44);
    
    		WriteDebugFile("cam_pos:\n");
    		WriteDebugFile("(%f) (%f) (%f) (%f)\n", cam_pos.m11, cam_pos.m12, cam_pos.m13, cam_pos.m14);
    		WriteDebugFile("(%f) (%f) (%f) (%f)\n", cam_pos.m21, cam_pos.m22, cam_pos.m23, cam_pos.m24);
    		WriteDebugFile("(%f) (%f) (%f) (%f)\n", cam_pos.m31, cam_pos.m32, cam_pos.m33, cam_pos.m34);
    		WriteDebugFile("(%f) (%f) (%f) (%f)\n", cam_pos.m41, cam_pos.m42, cam_pos.m43, cam_pos.m44);
    
    		WriteDebugFile("cam_rot:\n");
    		WriteDebugFile("(%f) (%f) (%f) (%f)\n", cam_rot.m11, cam_rot.m12, cam_rot.m13, cam_rot.m14);
    		WriteDebugFile("(%f) (%f) (%f) (%f)\n", cam_rot.m21, cam_rot.m22, cam_rot.m23, cam_rot.m24);
    		WriteDebugFile("(%f) (%f) (%f) (%f)\n", cam_rot.m31, cam_rot.m32, cam_rot.m33, cam_rot.m34);
    		WriteDebugFile("(%f) (%f) (%f) (%f)\n", cam_rot.m41, cam_rot.m42, cam_rot.m43, cam_rot.m44);
    
    	}
    
    	glLoadMatrixf((float*)(mv_cur));
    }
    


  • Vielen dank erst mal für die Korrekturen =))

    Aber um nochmal auf die eigentliche Frage zurückzukommen:
    Den Pitch, Roll und Yaw Winkel aus der Matrix berechnen?





  • PS: Lies dir bitte mein PDF durch!



  • Danke! =))



  • Eine kleine Frage noch am Rande, darf ich erfahren was an der Matrixmultiplikation falsch implementiert ist? Ich steh da grad auf dem Schlauch...



  • Eine kleine Frage noch am Rande, darf ich erfahren was an der Matrixmultiplikation falsch implementiert ist? Ich steh da grad auf dem Schlauch...

    1. LGS:
    a11*x+a12*y+a13*z+a14*w = x'
    a21*x+a22*y+a23*z+a24*w = y'
    a31*x+a32*y+a33*z+a34*w = z'
    a41*x+a42*y+a43*z+a44*w = w'

    2. LGS:
    b11*x'+b12*y'+b13*z'+b14*w' = x''
    b21*x'+b22*y'+b23*z'+b24*w' = y''
    b31*x'+b32*y'+b33*z'+b34*w' = z''
    b41*x'+b42*y'+b43*z'+b44*w' = w''

    das 1. LGS als Matrix:
    (a11 a12 a13 a14)
    A= (a21 a22 a23 a24)
    (a31 a32 a33 a34)
    (a41 a42 a43 a44)

    das 2. LGS als Matrix:
    (b11 b12 b13 b14)
    B= (b21 b22 b23 b24)
    (b31 b32 b33 b34)
    (b41 b42 b43 b44)

    Die Matrixmultiplikation B * A ist nichts anderes als die Hintereinaderausführung der Transformation A und B.

    also:
    b11*(a11*x+a12*y+a13*z+a14*w) +b12*(a21*x+a22*y+a23*z+a24*w) +b13*(a31*x+a32*y+a33*z+a34*w)+b14*(a41*x+a42*y+a43*z+a44*w) = x''
    b21*(a11*x+a12*y+a13*z+a14*w) +b22*(a21*x+a22*y+a23*z+a24*w) +b23*(a31*x+a32*y+a33*z+a34*w)+b24*(a41*x+a42*y+a43*z+a44*w) = y''
    b31*(a11*x+a12*y+a13*z+a14*w) +b32*(a21*x+a22*y+a23*z+a24*w) +b33*(a31*x+a32*y+a33*z+a34*w)+b34*(a41*x+a42*y+a43*z+a44*w) = z''
    b41*(a11*x+a12*y+a13*z+a14*w) +b42*(a21*x+a22*y+a23*z+a24*w) +b43*(a31*x+a32*y+a33*z+a34*w)+b44*(a41*x+a42*y+a43*z+a44*w) = w''

    Jetzt einfach alles in die Form
    C11*x + C12*y + C13*y + C14*w = x''
    C21*x + C22*y + C23*y + C24*w = y''
    C31*x + C32*y + C33*y + C34*w = z''
    C41*x + C42*y + C43*y + C44*w = w''

    bringen - Koeffizenten ablesen - das ist dann gleich C = B * A


Anmelden zum Antworten