Discussion about math, puzzles, games and fun. Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ π -¹ ² ³ °

You are not logged in.

- Topics: Active | Unanswered

Pages: **1**

**CWinter****Member**- Registered: 2005-09-05
- Posts: 4

Before I go completely insane trying to solve this problem is there someone here extremely good at matrix math and complex linear equations who can work this out for me and give me the formulae.

Below is an example problem to help explain the question.

Using the following translation, rotation and inverse translation vectors (Which would be used in setting up a bone matrix for 3D character animation)

vT1 = (-10, 0, 0)

vR = (3.14, 3.14, 3.14)

vT2 = (10, 0, 0)

Which would turn into the 3 following, 4x4 matrices

mT1:

(1.000000,0.000000,0.000000,0.000000)

(0.000000,1.000000,0.000000,0.000000)

(0.000000,0.000000,1.000000,0.000000)

(-10.000000,0.000000,0.000000,1.000000)

mR:

(0.999997,-0.001593,0.001590,0.000000)

(0.001590,0.999997,0.001595,0.000000)

(-0.001593,-0.001593,0.999997,0.000000)

(0.000000,0.000000,0.000000,1.000000)

mT2:

(1.000000,0.000000,0.000000,0.000000)

(0.000000,1.000000,0.000000,0.000000)

(0.000000,0.000000,1.000000,0.000000)

(10.000000,0.000000,0.000000,1.000000)

And then combing those 3 matrices into the matrix below like this:

mBoneOffset = mT1*mR*mT2

mBoneOffset:

(0.999997,-0.001593,0.001590,0.000000)

(0.001590,0.999997,0.001595,0.000000)

(-0.001593,-0.001593,0.999997,0.000000)

(0.000025,0.015925,-0.015900,1.000000)

***********************

QUESTION.

How do I find the vector vT2 when the ONLY information I have available to me is the mBoneOffset matrix.

I have been told that this is possible by finding the formulaes used to work out the x, y and z values for the matrix and then solving for x, y and z in the resulting complex linear equations but this is completely beyond my knowledge and I really need help here.

***********************

Thanks in advance for anyone who can provide the formulae to solve this problem, it would be greatly appreciated.

Callum.

Offline

**John E. Franklin****Member**- Registered: 2005-08-29
- Posts: 3,588

Can you explain how you get the ...97... numbers in mR?

**igloo** **myrtilles** **fourmis**

Offline

**CWinter****Member**- Registered: 2005-09-05
- Posts: 4

Hi John,

Thanks for having a go at this.

The rotation matrix mR is created by a directx API call to:

D3DXMATRIX* WINAPI D3DXMatrixRotationYawPitchRoll

( D3DXMATRIX *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll );

You supply the rotation angle values in radians and it builds the rotation matrix with those values; I assume by first creating a matrix for each axis and then multiplying the 3 together in the order z(roll), x(pitch), y(yaw); at least thats what the docs say on it.

So the full order of concatenation of matrices for a bone matrix will probably be mT * mRz * mRx * mRy * mT-1

mR is the composite of mRz, mRx and mRy

To help with mR I'll show the formulaes used to generate each rotation matrix in the left handed coordinate system as per the docs.

For each angle in radians you would do:

float sin = sinf(angle);

float cos = cosf(angle);

Then fill in the corrsponding matrix (below). Then when you have all 3 matrices mult them together in the order z,x,y. (This should be exactly what the directx command above is doing to create mR,...... I hope because if it isnt then i dont know, but im going by the docs on this so it should be correct.)

Z-Axis X-Axis Y-Axis

[ cos, sin, 0, 0] [1, 0, 0, 0] [cos, 0, -sin, 0]

[-sin, cos, 0, 0] [0, cos, sin , 0] [ 0, 1, 0, 0]

[ 0, 0, 1, 0] [0, -sin, cos, 0] [sin, 0, cos, 0]

[ 0, 0, 0, 1] [0, 0, 0, 1] [ 0, 0, 0, 1]

I hope that explains enough for you to be able to get somewhere. Thats about as much as i know or needed to know to create a rotation matrix.

Many Thanks

Callum

Offline

**John E. Franklin****Member**- Registered: 2005-08-29
- Posts: 3,588

Thanks for explaining in more detail, however, I must admit that my knowledge

of matrices is far too limited at this point to even get a basic understanding of

what is going on. I am pretty good with trig, however, and wondered if the

...97... number could be computed with trigonometry.

**igloo** **myrtilles** **fourmis**

Offline

**CWinter****Member**- Registered: 2005-09-05
- Posts: 4

The only other help i could give is to explain how to mutiply 2 matrices together

To multiply 1 matrix by the other you multiply the rows of the first by the columns of the second adding the four results in each row. To explain better look below

[a, b, c, d] [A, B, C, D] [aA+bE+cI+dM, aB+bF+cJ+dN, aC+bG+cK+dO, aD+bH+cL+dP]

[e, f, g, h] * [E, F, G, H] = [eA+fE+gI+hM, eB+fF+gJ+hN, eC+fG+gK+hO, eD+fH+gL+hP]

[i, j, k, l] [I, J, K, L] [iA+jE+kI+lM, iB+jF+kJ+lN, iC+jG+kK+lO, iD+jH+kL+lP]

[m,n, o, p] [M, N, O, P] [mA+nE+oI+pM,mB+nF+oJ+pN,mC+nG+oK+pO, mD+nH+oL+pP]

so lets say the first matrix above was mZ and the second was mX, once you have found the result of multiplying those 2 you then multiply the result by mY, which is how you get mR and the values that are in it.

If this still doesnt help, then thanks for spending the time to find if you could solve this or not. The solution to this would allow me to move and centre skin mesh characters around properly in an editor i made, when the models loaded dont contain the original rotation centres of the bones. These are needed to offset the translation values of the bones by the amout the mesh moved but to do that I need to rebuild the bone matrices using the original translation vector(or rotation centre of the bone) with the offset applied. Unfortunatly i cant just add the offset to the translation members of the bone matrix as the values would be wrong and the animation doesnt hold together. This feature will have to be put on hold without this answer, but it just means that we will have to make sure any characters we dont make ourselves and purchase are pre-centred to avoid the need for this feature.

It would have been a handy feature to have but without the solution ill just have to leave it out.

Many thanks for your time.

Callum.

Offline

**John E. Franklin****Member**- Registered: 2005-08-29
- Posts: 3,588

In mR above, why are the 159#'s not all the same? They end in 0, 3, or 5?

I thought the three 3.14 numbers might make this more symmetrical, but I don't know anything yet.

**igloo** **myrtilles** **fourmis**

Offline

**CWinter****Member**- Registered: 2005-09-05
- Posts: 4

Hmmm, I see your point, it could be to do with the precision of floating point numbers.

I'll just do the sin and cos of 3.14 in code and see what results i get

Ok - cos = -0.999999 and sin = 0.001593

so i guess with those values positioned in each of the x y and z matrices. when the numbers are multiplied during concatenation of the matrices then the answers come out slightly off from what they started.

I guess in a perfect world all those similar numbers would be the same, as you thought.

Callum.

Offline

Pages: **1**