sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Scaling Transformation

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 3 Posters 1.0k Views 3 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.
    • J Offline
      Jim
      last edited by

      So apparently applying the following scaling transformation to a Group scales the Group along the world axes, and not the Group's axes. (Shown in wireframe to show Group axes.)

      It just seems scaling along the Group's axes would have been the expected result.

      
      tr = Geom;;Transformation.scaling( 2, 1, 1 )
      group.transform! tr
      
      

      Clipboard01.jpg

      So I need to ask, how do I go about getting the Group to scale 2x along its X axis, regardless of its rotation?

      In answer to my own question, the only solution I found is to create a new transformation, apply the scaling first, then apply the position and rotation transformations of the original Group. There are other ways to order the transformations, but the scaling must be done before the rotation.

      Hi

      1 Reply Last reply Reply Quote 0
      • PixeroP Offline
        Pixero
        last edited by

        Jim, have you looked at my JS_Place3dTexture source? The cpp file here: http://www.pixero.com/files/JS_Place3dTexture.zip
        At the bottom of it there's the order for multiplying the matrices to get it right.

        1 Reply Last reply Reply Quote 0
        • AdamBA Offline
          AdamB
          last edited by

          @jim said:

          So apparently applying the following scaling transformation to a Group scales the Group along the world axes, and not the Group's axes. (Shown in wireframe to show Group axes.)

          It just seems scaling along the Group's axes would have been the expected result.

          
          > tr = Geom;;Transformation.scaling( 2, 1, 1 )
          > group.transform! tr
          > 
          

          [attachment=0:r2ix4t33]<!-- ia0 -->Clipboard01.jpg<!-- ia0 -->[/attachment:r2ix4t33]

          So I need to ask, how do I go about getting the Group to scale 2x along its X axis, regardless of its rotation?

          In answer to my own question, the only solution I found is to create a new transformation, apply the scaling first, then apply the position and rotation transformations of the original Group. There are other ways to order the transformations, but the scaling must be done before the rotation.

          Jim,

          Multiplying 2 matrices together is non-commutative (unlike with regular numbers). ie A * B is not the same as B * A for matrices.

          The transform method does group_matrix * your_matrix , what you want is your_matrix * group_matrix
          So just all you need to do is get the group matrix out multiply it with yours and set it back on the group to ensure you get the order you expect.

          Adam

          Developer of LightUp Click for website

          1 Reply Last reply Reply Quote 0
          • J Offline
            Jim
            last edited by

            Thanks for the help.

            Jan, I haven't looked at your code yet, but I plan to.

            Adam, I tried what you said (at least I think I did,) but ultimately, this is what worked for me: (assume a single Group is selected)

            
            m = Sketchup.active_model
            e = m.active_entities
            s = m.selection
            
            trs = Geom;;Transformation.scaling( 2, 1, 1 )
            s[0].transformation *= trs
            
            

            Which seems counter to what you said?

            Hi

            1 Reply Last reply Reply Quote 0
            • AdamBA Offline
              AdamB
              last edited by

              @jim said:

              Thanks for the help.

              Jan, I haven't looked at your code yet, but I plan to.

              Adam, I tried what you said (at least I think I did,) but ultimately, this is what worked for me: (assume a single Group is selected)

              
              > m = Sketchup.active_model
              > e = m.active_entities
              > s = m.selection
              > 
              > trs = Geom;;Transformation.scaling( 2, 1, 1 )
              > s[0].transformation *= trs
              > 
              

              Which seems counter to what you said?

              It really depends on what the semantics of their * operator is. ie does it pre- or post- concatenate the matrix - but glad you're all sorted either way!

              Developer of LightUp Click for website

              1 Reply Last reply Reply Quote 0
              • J Offline
                Jim
                last edited by

                Just for reference, the following works for scaling along the Group's axis:

                
                m = Sketchup.active_model
                e = m.active_entities
                s = m.selection
                
                tr = s[0].transformation
                trs = Geom;;Transformation.scaling( 2, 1, 1 )
                s[0].transformation = (tr * trs)
                

                but this scales along the global axis:

                s[0].transformation = (trs * tr)
                

                as does this:

                s[0].transform! trs
                

                Hi

                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