Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>Given an arbitrary 4x4 transformation matrix, how do I find out the center of rotation?</p> </blockquote> <p>The problem cannot be solved in general case, because matrix might not represent rotation. It could be projection matrix, zero matrix, etc. </p> <p>Aside from that you might want to check <a href="https://stackoverflow.com/a/9918735/271376">this answer</a>.</p> <p>Your matrix represents transform that converts old coordinate system into new coordinate system.</p> <hr> <p>Object matrix can be represented this way:</p> <pre><code>objx.x objx.y objx.z 0 //m[0][0]..m[0][3] or _11, _12, _13, _14 objy.x objy.y objy.z 0 //m[1][0]..m[1][3] or _21, _22, _23, _24 objz.x objz.y objz.z 0 //m[2][0]..m[2][3] or _31, _32, _33, _34 objpos.x objpos.y objpos.z 1 //m[3][0]..m[3][3] or _41, _42, _43, _44 </code></pre> <p>Where m[][] and _11.._44 are corresponding elements of D3DMATRIX, objpos - object position vector, objx - object x ('local x" transformed to world space) vector, etc.</p> <p>So as long as the last column (m[0..3][3]) is 0, 0, 0, 1 you can extract object position and its "x", "y", "z" vectors ("side", "up", "front" - which is which depends on application) from matrix. If last column is not "0, 0, 0, 1", then it is projection matrix and you can't extract object data from it this easily.</p> <hr> <p>So you can extract individual vector and center of old coordinate system within new coordinate system, and individual vectors. THen you can find out center of rotation or whatever you want using them.</p> <p>However, for a matrix to represent rotation, following must be true:</p> <ol> <li>dotProduct(objx, objy) == 0</li> <li>dotProduct(objx, objz) == 0</li> <li>dotProduct(objx, objz) == 0</li> <li>dotProduct(objx, objx) == 1</li> <li>dotProduct(objy, objy) == 1</li> <li>dotProduct(objz, objz) == 1</li> <li>Last column is [0, 0, 0, 1]</li> </ol> <p>And individual axes should be properly oriented (so you can be sure this isn't a "mirror" matrix). Exact orientation depends on your application. Could be something like this:</p> <ol> <li>crossProduct(objy, objx) == objz</li> <li>crossProduct(objx, objz) == objy</li> <li>crossProduct(objz, objy) == objx</li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload