• Login
sketchucation logo sketchucation
  • Login
🔌 Quick Selection | Try Didier Bur's reworked classic extension that supercharges selections in SketchUp Download

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.
  • T Offline
    thomthom
    last edited by 22 Jul 2012, 13:35

    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
    • T Offline
      TIG Moderator
      last edited by 22 Jul 2012, 14:44

      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
      • T Offline
        thomthom
        last edited by 22 Jul 2012, 14:49

        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
        • T Offline
          TIG Moderator
          last edited by 22 Jul 2012, 17:39

          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
          • T Offline
            thomthom
            last edited by 22 Jul 2012, 18:45

            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
            • T Offline
              TIG Moderator
              last edited by 22 Jul 2012, 20:04

              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 7 Jan 2013, 16:34

                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
                • T Offline
                  thomthom
                  last edited by 7 Jan 2013, 18:25

                  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
                  • A Offline
                    AdamB
                    last edited by 10 Jan 2013, 18:28

                    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
                    • D Offline
                      Dan Rathbun
                      last edited by 10 Jan 2013, 19:46

                      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