# Can I define a plane given 2 points in xyz coordinates as well as roll angle about that vector?

I am working on a complex motion analysis, trying to calculate wrist angles in 3 dimensions. I have sensors placed as this diagram depicts

and need both flexion/extension angles as well as radial/ulnar deviation angles. The sensors provide xyz coordinates as well as yaw, pitch & roll angles in degrees.

The problem is, the forearm is unconstrained and can rotate freely so the reference plane is constantly changing. I would like to define a plane based on the vector formed by sensors 2 & 3 and the roll angle about that vector (sensors 2 & 3 are mounted to a plate so they should automatically be in the same plane). I would then like to project the point at sensor 1 onto the plane defined in the previous step in order to find the radio-ulnar deviation angles as separate from flexion/extension. Is this possible or do I need a 3rd point on the arm in order to define the plane of the forearm?

I currently have the flexion/extension angle calculated as the arccosine of the dot product of the 2 vectors. See image with my formula in the bar at top

Is this part correct?

Thank you for any suggestions or guidance you can provide.

-
Two things you can do to increase the likelyhood of useful answers: 1. You could be more specific about these measured rotation angles: what exactly do they measure, in what order, with what frame of reference? 2. You could copy that Excel data and paste it (here or in some pastebin), preferrably as comma-separated values. Then people could use your numbers to develop, test and explain their formulas. – MvG Jan 5 '14 at 19:44

You can't distinguish flexion/extension from radio-ulnar deviation unless you can calibrate your setup somehow. You can easily convert coordinates to some reference system which moves with the plate on which sensors 2 and 3 are mounted, but you don't know the plane of that plate a priori. The arccos computation you describe would be the total angle between the two lines, which includes both the angles you are looking for.

If you can calibrate the system, then you can use the following approach: Given yaw/pitch/roll of sensor 2 or sensor 3, find a rotation matrix which undoes these rotations, or in other terms a change of coordinates to the reference frame of this sensor. The exact way to form that rotation matrix depends on the order and reference frame of your rotation angles, there are various conflicting conventions so you have to see which numbers your devices actually report. For a rotation matrix, the inverse is simply the transpose, so inverting that matrix is cheap. Since both sensors are mounted on the same plate, they should only be able to rotate together, so it doesn't matter which of the two rotations you take, since the results should only differ by some constant rotation anyway. I intend to use this to orient the reference coordinate system, and I'll not be using the rotations of sensor 1 at all.

In the next step, take the difference vectors from 2 to 1 resp. from 2 to 3. These are the positions in a reference frame which has sensor 2 at the origin. Apply the rotation-undoing matrix from the previous paragraph, and you obtain a reference frame in which the plane of your forarm plate has a fixed position.

What that position is you'll have to find out during calibration. There are two important planes, corresponding to your two different angles. These two planes are orthogonal to one another, and both contain the line joining sensors 2 and 3 (or more precisely the arm below those sensors). Move the hand in one direction, and you know your planes with respect to this reference frame. Knowing a plane through the origin can often best be described by writing down its normal vector. And computing a vector normal to two given vectors is easiest done using the cross product. For later use, it makes sense to normalize these normal vectors to unit length.

Now you want to track motion. For every frame of your data, do the above translation and rotation to get to a coordinate system fixed with respect to the forearm. Then compute the dot product between the vector pointing at sensor 1, normalized to unit length, and the unit length normal vector of one of your planes. The result will be the sine of the angle that the line joining sensors 1 and 2 makes with the plane. Doing so for two planes will give you the two angles you're asking about.

Mathematicians tend to write things down in two dimensions, or using rather abstract notation. Neither is readily available for you in Excel. So I suggest you do the computation symbolically on a sheet of paper, and give every variable of every intermediate step a unique name. This will mean nine names for a rotation matrix, three for a vector, and so on. Once you have worked out all the formulas, you can assign those names to the columns in your Excel table, and write the formula for every single number in a single row. That you can then copy to the other rows.

-
Thanks for the response. When you say calibrate my system, what do you mean? I have a (0,0,0) at the "source unit" (this is an electromagnetic tracking system). How would I convert my coordinates to a reference system which moves with the sensor 2/3 plate? – MsHF Jan 5 '14 at 15:07
When you say a "rotation matrix that undoes these rotations" do you mean that I simply back these values out of each sensor? Also, thank you for confirming that the angle I've calculated is a combination of both movements. – MsHF Jan 5 '14 at 15:14
By “calibrate” I mean you'd move the hand up (maximize flexion) with zero deviation, then tell the system “these three points span the flexion plane, the plane through sensors 2 and 3 which is orthogonal to that is the deviation plane.” After that you know which plane is which, and as long as you can keep track of your reference frame you can also compute the angles you need. Wrt. the second part of the first comment, have you read the Wikipedia links I included? If so, what aspect of that is unlear? I wouldn't want to write this in Excel, but that's a matter of taste. – MvG Jan 5 '14 at 15:15
I have zero experience with rotation matrices (in fact, I'm learning all of this linear algebra as I go) so I'm a bit overwhelmed by the wiki page. I'm still looking for additional sources to learn from (Khan academy doesn't seem to cover rotation matrix). As for writing this in Excel, I am open to your suggestions, although anything would likely involve me learning new software. – MsHF Jan 5 '14 at 18:45
Would it make things easier if I had a 3rd sensor on the forearm to establish a reference plane without all these transformations? – MsHF Jan 5 '14 at 18:51