Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. What is QMatirx::inverted is being used in QGraphicsView
Forum Updated to NodeBB v4.3 + New Features

What is QMatirx::inverted is being used in QGraphicsView

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 5 Posters 3.2k Views 5 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by Qt Enthusiast
    #1

    what is matrix inverted http://doc.qt.io/qt-4.8/qmatrix.html#inverted

    I went through documentation on http://doc.qt.io/qt-4.8/qmatrix.html#inverted and what is matrix inverted

    K 1 Reply Last reply
    0
    • Q Qt Enthusiast

      what is matrix inverted http://doc.qt.io/qt-4.8/qmatrix.html#inverted

      I went through documentation on http://doc.qt.io/qt-4.8/qmatrix.html#inverted and what is matrix inverted

      K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      @Qt-Enthusiast

      Matrix inversion is a defined, mathematical operation on numerical matrices comparable to simple division of numbers.
      Ask Google is the best way to find out more

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      3
      • Q Offline
        Q Offline
        Qt Enthusiast
        wrote on last edited by
        #3

        Ok Why is it is used in QgraphicsView . is it because

        / 0,0 is top/left corner in qt - flip vertically to make it bottom/left

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          Qt Enthusiast
          wrote on last edited by
          #4

          is some one expert why matrix inversion is used in QgraphicsView

          jsulmJ 1 Reply Last reply
          0
          • Q Qt Enthusiast

            is some one expert why matrix inversion is used in QgraphicsView

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @Qt-Enthusiast Which exact use of matrix inversion in QGraphicsView do you mean?

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            1
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @jsulm Likely this one

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              Q 1 Reply Last reply
              1
              • SGaistS SGaist

                @jsulm Likely this one

                Q Offline
                Q Offline
                Qt Enthusiast
                wrote on last edited by
                #7

                I can share the code if you want

                kshegunovK 1 Reply Last reply
                0
                • Q Offline
                  Q Offline
                  Qt Enthusiast
                  wrote on last edited by
                  #8

                  void myView::mouseReleaseEvent() {
                  createCoreBox();
                  }
                  void myView::createCoreBox(QRect rect)
                  {
                  // convert rect to db coordinates
                  QRect p = d_matrix.inverted().mapRect(mapToScene(rect).boundingRect().toRect());

                  }

                  I am not able to get why inverted matrix is used in above code

                  1 Reply Last reply
                  0
                  • Q Qt Enthusiast

                    I can share the code if you want

                    kshegunovK Offline
                    kshegunovK Offline
                    kshegunov
                    Moderators
                    wrote on last edited by
                    #9

                    A matrix is a (discrete) linear operator that maps one vector space into another; the inverse of a matrix, if it exists, which it may not, reverses the mapping.

                    In layman terms, a matrix is simply a transformation that preserves distance. The inverse of the matrix is the inverse transformation. Scaling, shearing, rotating, translating, axis inversion(s) are all transformations that can be represented by one or more matrices.

                    ... as for your other thread mentioned by @SGaist, no matrix inversion will do you no good to invert the axes, nor will it be helpful in moving the coordinate point origin. You need to construct the appropriate transformation matrix to achieve that, which is rather simple:

                    1    0   0
                    0   -1  -H
                    0    0   1
                    

                    where H is the height of the widget/scene/whatever and is used to shift the coordinate system's origin so it coincides with the bottom left corner. Read more on matrices and transformations here.

                    Read and abide by the Qt Code of Conduct

                    1 Reply Last reply
                    2
                    • Q Offline
                      Q Offline
                      Qt Enthusiast
                      wrote on last edited by
                      #10

                      void myView::createCoreBox(QRect rect)
                      {
                      // convert rect to db coordinates
                      QRect p = d_matrix.inverted().mapRect(mapToScene(rect).boundingRect().toRect());

                      }

                      My QRect co ordinates are

                      Rect 123 202 333 42

                      but mapTpScenece(Rect) returns Rect 0 -1 -1 0 <. I am not sure why in which case mapToScence returns 0 -1 -1 0

                      kshegunovK 1 Reply Last reply
                      0
                      • Q Qt Enthusiast

                        void myView::createCoreBox(QRect rect)
                        {
                        // convert rect to db coordinates
                        QRect p = d_matrix.inverted().mapRect(mapToScene(rect).boundingRect().toRect());

                        }

                        My QRect co ordinates are

                        Rect 123 202 333 42

                        but mapTpScenece(Rect) returns Rect 0 -1 -1 0 <. I am not sure why in which case mapToScence returns 0 -1 -1 0

                        kshegunovK Offline
                        kshegunovK Offline
                        kshegunov
                        Moderators
                        wrote on last edited by
                        #11

                        @Qt-Enthusiast said in What is QMatirx::inverted is being used in QGraphicsView:

                        I am not sure why in which case mapToScence returns 0 -1 -1 0

                        You have plenty of information in this thread, so you need to read up on the math and understand it; only then start to write down code. The "throw it against the wall and see what sticks" method will bring you only so far ...

                        Read and abide by the Qt Code of Conduct

                        1 Reply Last reply
                        2

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved