Skip to main content
gamedev.net
🔒 Locked

D3DXVec4Transform question (PLEASE HELP)

Started by PinkFish 0 replies 1.2k views
Original Post
PinkFish
PinkFish
I stumbled upon something that should normally be obvious, but i dont seem to get it: transforming a vector by a matrix should work by multiplying C = A x B, with A -> the matrix (4x4), B -> the vector in column form (4x1). ok lets take an example: A = row0 -> 0.865 0.5 0 0 row1 -> 0 0 1 0 row2 -> -0.5 0.865 0 0 row3 -> 0 0 0 1 B = row0 -> 10 row0 -> 20 row0 -> 15 row0 -> 1 this would produce in my code and in http://www.uni-bonn.de/~manfear/matrixcalc.php (a handy online matrix multiplication tool) C = 373/20 (18.65) 15 123/10 (12.3) 1 BUT if try to do that using D3DXVec4Transform using the following code

D3DXMATRIX ma;
		D3DXVECTOR4 mb;
		D3DXVECTOR4 mr;


		ma(0, 0) = 0.865f;
		ma(0, 1) = 0.5f;
		ma(0, 2) = 0.0f;
		ma(0, 3) = 0.0f;
		ma(1, 0) = 0.0f;
		ma(1, 1) = 0.0f;
		ma(1, 2) = 1.0f;
		ma(1, 3) = 0.0f;
		ma(2, 0) = -0.5f;
		ma(2, 1) = 0.865f;
		ma(2, 2) = 0.0f;
		ma(2, 3) = 0.0f;
		ma(3, 0) = 0.0f;
		ma(3, 1) = .0f;
		ma(3, 2) = 0.0f;
		ma(3, 3) = 1.0f;

		mb.x = 10.0f;
		mb.y = 10.0f;
		mb.z = 10.0f;
		mb.w = 10.0f;

		D3DXVec4Transform(&mr, &mb, &ma);


the result is: x 3.6499996 y 13.650000 z 10.000000 w 10.000000 to get the same result as D3DXVec4Transform, i would have to change the order of multiplication, and make a [1x4] x [4x4] -> [1x4] or i would need to transpose the 4x4 matrix! so i dont get it at all, which is the right way?? im probably wrong but i cant figure out where my mistake is ... plz help!!
sirob
sirob
DX uses row-major matrices, while most math applications and standards use column-major matrices (as does OGL).
Conversion between the two is simply a transpose.
Sirob Yes.» - status: Work-O-Rama.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.