# How to calculate the abduction and flexion angle from 3D co-ordinates of shoulder and elbow

I am using a "Microsoft Kinect for Windows" to track the $x$, $y$, and $z$ positions of my Shoulder, Elbow, Wrist, and Hand. Each position is normalised to my shoulder so that my shoulder is always at $[1,1,1]$, and other points are relative.

The output of this program is a $3$ by $4$ matrix, in the form:

$$\begin{bmatrix} Sx & Ex & Wx & Hx \\ Sy & Ey & Wy & Hy \\ Sz & Ez & Wz & Hz \\ \end{bmatrix}$$

From this I want to calculate the abduction and flexion angle between the shoulder and elbow.The abduction and flexion motions are shown below. How would I do this?

The co-ordinate system:

My Attempt So Far

To calculate the abduction angle, I used the dot product formula referenced against a unit vector pointing down, defined as zero degrees:

$$\theta=\cos^{-1}\frac{ \begin{bmatrix} 1\\ 0 \end{bmatrix}\cdot \begin{bmatrix} Ez\\ Ey \end{bmatrix} } { |\begin{bmatrix} 1\\ 0 \end{bmatrix}| |\begin{bmatrix} Ez\\ Ey \end{bmatrix}| }$$

But this gives a value of $30$ degrees when my arm is straight down (it should be zero), and it increases to $45$ degrees when my arm is straight up (it should be 180).

What equation should I actually be using?

If the coordinate of the shoulder joint is normalized to $(1,1,1)$, then the calculation of the angle of the shoulder-to-elbow rotation must be done relative to this point--that is to say, you must translate all the coordinates so that the shoulder joint is at the origin.
If the diagram with the person has the axes in correct orientation, then "down" would be the vector $$-\hat j = (0,-1,0)$$ and the rotation would be computed by the dot product $$(-\hat j) \cdot (\vec E - \vec S) = (0,-1,0) \cdot (E_x - 1, E_y - 1, E_z - 1)$$ with the angle given by $$\theta = \cos^{-1} \frac{1 - E_y}{\sqrt{(E_x - 1)^2 + (E_y - 1)^2 + (E_z - 1)^2}}.$$ This gives the rotation angle as measured in the plane of motion. To find the the component angles which are the projection of the above angle in the $xy$- and $yz$-planes, you would eliminate in the denominator the $z$- and $x$-coordinate contributions, respectively.
• Thanks for your answer. Wouldn't "down" be the vector $(1,0,1)$, since the origin in this example is at $(1,1,1)$? Also, I should clarify: in the matrix of positions, all of the points have already been normalised to the shoulder, so they have already had $S_x$, $S_y$, and $S_z$ taken away from them. – Blue7 Feb 24 '15 at 22:58
• " they have already had $S_x$ , $S_y$ , and $S_z$ taken away from them". This is still unclear sorry. What I'm tryimg to say is that the shoulder is at $(1,1,1)$, and all of the other joints positions are relative to the shoulder. So if my arm is at the same angle and I walk around the room, all the points will stay at the same angle, because they are relative to my shoulder. – Blue7 Feb 25 '15 at 10:17