Getting the look vector of a Matrix when the current rotation is 1.57(x-axis)

This topic is 952 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

How come I would get 1.00000, 0, 0

void CCB::CreateMoveBack()
{

D3DXMATRIX newWorld = m_matWorld;
TurnObjectAround(newWorld);
D3DXVECTOR3 moveBackDir = GetLookVector(newWorld);
CreateMoveBackAnimation(-moveBackDir);

}

void TurnObjectAround(D3DXMATRIX& matWorld) // Rotate an object by D3DX_PI / 2 or 180.0f degrees.
{
D3DXMATRIX RY;
matWorld *= RY;
}

D3DXVECTOR3 GetLookVector(const D3DXMATRIX& matWorld) // Also called Forward vector or Direction vector, this is the vector from the object's world matrix
{
return D3DXVECTOR3(matWorld._13, matWorld._23, matWorld._33);
}


The result is of the vMoveBackDir is -1.0000, 0.0000, 0.0000

when the world matrix is collapsed and when the rotation is 1.57, 0, 0, scale of 1,1,1 and no other transformations added?

Why? I am expecting to get something like 0, 0, 1

Share on other sites

"D3DXVECTOR3(matWorld._13, matWorld._23, matWorld._33);"

You're grabbing the third column from the matrix there, not the third row.

So the identity matrix transformed by a 1.57 rad rotation around the Y-axis results in:

0 0 [-1]

0 1 [0]

1 0 [0]

Share on other sites

Even though the math is corrected now,

I still need to get the right vector instead of the lookat vector without negating it?

Why??? it seems very strange to me...

[0] 0 -1

[0] 1 0

[1] 0 0

Thanks

Jack

Edited by lucky6969b

Share on other sites

That's the first row:

[0, 0, -1]

0 1 0

1 0 0

Edited by eppo

Share on other sites

So the first row, is the left vector right (in directx sense),
but why not the third row, which represents the look vector?
I still need to get the left vector though.
Thanks
Jack

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
5. 5
A4L
11

• 12
• 16
• 26
• 10
• 44
• Forum Statistics

• Total Topics
633767
• Total Posts
3013739
×