We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › Geomerative and vector scaling
Page Index Toggle Pages: 1
Geomerative and vector scaling (Read 904 times)
Geomerative and vector scaling
Apr 15th, 2009, 7:33pm
 
What's the best way to scale an RGeomElem about its own centroid?  I want to scale things without their position changing due to the scaling of the coordinate system.  I can think of a few ways to do it but they all seem too complicated.. Maybe I'm missing the easy way?
Re: Geomerative and vector scaling
Reply #1 - Apr 15th, 2009, 7:55pm
 
Ok I figured it out - there is an easy way.   When the object is scaled (say, smaller), its coordinate system is scaled as well, resulting in a translation of the object.  

So, you need to "undo" this translation by figuring out how far it moved.  It moves the distance equal to its distance from the origin multiplied by the scaling factor.  

So to "undo the scaling translation" simply translate by:

shift=centroid-(centroid*scalingFactor)

or

shiftX=centroidX-(centroidX*scalingFactor)
shiftY=centroidY-(centroidY*scalingFactor)

I guess this is rather obvious but I was being lazy.  Maybe it will help someone else  Cheesy
Page Index Toggle Pages: 1