Scale along custom axis
-
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?
-
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... -
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.
-
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 ?
-
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.
-
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'... -
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) -
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.
-
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
-
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 ?
Advertisement