Announcement

Collapse
No announcement yet.

Matrix and vector multiplication

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Matrix and vector multiplication

    Does open inventor use column vectors to apply matrix multiplications or row vectors?

  • #2
    Row vectors

    Originally posted by zack View Post
    Does open inventor use column vectors to apply matrix multiplications or row vectors?
    Good question. The reference manual doesn't really make this clear. The good news is that, in my experience at least, you don't need to know this very often in order to use Inventor. Just remember to apply transforms in the correct order in the scene graph.

    Open Inventor considers coordinates to be row vectors.
    Therefore use SbMatrix::multVecMatrix to transform a position (e.g. from object coords to world coords) and SbMatrix::multDirMatrix to transform a normal vector.

    Correspondingly transforms are applied "left to right".
    So use SbMatrix::multLeft to concatenate a transform onto the cumulative modeling matrix.

    Matrices are effectively stored in column-major order. So m[i][j] is the value in column i and row j (just like OpenGL matrices, but unlike classic C/C++ 2d arrays). For example, in a 4x4 transform matrix the translation X, Y, Z values are in m[3][0], m[3][1] and m[3][2].

    -Mike

    Comment


    • #3
      The OIV doc saith :
      4x4 matrix class/datatype used by many Open Inventor node and action classes. The matrices are stored in row-major order.
      Which of course say nothing about the vector and matrix multiplication.

      When OIV use row vectors, then I have to use SbMatrix::multRight
      to concatenate a new transformation to the current one.

      Another question, juse to clear some points:
      When I insert a rotation as first child, a translation as second child and a primitive as third child in the scenegraph.

      Which transformation is applied first to the primitive?
      The inventor mentor said, it would be the translation and then the rotation.
      And because of that I though OIV use column vector (V' = R * T * V)

      Comment


      • #4
        Trust the source

        Originally posted by zack View Post
        The OIV doc saith : "The matrices are stored in row-major order."
        Well, that proves the whole row/column thing has been confusing since SGI first etched this code into clay tablets...
        We'll fix that in the next release (i.e. after 8.0). For now see my previous message based on reading the source code.
        Another question, juse to clear some points:
        When I insert a rotation as first child, a translation as second child and a primitive as third child in the scenegraph. Which transformation is applied first to the primitive?
        The inventor mentor said, it would be the translation and then the rotation.
        And because of that I though OIV use column vector (V' = R * T * V)
        The Mentor is correct. Transformations are applied in the reverse order they appear in the scene graph. Each transform node (effectively) calls SbMatrix::multLeft to concatenate the new transform onto the accumulated modeling matrix. (I say "effectively" because there are arithmetic shortcuts taken in some cases, but the effect is the same.) Thus V' = V * T * R.

        Regards,
        Mike

        Comment

        Working...
        X