Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

11991 Posts in 1587 Topics- by 3509 Members - Latest Member: lioneltenel

27. May 2012, 04:02:35 am
Xith3D CommunityGeneral CategorySupport (Moderator: Marvin Fröhlich)Transform3D's setTranslation bug?
Pages: [1]
Print
Author Topic: Transform3D's setTranslation bug?  (Read 1303 times)
Ace Strong
Just dropped in

Offline Offline

Posts: 10


View Profile Email
« on: 13. May 2008, 02:23:19 am »

Code:
public final void setTranslation( float x, float y, float z )
    {
        matrix.m03( x );
        matrix.m13( y );
        matrix.m23( z );
       
        setChanged( true );
    }
The translation matrix seems should be like below

so the code maybe
Code:
public final void setTranslation( float x, float y, float z )
    {
        matrix.m30( x );
        matrix.m31( y );
        matrix.m32( z );
       
        setChanged( true );
    }
Am i right? Huh
Logged
Ace Strong
Just dropped in

Offline Offline

Posts: 10


View Profile Email
« Reply #1 on: 13. May 2008, 02:34:32 am »

I must be wrong Undecided

so the matrix is column first, not row first Smiley
Logged
Mathias 'cylab' Henze
Fierce Warrior
****
Offline Offline

Posts: 540

1064620
View Profile WWW
« Reply #2 on: 13. May 2008, 08:25:12 am »

Yet, but never mind. It's quite confusing that the two major graphics libraries use opponent element order (directx is row major, while opengl is column major by default). Btw. this is a nice little explanation about matrices: http://www.sjbaker.org/steve/omniv/matrices_can_be_your_friends.html
Logged

Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #3 on: 13. May 2008, 09:53:38 am »

Hmm... I maybe totally wrong here. So please correct me, if I am. But this shouldn't have much to do with column-major/row-major. The cm/rm thing just affects the way, the values are arranged in the backing array. But the actual matrix elements are the same in both strategies.

The translation of a 4x4-transformation-matrix is in the first three components of the 4th column.

Marvin
Logged
Mathias 'cylab' Henze
Fierce Warrior
****
Offline Offline

Posts: 540

1064620
View Profile WWW
« Reply #4 on: 13. May 2008, 10:24:48 am »

Yes, you are right, this is not a problem of column/row major notation, but of pre- or postmultiplying the vector.

In xith (and opengl?), the transformation matrix is multiplied with the vector, which afaik is equivalent to multiplying the vector with the transposed matrix. Ace Strongs equation uses the latter, which is why the translation vector is present in the last row and not the last column. The wikipedia article on translation uses the other form: http://en.wikipedia.org/wiki/Translation_(geometry)
Logged

Ace Strong
Just dropped in

Offline Offline

Posts: 10


View Profile Email
« Reply #5 on: 14. May 2008, 12:22:48 am »

I got it!

Thanks Grin
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic