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

    Scale along custom axis

    Scheduled Pinned Locked Moved Developers' Forum
    10 Posts 5 Posters 1.2k 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.
    • thomthomT Offline
      thomthom
      last edited by

      Is it possible to create a transformation that will scale in 1D or 2D in a direction that doesn't line up with the world axis?

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

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        Isn't that going to distort geometry rather like Fredo's Scale tools ? Skewing boxes etc.
        Or if it doesn't do any 'skewing' then a 'diagonal scaling' would be the like doing two axial scalings combined - which can be calculated from the 'hypotenuse' of the right-angled triangle that the one 'diagonal' scaling factor represents...

        TIG

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

          It's a diagonal stretching - can that be done with a transformation object? Or does one have to calculate each vertex by itself?
          ❓

          I really cannot wrap my head around this.

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

          1 Reply Last reply Reply Quote 0
          • TIGT Offline
            TIG Moderator
            last edited by

            If you do a Scaling Transformation in [say] the X AND Y by factors proportional so that they replicate a single diagonal factor it should work ?

            TIG

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

              hmm.. given that the direction might cross any 3 dimensions I'm not 100% sure how the math there works. What I have so far is using a transformation to transform my points to a local coordinate system, apply scale, then transform back to original coordinate system.

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

              1 Reply Last reply Reply Quote 0
              • TIGT Offline
                TIG Moderator
                last edited by

                Flatten angles to one plane [XY?] (RickW made a method to flatten points to planes and find angles - which you then use in some Trig') and you can work out the proportional Scaling in those two axes.
                Then flatten to the other remaining plane and repeat the scaling.
                So Scaling in all three axes proportionately should give the equivalent of scaling in the 'diagonal'...

                TIG

                1 Reply Last reply Reply Quote 0
                • D Offline
                  dacastror
                  last edited by

                  To do this simply could not use the version of the Pythagorean Theorem in 3d?
                  h² = a² + b² + c²
                  that gives the diagonal of a cube or any parallelepiped of right angles
                  (google translator)

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

                    Not sure how to apply that... :s

                    What I ended up doing, and I forgot to post back, was that I did a combination transformation where I transformed to match origin and axes of the scaling, then apply scale, then transform back.

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

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

                      Just for the record..

                      def scaleAlongVector(v) a = Geom::Vector3d.new(1,0,0) m = Geom::Transformation.new(Geom::Point3d.new, v.cross(a), v.dot(a) ) return m.inverse * Geom::Transformation.scaling(v.length, 1,1) * m end

                      where length of v controls how much scaling

                      Developer of LightUp Click for website

                      1 Reply Last reply Reply Quote 0
                      • Dan RathbunD Offline
                        Dan Rathbun
                        last edited by

                        If that works (and likely it does 'cause it's Adam talking,) can it be moved to the first post, retitled as a snippet topic, and comments inserted explaining WHY it works ?

                        I'm not here much anymore.

                        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