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

Extracting overall angle from a matrix

  1. Mar 24, 2007 #1
    Hi - was wondering if anyone could help with this problem.

    If I have a square, which is like this:
    Code (Text):

    |     |
    |     |
    and I then apply a transform matrix to it, which might consist of multiple rotations and translations, is there any way to determine what the overall angle is between the horizontal and the line AB of the square?

    I am assuming there is a way to do this, because it is always possible to just draw out the square with the matrix applied to it, on paper and just measure the angle that it makes to the horizontal with a protractor. However I have no idea how to go about working out the angle purely mathematically.

    The matrix I am using is of the form:
    [a] [c] [e]
    [d] [f]
    [0] [0] [1]

    I would appreciate any help with this.
  2. jcsd
  3. Mar 25, 2007 #2
    You're using an x-y coordinate frame. The angle that AB makes with respect to the x axis is just the inverse tangent of YAB/XAB, where YAB is the y component of A minus the y component of B.
  4. Mar 25, 2007 #3
    Hi - thanks for the help.

    I should say that this is for use with Javascript and SVG.

    The problem is that I don't know what the x and y coordinates are of any of the corners once the matrix is applied to it. I know the x and y position of the top left hand corner of the square before the matrix is applied to it, however when you apply the matrix to it, according to the computer, the x and y coordinates of the square stay the same even though the position of the top left hand corner has moved.

    So because I don't have the x and y coordinates of the corners A or B I can't use that formula.

    Do you have any suggestions on how I could work out the position of A and B just by using the coordinates of the square before the matrix is applied, and the matrix itself?

    Sorry if this post isn't very clear.
  5. Mar 25, 2007 #4
    It looks like you're applying a rotation matrix to the components.


    where M is your matrix and r is the triplet r=(rx,ry,rz). Is that correct?
  6. Mar 25, 2007 #5
    erm - i'm not really sure what that means - my maths has never been very good.

    Maybe this explains it better:
    if you search for: "Mathematically, all transformations can be represented as 3x3 transformation matrices of the following form:" without the speech marks that section explains how the matrix system I am using works.

    Thanks for your help again.
  7. Mar 25, 2007 #6

    Are you transforming the coordinate system (x and y axes) or are you transforming the box, whilst keeping the coordinate system fixed?

    These are largely equivalent processes, but it would be nice to know which one you're doing.
  8. Mar 25, 2007 #7
    Hi - sorry for the delay in replying. I was expecting to get an email but it never arrived.

    When I apply the matrix, the coordinate system of the object is changed to reflect the matrix. So, for example if I rotate the object by 30 degrees, the coordinate system of the object, will rotate 30 degrees. However, the 'base' coordinate system stays the same. So in essence you have a coordinate system within another coordinate system.

    If you have a look here: http://www.w3.org/TR/SVG/images/coords/RotateScale.svg [edit] you will need Internet explorer with the Adobe SVG Viewer plugin or just firefox to view that file [/edit] the black lines along the top and left hand side is the 'base' coordinate system, and the red lines are the new coordinate system for each matrix.

    So in answer to your question, i am transforming a 'child' coordinate system within a fixed coordinate system.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?

Similar Discussions: Extracting overall angle from a matrix