Link to home
Start Free TrialLog in
Avatar of Damian Franco
Damian Franco

asked on

Uniformly scaled a cuboid to fit inside another cuboid

Hello,
Lets say I have a cuboid V with any dimension (width, height, depth)
and I have another cuboid M again with any dimension  (width, height, depth)

I have to scale down or up cuboid M to fit inside cuboid V

Right now I am finding the largest dimension of cuboid M and scaling it to fit the smallest dimension of cuboid V

VSize = [v.width, v.height, v.depth];
MSize   = [m.width, m.height, m.depth];

largestMSize = calculateLargestSize(MSize)
smallestVSize = calculateSmallestSize(VSize);

scaleRatio = smallestVSize/largestMSize

I think this will guarantee cuboid M will fit inside cuboid V - BUT this is too extreme

Do you know of a way to calculate the correct scale for cuboid M to fit inside cuboid V?
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Damian Franco
Damian Franco

ASKER

This would work if M is bigger than V (ratio < 1)

How about if M is smaller than V? (ratio > 1)

How about if M is smaller than V AND one side of M is smaller than V but the other side of M is bigger than V?

What do we do?

THANKS!
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks!