Results 1 to 9 of 9

Thread: ModelView Matrix & Calc Translation factor

  1. #1
    Member Contributor
    Join Date
    May 2008
    Posts
    67

    ModelView Matrix & Calc Translation factor

    My modelview matrix is currently:

    1 0 0 0
    0 cos45 -sin45 0
    0 sin45 cos45 0
    0 0 0 0

    Now I call glTranslate(0,2,0) and multiply the above matrix with the below one.

    1000
    0101
    0010
    0001

    I can figure out the first 3x3 block which is just

    1 0 0
    0 cos45 -sin45 0
    0 sin45 cos45 0

    But how do I figure out the right most column ( the translation values)

  2. #2
    Senior Member Regular Contributor trinitrotoluene's Avatar
    Join Date
    Sep 2008
    Location
    Montérégie,Québec
    Posts
    362

    Re: ModelView Matrix & Calc Translation factor

    This is just a 4x4 matrix multiply. Multiply rows of matrix 1 by column of matrix 2. So

    |1 0 0 0 |
    |0 cos45 -sin45 0 |
    |0 sin45 cos45 0 |
    |0 0 0 1 |
    *
    |1 0 0 0|
    |0 1 0 2|
    |0 0 1 0|
    |0 0 0 1|

    =
    | 1 0 0 0 |
    | 0 cos45 -sin45 2*cos45 |
    | 0 sin45 cos45 2*sin45 |
    | 0 0 0 1 |

  3. #3
    Member Contributor
    Join Date
    May 2008
    Posts
    67

    Re: ModelView Matrix & Calc Translation factor

    Ah thankyou for the reply. have looked at the diagram and I understand it now. I did look at it before and misinterpreted it .

    Thankyou! I also have another question which I will post here.

    When we calculate the position of each vertex we multiply it by the modelview matrix right, so how is the new position calculated?

    Do we just represent the point P (4,3,2) as a 3x1 matrix then do matrix multiplication between the point and the MV matrix?

  4. #4
    Senior Member Regular Contributor trinitrotoluene's Avatar
    Join Date
    Sep 2008
    Location
    Montérégie,Québec
    Posts
    362

    Re: ModelView Matrix & Calc Translation factor

    Yes, you can represent a point P (4,3,2,1) (x,y,z,w) as a 4x1 matrix. This is called homogeneous coordinates.

    In OpenGL, the modelview matrix and a vertex is multiplied in this order P' = MV * P

  5. #5
    Member Contributor
    Join Date
    Mar 2008
    Location
    Northern Virginia (USA)
    Posts
    84

    Re: ModelView Matrix & Calc Translation factor

    Quote Originally Posted by baconbeastnz
    Ah thankyou for the reply. have looked at the diagram and I understand it now. I did look at it before and misinterpreted it .

    Thankyou! I also have another question which I will post here.

    When we calculate the position of each vertex we multiply it by the modelview matrix right, so how is the new position calculated?

    Do we just represent the point P (4,3,2) as a 3x1 matrix then do matrix multiplication between the point and the MV matrix?
    Yes, as the other poster already said.

    Of course, usually we don't apply our matrix transformations to vertexes directly. The video driver applies our model view and projection matrixes to our vertexes when we render them. Modern accelerated video hardware is a WHOLE lot faster for matrix math like this than the CPU.
    Duncan C

  6. #6
    Member Contributor
    Join Date
    May 2008
    Posts
    67

    Re: ModelView Matrix & Calc Translation factor

    ok cool, thanks, so glad i finally understands how that all works now =D for my next assignment I need to make ray caster should be fun but still need to understand quite a few more concepts lol.

    cheers guys!

  7. #7
    Member Contributor
    Join Date
    May 2008
    Posts
    67

    Re: ModelView Matrix & Calc Translation factor

    Actually, having just tried to 4x1 multiplication, I have run into another misunderstanding.

    Let p = Mv x P

    MV = below

    1 0 0 0
    0 1 0 0
    0 0 -1 4
    0 0 0 1

    Now to calc P I get:

    X = 1xX + 0xX + 0xX + 0xX
    Y = 0xY + 1xY + 0xY + 0xY
    Z = 0xZ + 0xZ - Z + 4Z

    However the answer for z is supposed to be : "-z +4"

    (O_o)/") hmph.....

  8. #8
    Senior Member Regular Contributor trinitrotoluene's Avatar
    Join Date
    Sep 2008
    Location
    Montérégie,Québec
    Posts
    362

    Re: ModelView Matrix & Calc Translation factor

    No this is

    Suppose we have a point P(X,Y,Z,W=1)

    X = 1*X + 0*Y + 0*Z + 0*W = X
    Y = 0*X + 1*Y + 0*Z + 0xW = Y
    Z = 0*X + 0*Y + -1*Z + 4*W = -Z + 4 => W = 1
    W = 0*X + 0*Y + 0*Z + 1*W = 1

    Here P is a column vector

  9. #9
    Member Contributor
    Join Date
    May 2008
    Posts
    67

    Re: ModelView Matrix & Calc Translation factor

    AHHHH!! I seee I see! another hurdle leaped
    Thanks = )

Similar Threads

  1. Clarification (Projection Matrix & ModelView Matrix)?
    By CroCodile in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 10-01-2013, 11:43 AM
  2. Modelview translation with GLM
    By dirtyburger in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 02-21-2012, 09:14 AM
  3. extract translation/ euler rotation from modelview
    By qnext in forum OpenGL: General
    Replies: 7
    Last Post: 09-20-2011, 02:38 PM
  4. Lightning: ModelView matrix or just Model Matrix?
    By bliss in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 01-14-2011, 02:38 PM
  5. Difference between Modelview matrix and projection matrix
    By aphlai in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 08-22-2001, 07:22 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean