Jump to content
  • Advertisement
Sign in to follow this  
NDIR

unknown matrix

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!