# Efficient algorithm for mesh scale adjustment based on the scale of another mesh

I have a mesh (Mesh-A) with a bounding box of some arbitrary size defined by X,Y,Z scale. In runtime I import another mesh (Mesh-B),which has an overall topology similar to the Mesh-A, but it can have a different default scale. I am looking for an efficient algorithm to rescale the Mesh-B to have the new scale equal to the Mesh-A,which basically means - their bounding boxes are of similar sizes. The naive approach would be to run for... loop, scaling the Mesh-B transform,till its BB has an approximate size equal to that of the Mesh-B's BB. I would like to learn other approaches.

• Scaling by BB does not seem a very fruitful way to do anything. I mean a elephant does not have the same BB as a human. Ideally youd have some feature you can relate. Sep 11 at 13:34

Scaling is linear, so you can do this in one step rather than iteratively. If you have two vector values sizeA and sizeB for the sizes of the two meshes’ bounding boxes, the vector value you should scale mesh B by is sizeA / sizeB. If you want to scale it uniformly, you’ll need to pick a single scalar value; one way to do that would be to average the ratios of each component, i.e. (sizeA.x / sizeB.x + sizeA.y / sizeB.y + sizeA.z / sizeB.z) / 3.