# Difference in shape, LxWxH, most similar proportions, regardless of scale

1. Jan 30, 2013

### xinlo

this is not actually for homework, I am no longer in school, this is for a small application I am trying to write that compares dimensions. However, I believe this is the appropriate spot to post after reading the rules.

1. The problem statement, all variables and given/known data

okay, so lets say you got a shape, for example a rectangular prism.

192 x 210 x 212.

Then you have a list of other shapes and their dimensions

191,209,210
188,208,209
185,207,208
197,204,207
199,211,214

How would you pick the one that most closely matches the proportions of the original shape? scale does not matter, only proportions

2. Relevant equations

when its two dimensions its much simpler, you could just divide the length/width and pick the number closest to the result of the original.

3. The attempt at a solution

At first I had the idea of dividing the length/width and the length by the height seperately, figure the difference from the original shape, and then add those two differences together. The problem with this method is you can get large differences that are opposites, one positive and one negative that cancel each other out close to 0.

I don't need a solution to the above numbers, those numbers are just examples, I am just wanting to know what equation you would use to solve this type of problem.

Last edited: Jan 30, 2013
2. Jan 30, 2013

### cepheid

Staff Emeritus
Welcome to PF xinlo!

Thanks for actually reading the site rules! You have posted in the right place.

Hmm...the first thought that comes to mind is: try using the RMS difference.

3. Jan 30, 2013

### xinlo

Model rectangular prism LxWxH: 192 x 210 x 212

various rectangular prisms L,W,H
186,205,204
186,206,205
188,210,206
191,209,210
188,208,209
185,207,208
197,204,207
199,211,214
210,192,212 (should be farthest from a match)
384,420,424 (should be perfect match)

In the above data set I added one with the same dimensions but in a different order, also a couple where the width is greater than the height.
so my solving method should show those value as the least similar.
I also added one that has the exact same dimensions as the original only double, it should return the closest match.(perfect match)

below is how I did it, if I am reading wikipedia correctly: http://en.wikipedia.org/wiki/Root_mean_square

This is how I did it =SQRT(1/3(192^2+210^2+212^2))
(and then do the above for the other sets of dimensions and see which is closest.)

This RMS method would actually work perfectly it seems, if all data in the different sets is always L<W<H.

Also I realize when I originally asked the question, the data set I provided, this solution would have worked.

4. Jan 30, 2013

### Staff: Mentor

You want to find the one that is closest to being geometrically similar. Here's an idea. First write the dimensions of all the prisms in ascending order. Then let the three numbers be the three components of a vector from the origin. Divide each of the choices by the magnitude of the vector to get a unit vector. Then take the dot products of all the unit vectors with the unit vector for the subject shape. The one giving the dot product closest to unity is the one closest to being geometrically similar.

5. Jan 30, 2013

### xinlo

I ended up using the first suggestion, it ended up working perfectly, I just wasn't doing it correctly, given all objects have to remain facing the same direction (length cannot be swapped out for width.)

and then for y just plug in all other sets of numbers and the smallest value is the closest match.

=SQRT((x0/x2-y0/y2)^2 + (x1/x2-y1/y2)^2 + (x2/x2-y2/y2)^2)

x0,x1,x2 = 192,210,212 = 0
--------------------------------------------
y0,y1,y2 = 384,420,424 = 0
y0,y1,y2 = 191,209,210 = 0.006062527
y0,y1,y2 = 188,208,209 = 0.007700726
y0,y1,y2 = 186,206,205 = 0.014407578
y0,y1,y2 = 186,205,204 = 0.015581448
y0,y1,y2 = 185,207,208 = 0.016883492
y0,y1,y2 = 199,211,214 = 0.024675823
y0,y1,y2 = 188,210,206 = 0.029679298
y0,y1,y2 = 197,204,207 = 0.046307593
y0,y1,y2 = 210,192,212 = 0.120074736

Thank you both very much for the help :)

Last edited: Jan 31, 2013