sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Noob: Understanding transformation.inverse

    Scheduled Pinned Locked Moved Developers' Forum
    10 Posts 5 Posters 481 Views 5 Watching
    Loading More Posts
    • 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.
    • B Offline
      billwheaton
      last edited by

      I'm having trouble understanding what transformion.inverse does as I examine other people's code and try to learn.

      In TIG's CofGravity.rb code there is a snippet for placing a group...

      ### add markers at cog etc
      tgp=entities.add_group(todo)
      cog_gp=tgp.copy
      ...
      ...
      cog_gp_tr=cog_gp.transformation
      ...
      ...
      ### put into right place ???
      cog_gp.transform!(cog_gp_tr.inverse)
      

      I've seen other things like this and people doing it as a matter of course. To me its like the underware gnomes.

      1. first you get a transformation
      2. then ???
      3. then you get its inverse.

      For the life of me, I can't figure out what it does. The help says there are lots of examples on the interwebs, - greaaat.

      Some help that might make it click in my head would be really appreciated.... like "when you have this, and you want that, then run inverse on it" might do the trick.

      Thanks so much!

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        Say that you create a transformation to move an object:

        t=Geom::Transformation.new([10,20,30])
        (a translation from [0,0,0] to [10,20,30])

        And you then use that to transform an entity:

        group.transform!(t)

        Then you have moved that by a certain distance.

        If you want to move it back to its original position you can use the inverse transformation.

        group.transform!(t.inverse)

        Thomas Thomassen — SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • B Offline
          billwheaton
          last edited by

          Thanks, that's a great help.

          @thomthom said:

          group.transform!(t)

          Then you have moved that by a certain distance.

          If you want to move it back to its original position you can use the inverse transformation.

          group.transform!(t.inverse)

          Ok... so suppose you didn't transform it in the first place what would be inferred by [ruby:1tz432dx]group.transform!(t.inverse) group.transform!(t.inverse) ?

          Because that is what it looks like its doing in the section above. that might be why TIGs got "### put into right place ???" as a comment. I'd have to ask him of course.

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            If you had not moved it in the first place and you'd move it in the opposite direction.

            t=Geom::Transformation.new([10,20,30]) group.transform!(t.inverse)

            This would move the group by the vector -10,-20,-30

            If you had a rotation transformation you'd rotate the other way.

            If you had a transformation that scaled down then the inverse would scale up.

            Thomas Thomassen — SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

            1 Reply Last reply Reply Quote 0
            • K Offline
              kyyu
              last edited by

              @billwheaton said:

              Thanks, that's a great help.

              @thomthom said:

              group.transform!(t)

              Then you have moved that by a certain distance.

              If you want to move it back to its original position you can use the inverse transformation.

              group.transform!(t.inverse)

              Ok... so suppose you didn't transform it in the first place what would be inferred by [ruby:1gvc83k7]group.transform!(t.inverse) group.transform!(t.inverse) ?

              Because that is what it looks like its doing in the section above. that might be why TIGs got "### put into right place ???" as a comment. I'd have to ask him of course.

              I recently had to learn this, myself. So here is my take on this. Maybe it will make more sense with an anlogy to multiplying numbers instead of matrices. So, a matrix inverse is analoguous to the "Multiplicative Inverse of a Number" or also called "Reciprocal".
              http://www.mathwords.com/m/multiplicative_inverse_of_a_number.htm

              If there is no transformation than the transformation matrix is the identity matix (analoguous to the number 1)

              So using this analogy and assuming the tranformation is say 5, we have this equation for what TIG is doing:
              5 * (1/5) = 1

              But if there was never a transformation to begin with, then the equation would just end up like this:
              1 * (1/1) = 1

              -Kwok

              1 Reply Last reply Reply Quote 0
              • M Offline
                MartinRinehart
                last edited by

                The basics of transformation matrices are explained in Appendix T of my tutorial.

                The use of transformation matrices is explained in Chapter 15 of my tutorial.

                Software that lets you move, rotate and scale component instances is explained in Chapter 16 of my tutorial.

                Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

                1 Reply Last reply Reply Quote 0
                • B Offline
                  billwheaton
                  last edited by

                  Thanks Martin. And I read those and they were a great help, but I didn't find much there about what the 'inverse' method does. The way ThomThom describes it, it sounds like an "undo" command.

                  1 Reply Last reply Reply Quote 0
                  • B Offline
                    billwheaton
                    last edited by

                    Good example. I was thinking that in a limited way, but didn't fully appreciate the whole scale and rotation effect too. Good to know.
                    Hm. Seems like threads aren't hierarchical here.

                    1 Reply Last reply Reply Quote 0
                    • Chris FullmerC Offline
                      Chris Fullmer
                      last edited by

                      nope, just linear to keep it simple.

                      Lately you've been tan, suspicious for the winter.
                      All my Plugins I've written

                      1 Reply Last reply Reply Quote 0
                      • M Offline
                        MartinRinehart
                        last edited by

                        @billwheaton said:

                        Thanks Martin. And I read those and they were a great help, but I didn't find much there about what the 'inverse' method does.

                        I've never had occasion to use the inverse() method. I just use my Chapter 16 classes and the Transformation class stays out of my life.

                        Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

                        1 Reply Last reply Reply Quote 0
                        • 1 / 1
                        • First post
                          Last post
                        Buy SketchPlus
                        Buy SUbD
                        Buy WrapR
                        Buy eBook
                        Buy Modelur
                        Buy Vertex Tools
                        Buy SketchCuisine
                        Buy FormFonts

                        Advertisement