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

Can you adjust the "strength" of a transformation?

Scheduled Pinned Locked Moved Developers' Forum
8 Posts 3 Posters 271 Views
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.
  • T Offline
    thomthom
    last edited by 8 Apr 2012, 18:00

    Say that you have a method that accepts a Transformation object. The type of transformation is unknown, it could be move, scale, rotate etc.

    Can you adjust the "strength" or magnitude of the transformation's effect? So if the given transformation was a scaling transformation of 200% in the Y axis you could make it n% of the input transformation? Can you weaken or strengthen an arbitrary transformation without knowing if it's scaling, rotating, translating or a combination?

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

    1 Reply Last reply Reply Quote 0
    • T Offline
      TIG Moderator
      last edited by 8 Apr 2012, 18:07

      Hardly... unless you already know the transformation type/factors ?
      Then 'interpolate' ??

      You can perhaps extract the rotation, scaling etc and make a 'new' transformation based on it ?

      If you make a scaling transformation 'trs' at say 1% then trstrs is 2%
      Or A rotation 'trr' at 1 degree, then trr
      trr is 2 degrees etc...
      or
      tr0=Geom::Transformation.new()
      trn=Geom::Transformation.interpolate(tr0, trs, 0.5)
      should return a scaling transformation 'half' of the original 'trs' ?
      BUT I don't think
      trn=Geom::Transformation.interpolate(tr0, trs, 2.0)
      will work for 'twice'... 😕

      TIG

      1 Reply Last reply Reply Quote 0
      • A Offline
        Aerilius
        last edited by 9 Apr 2012, 10:22

        Shouldn't it be possible by interpolating the transformation with an identity transformation?

        I did a quick test, but the API method Transformation.interpolate didn't work for me, so I wrote my own
        **```
        def interpolate(t1,t2,percent);a=t1.to_a;b=t2.to_a;c=[];16.times{|i| c[i]=percent*a[i]+(100-percent)*b[i]};return Geom;;Transformation.new(c);end

        ![transformations.jpg](/uploads/imported_attachments/hr97_transformations.jpg)
        1 Reply Last reply Reply Quote 0
        • T Offline
          TIG Moderator
          last edited by 9 Apr 2012, 11:03

          This is a clever way to interpolate all values but if you just want to interpolate the rotation it will also scale etc ?
          If the base tr is un-scaled 1,1,1 and the second tr is scaled in the X -1,1,1 - then won't it try to use an invalid scaling factor of 0,1,1 for the interpolation of '50%' ? 😕

          TIG

          1 Reply Last reply Reply Quote 0
          • T Offline
            thomthom
            last edited by 8 Jun 2012, 09:13

            I´m writing a small utility to visualize transformations to aid me understand what is going on. I can´t manage to visualize what will happen because I don´t have enough understanding of the matrix.

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

            1 Reply Last reply Reply Quote 0
            • T Offline
              thomthom
              last edited by 9 Jul 2012, 16:27

              @tig said:

              You can perhaps extract the rotation, scaling etc and make a 'new' transformation based on it ?

              You mean extract the rotation, scaling and translation to separate transformation - apply the wanted "strength" and then combine them?

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

              1 Reply Last reply Reply Quote 0
              • T Offline
                thomthom
                last edited by 9 Jul 2012, 17:56

                Just to clarify, all transformations are either move, scale, rotate - but I do not know what it is. And the transformation all have a custom origin - so rotation is around a given 3d point and axis and scale is around a 3d point.

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

                1 Reply Last reply Reply Quote 0
                • T Offline
                  TIG Moderator
                  last edited by 9 Jul 2012, 19:48

                  The object's 'position' is relatively easy to find - it's just the t=object.transformation.to_a for the xyx point as an array of the last few elements thus: point=[t[-4],t[-3],t[-2]]... OR transformation.origin !
                  The transformation's scale and rotation interact with each other, so they are much more complex to extract from the transformation array... but not impossible - there are already some earlier post discussing this...

                  TIG

                  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