# Kinect skeleton scaling in 3d space

I am developing a physioterapy system with kinect and need to scale a skeleton size to another skeleton size.

The kinect sensor recognizes 20 body joints, of every joint i have the x, y, and z positions. So, lets say i have the point A(-2, 3, 4) and want to move this point to the location B(4, -5, 2)

Actualy, i am using phytagoras to get the distance between one pairs of the joints of the origin skeleton, and the DestinySkeleton. For example, lets try to scale the points between Head and shoulder center:

howMuchScaleToX = Math.Sqrt(Math.Pow((skToBeScaled.Joints[ShoulderCenter].Position.X - skDestiny.Joints[Head].Position.X), 2)) * -1;
howMuchScaleToY = Math.Sqrt(Math.Pow((skToBeScaled.Joints[ShoulderCenter].Position.Y - skDestiny.Joints[Head].Position.Y), 2)) * -1;
howMuchScaleToZ = Math.Sqrt(Math.Pow((skToBeScaled.Joints[ShoulderCenter].Position.Z - skDestiny.Joints[Head].Position.Z), 2)) * -1;


Now i think i have the distances to scale for each dimension (x, y, z). Now i just add this values to the skeleton to be scaled

skToBeScaled.Joints[Head].Position.X = skToBeScaled.Joints[Head].Position.X + howMuchScaleToX
skToBeScaled.Joints[Head].Position.Y = skToBeScaled.Joints[Head].Position.Y + howMuchScaleToY
skToBeScaled.Joints[Head].Position.Z = skToBeScaled.Joints[Head].Position.Z + howMuchScaleToZ


But this approach are not working

-
Add $(6,-8,-2)$? Scale by $-2$ and then add $(0,1,10)$? There are infinitely many possibilities unless you explain more what you mean. –  alex.jordan Nov 27 '12 at 5:28

## 1 Answer

Usually you would pick one point as the origin and measure all others relative to it. Then to scale, you just multiply all the coordinates by your scaling factor. So if the left foot is your origin, it is at $(0,0,0)$. Then if the original right ankle is at $(1,.2,.1)$ and you scale up by $1.2$ the new right ankle is at $(1.2,.24,.12)$. Is this at all what you mean?

Added: The origin can be where you want it. The factor is how much larger you want the output than the input and is the same for all points. It is like using the enlarge/shrink button on a copy machine. If you use different scale factors for each point, or each coordinate, it will change the shape of the object, which is not usually desired in scaling. You can certainly measure the distance between any pair of points, which will get scaled by the factor, but that just happens by multiplying all the coordinates by the scale factor.

-
Your sugestion seems interesting, my origin point needs to be the HipCenter. Can you show me whats right way to find the mentioned factor? Just find the difference between each dimension (X_origin - X_destiny, Y_origin - Y_destiny and so on) or using phytagoras to find the distance betwenn Origin(x, y, z) and Destiny (x, y, z) ? . –  Ewerton Nov 27 '12 at 14:20
I am not using a unique factor becouse the skeleton are diferent for different persons, so i am trying to keep the body proportions and scaling. Any way, a first version of this algoritm could consider a unique factor. As asked i my previous comment, how about the reight way to calculate this factor? –  Ewerton Nov 27 '12 at 14:51
@Ewerton: If you have measured corresponding points on the two objects, you can find a scale factor for each distance. That scale factor will simply be the ratio of the distances, which you can find from the Pythagorean theorem. It will reflect, for example, that one person's arms are longer relative to their legs than another. You still don't have separate factors in $x,y,z$-the length doesn't change if you bend an elbow, but the coordinates do. –  Ross Millikan Nov 27 '12 at 15:11
Right @Ross Millikan, so, what i need to do to find the factor of each pair of joints is, for example: find the distance between SholderCenter center and Head of the Origin skeleton and find the distance between the ShoulderCenter and Head of the Destination skeleton, dividing this two values will give me the factor right? –  Ewerton Nov 27 '12 at 15:21
@Ewerton: that is right –  Ross Millikan Nov 27 '12 at 15:47