# How scaling a model changes its volume

Hi to all,

When changing an object’s scale, what is the corresponding value it’s volume would change by? For instance:

model.setScale(2)

tightBounds=model.getTightBounds()
xDim=tightBounds[1].x-tightBounds[0].x
yDim=tightBounds[1].y-tightBounds[0].y
zDim=tightBounds[1].z-tightBounds[0].z
currentVolume=xDim*yDim*zDim

model.setScale(3)

tightBounds=model.getTightBounds()
xDim=tightBounds[1].x-tightBounds[0].x
yDim=tightBounds[1].y-tightBounds[0].y
zDim=tightBounds[1].z-tightBounds[0].z
newVolume=xDim*yDim*zDim



So the volume would have increased by a certain amount. Is there a formula to tell what increase in volume an increase in scale would cause? Such that if I wanted an increase in volume by 5, I would increase the scale by x to get that desired volume-increase? I’m presently just using a while-loop to achieve this, though I’m wondering if there’s a “cleaner” way to achieve the same. If my question is unclear anywhere, ask and I’ll clarify.

If you scale any shape uniformly by a factor x, its volume increases by x^3. So if you want to increase the volume to y times the original volume, you should scale it by a factor of \sqrt[3]{y}.

Okay, I get it, because there’s 3 dimensions in question.
So if I wanted all models in my world to occupy a volume of about 250, scaling them up or down, I’d do it this way:

tightBounds=model.getTightBounds()
boundDimensions=tightBounds[1]-tightBounds[0]
currentVolume=boundDimensions.x*boundDimensions.y*boundDimensions.z
volumeChange=currentVolume/250.0
distributedDimensionChange=volumeChange**(1.0/3)
newScale=model.getScale()/distributedDimensionChange
model.setScale(newScale)


I tested it and it works in practice. Thanks rdb.