Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   DelphiGL VectorTransform stimmt nicht mit Mathe überein (https://www.delphipraxis.net/205976-delphigl-vectortransform-stimmt-nicht-mit-mathe-ueberein.html)

mael 5. Nov 2020 21:03


DelphiGL VectorTransform stimmt nicht mit Mathe überein
 
Hallo,

Ich bin etwas verwirrt wie DelphiGL Vektoren transformiert.

Normalerweise tut man dies indem man eine Transformationsmatrix M mit einem Vektor v multipliziert, also so:

M*v = v'

Allerdings hat DelphiGL eine Funktion VectorTransform die es umgekehrt macht, also v*M=v'. Da v*M != M*v ist bin ich etwas verwirrt.

Dass dies so gewollt ist zeigt sich an TGLBaseSceneObject.LocalToAbsolute, welches VectorTransform verwendet, das effektiv v*M berechnet.

Was ist die Logik dahinter?

karlkoch 5. Nov 2020 22:31

AW: DelphiGL VectorTransform stimmt nicht mit Mathe überein
 
Hallo,

die Reihenfolge hängt davon ab, ob mit "Row Major" oder "Column Major" gearbeitet wird.

Viele Grüße,

karlkoch

mael 6. Nov 2020 01:00

AW: DelphiGL VectorTransform stimmt nicht mit Mathe überein
 
Danke.

Im folgenden Link wird nochmal bestätigt dass OpenGL tatsächlich column major verwendet, und damit die übliche Multiplikation von M*v sich zu v*M umdreht. Üblicherweise wird für eine Transformation angenommen, dass M in row major ist, und dann wäre auch M*v korrekt. Da OpenGL (und damit DelphiGL, wohl überall aus Konsistenzgründen dies auch tut) column major annimmt, ist hier für die Transformation v*M korrekt.

Man könnte auch sagen: M*v = v*M^T (wobei M^T die Transponierte von M ist)

https://www.khronos.org/opengl/wiki/...r_row-major.3F

Zitat:

Are OpenGL matrices column-major or row-major?

For programming purposes, OpenGL matrices are 16-value arrays with base vectors laid out contiguously in memory. The translation components occupy the 13th, 14th, and 15th elements of the 16-element matrix.

Column-major versus row-major is purely a notational convention. Note that post-multiplying with column-major matrices produces the same result as pre-multiplying with row-major matrices. The OpenGL Specification and the OpenGL Reference Manual both use column-major notation. You can use any notation, as long as it's clearly stated.

Sadly, the use of column-major format in the spec and blue book has resulted in endless confusion in the OpenGL programming community. Column-major notation suggests that matrices are not laid out in memory as a programmer would expect.

A summary of Usenet postings on the subject can be found here.
Einleitung der Usenet postings:
Zitat:

Column Vectors Vs. Row Vectors

The following are excerpts from an interesting Usenet discussion about the differences in convention between using column vectors or row vectors. This drives the 4x4 matrix representation as well, since vector-matrix multiplication is represented with the matrix on the left for column vectors, and on the right for row vectors. The 4x4 matrices in each case are the transpose of the other convention.

Put another way, if you're using row vectors, your 4x4 translation components are in the bottom row. If you're using column vectors, your 4x4 translation components are in the right column.

Generally, in 3D graphics, you have to keep on your toes, since this convention varies from system to system.


Alle Zeitangaben in WEZ +1. Es ist jetzt 18:57 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz