Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Un-scaling the matrix - how?

  1. Dec 26, 2007 #1
    1. The problem statement, all variables and given/known data
    We have (3d) vectors v1 and v2, and some matrix M, v2 = M v1. This scales and rotates vectors, but I need to constrain this to rotation only. So we have this in a form M = S * R (or R * S) where S is scaling only matrix, and R is rotation only.

    2. Relevant equations
    If I knew these, I wouldn't be posting.

    3. The attempt at a solution
    I figured that S must be diagonal matrix, and if we put ort vectors through M, we could somehow find its non-zero coefs and then easily invert it, but the exact math escapes me... Then I thought, there must be someone who did this, or knows someone who did :)

    [edit] I have found this unfinished discussion on gamedev, that suggests this thing is implemented in directx, so it is definitely possible; meanwhile, I will keep searching.

    [edit] holy crrr carramba, it seems so complex. 1 + 2 and 3... my head is going to explode.

    is there at least any simple way to extract rotation part alone?
    Last edited: Dec 26, 2007
  2. jcsd
  3. Dec 27, 2007 #2


    User Avatar
    Science Advisor
    Homework Helper

    I'm not sure that such a decomposition exists in the general case.

    You should look into the QR decomposition algorithms.
  4. Dec 28, 2007 #3
    hey thanks I looked at this method, and it seems to solve my problem in just three steps. however, I do not understand whre they got 6 in denominator from.

    I also looked at this article, and the notes there seem to be saying that I can compute G coefs immediately, without finding an angle. but there I cant seem to grasp where do they get a and b from.

  5. Dec 28, 2007 #4

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    There's always Numerical Recipes, http://www.nrbook.com/a/bookcpdf/c2-10.pdf

    Beware that the code is in "C-Tran" (Fortran translated to C). In particular, arrays are indexed from 1 (ala Fortran) rather than 0, as in C.
  6. Dec 29, 2007 #5
    thanks, but that pdf doesnt open here. I seem to figure that a and b refer to values in original matrix, so I will try to code this per wiki (hopefully people who wrote that did not screw it up).
    Last edited: Dec 29, 2007
  7. Dec 29, 2007 #6


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Just to clarify...

    S is supposed to be a diagonal matrix?
    R is supposed to be an orthogonal matrix with determinant 1?

    If so, this is appears to be a very easy problem:

    If M = RS, then

    [tex]M^T M = S^T R^T R S = S I S = S^2[/tex]

    If M = SR, then

    [tex]M M^T = S R R^T S^T = S I S = S^2[/tex]

    Either way, you can cancel out the rotation and thus get the square of your scaling matrix. All that's left is to take the square root, and guess the signs.

    If R is allowed to be a combination of rotations and reflections, then it doesn't even matter if you get the signs right!

    If S is supposed to be a multiple of the identity, it's even easier: SR=RS, and you only need to compute a single entry of [itex]M^T M[/itex].
    Last edited: Dec 29, 2007
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook