A question about btTransform column/row order

vicviper
Posts: 21
Joined: Thu Jun 01, 2006 9:55 pm

A question about btTransform column/row order

Post by vicviper »

I took a look at btTransform, it contains a 3x3 matrix and a vector3 , essentially making a 3x4 matrix.

I've seen the ( ) operator, which is being used to transforms vertices from local to world position, and as far as I know, it should be equicalent to: vector = vector * matrix3x3, multiplying vector bymatrix columns

but instead of that, it's working like vector = matrix3x3 * vector, multiplying vector bymatrix rows.

is that the correct/desired behavior?

It looks like the default matrix3x3 has the correct vector * matrix (columns) order.

Is the 3x3 matrix being used in transposed mode when used in a btTransform?

thanks in advance!
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: A question about btTransform column/row order

Post by Erwin Coumans »

Those 3 lines should be equivalent, for transform T, with rotation M and translation T, and vector v:
v = T * v
v = T(v)
v = T.getRotation()*v + T.getOrigin()
v = M * v + T

It looks consistent. By the way, the interface is directly taken from SOLID collision library, without modifications (and with Gino van den Bergen's permission of course).

I'm tempted to make the interface a bit more clear, with method named 'transformPoint' and 'transformVector', instead of the confusing and errorprone operators. Note that currently, btPoint is typedef'd at vector, to avoid endless vector <-> point conversions.

Do you recommend certain changes?
Thanks,
Erwin
vicviper
Posts: 21
Joined: Thu Jun 01, 2006 9:55 pm

Re: A question about btTransform column/row order

Post by vicviper »

Ok, I think I understand now that you're using a transform like this:

1 0 0 X
0 1 0 Y
0 0 1 Z

And that's the reason because to transform a vertex, you do V' = T * V;

I't s just that I was used to this one:
1 0 0
0 1 0
0 0 1
X Y Z

so, in order to transform a vertex, I need to do V' = V * T; which is what was confusing me.

About a clearer interface, I suggest you this one:

worldPoint = Transform.LocalToWorld( localPoint );
localPoint = Transform.WorldToLocal( worldPoint );

This interface has the advantage that leaves no room for mistakes, regarding which basis translation are you doing, something that happens with V' = T * V or V' = V * T , which is dependant of the row/column order you have chosen.

Anyway, I would leave the operator() as a convenience shortcut for LocalToWorld operation

And if I want to tranform only a vector (like a normal Vector), without taking into account the translation component, I would simply use the basis of the transform:

WorldNormal = Transform.GetBasis().LocalToWorld( localNormal );

Hope you like it

Thanks in advance