# unknown matrix

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

## Recommended Posts

Hey all. Another question. Lets say i have a model A and model B. I know that model B is just a copy of model A, but transformed by some matrix (this matrix 4x4 contains rotation about custom axis and translation). Now i'd like to calculate this matrix. How would one do that? So i have vertices from A and transformed vertices from B. How to calculate the matrix?

##### Share on other sites
Do you know for each vertex which to which vertex in the other model it corresponds to?

yes.

##### Share on other sites
Let P_a_i be a vertex from mesh A and P_b_i be a vertex from mesh B.
Let T be our unknown transformation.

We have that P_b_i = T * P_a_i for all i. Written a different way:

| P_b_i_x |   | T_11 T_12 T_13 T_14 | | P_a_i_x || P_b_i_y | = | T_21 T_22 T_23 T_24 | | P_a_i_y || P_b_i_z |   | T_21 T_22 T_23 T_24 | | P_a_i_z || P_b_i_w |   | T_21 T_22 T_23 T_24 | | P_a_i_w |

We want to solve for T, so we need more points. We can simply write these points as columns:

| P_b_i_x P_b_j_x P_b_k_x P_b_l_x |   | T_11 T_12 T_13 T_14 | | P_a_i_x P_a_j_x P_a_k_x P_a_l_x || P_b_i_y P_b_j_y P_b_k_y P_b_l_y | = | T_21 T_22 T_23 T_24 | | P_a_i_y P_a_j_y P_a_k_y P_a_l_y || P_b_i_z P_b_j_z P_b_k_z P_b_l_z |   | T_21 T_22 T_23 T_24 | | P_a_i_z P_a_j_z P_a_k_z P_a_l_z || P_b_i_w P_b_j_w P_b_k_w P_b_l_w |   | T_21 T_22 T_23 T_24 | | P_a_i_w P_a_j_w P_a_k_w P_a_l_w |

For some points P_a_i, P_a_j, P_a_k, P_a_l in mesh A and points P_b_i, P_b_j, P_b_k, P_b_l in mesh B. Now we can simply multiply by the inverse of the P_a matrix on the right side of the equation to get T.

##### Share on other sites
Then you can just pick any 4 vertices from your first mesh, create a matrix P that has those 4 vertices as columns, create another matrix Q that has the same 4 vertices form the second mesh as it's columns. The matrix which you want will then be

A = Q * inv(P)

thanks!

• 16
• 11
• 11
• 9
• 49
• ### Forum Statistics

• Total Topics
631394
• Total Posts
2999749
×