### Modeling the Shoulder

Our goal in modeling the magnet is to be able to find the arm’s position given a magnetometer’s reading. In order to do that, we need to fix the magnet’s position on the arm. This will limit the total possible positions in which the magnet can be located, and it will allow us to locate the position of the arm given a magnets position. First, we will model the magnet’s range of motion on the shoulder. Then, we will combine that with the magnetometer’s position and the magnetic field produced by the magnet to localize the magnet on the arm and to identify the position of the shoulder joint.

For modeling the magnet’s position relative to the shoulder, we will define the origin as the center of the rotator cuff, so that when the arm moves, the origin is the center of rotation. A person will face in the positive *y* direction, the *z* axis will be the vertical axis, and the *x* axis will run in parallel with the shoulders, with the positive *x* direction being away from the shoulder. We will place the magnet on the humerus, right below the deltoid, and define the position of the magnet as *m* with *m’* being the unit vector in the magnet’s direction, and *d* being the distance between the magnet and the center of the rotator cuff. For our model, we will assume that the magnet is always facing perpendicular to the humorous, and that it is always equidistant from the center of the rotator cuff. While these assumptions may not hold true, the model can be adjusted later to correct for any errors.

In order to model the shoulder, we will use a rotational coordinate system as pictured in the diagram above. Yaw, rotation around the z axis, or moving the arm forward and back at a constant height will be denoted as Ψ, with Ψ = 0 in the direction of the positive *x* axis, with a positive Ψ in the forward direction. Pitch, the angle formed by the arm and the positive *z *axis, that measures movement of the arm up and down will be denoted by Θ. Roll, rotation around the *x* axis, or twisting your arm will be denoted by φ, with positive φ being forward rotation. We can model the magnet’s location by the following equations of a sphere of radius *d*, where *m _{x}*,

*m*

*, and m*

_{y}_{z}are the

*x,y*and

*z*coordinates of the magnet respectively because of the assumption that the magnet is always equidistant from the center of the rotator cuff.

To model V* _{m}*, the unit vector in the direction that the magnet is pointing, we will start by modeling the V

*, the unit vector in the direction that the magnet is pointing where φ = 0. Then, we will rotate it around the position vector to model change in φ . We know that V*

_{m0}*is the same as the position vector at Θ – π/2 because the magnet is rotated π/2 rad in the Θ direction from the position vector. Thus the following equations indicate the magnet’s direction such that φ = 0, where V*

_{m0}*, V*

_{m0x}*, and V*

_{m0y}*are the vector components of V*

_{m0z}*in the*

_{m0}*x, y,*and

*z*directions respectively.

Next, to rotate V* _{m0}* in the φ direction, we need to rotate it around the position vector. Based on Rodrigues’ Rotation Formula, we can express V

*= V*

_{m}** cos(φ) + (V*

_{m0}*×*

_{m0}*m*‘) * sin(φ) . The following equations indicate the magnet’s direction after being rotated φ rad, where V

*, V*

_{mx}*, and V*

_{my}*are the vector components of V*

_{mz}*in the*

_{m}*x, y*, and z directions respectively.

Now that we have modeled the magnet’s position and orientation on the shoulder, we can model it’s effect on the magnetometer at any shoulder location. The coordinate system will remain the same for modeling the magnetic field as for modeling the position and orientation of the magnet. The magnetometer will be located on the shoulder blade, right below the spine of the scapula and will be denoted as *t*. We will have three vectors as shown in the diagram to the right, V* _{m}*, the vector in which the magnet is facing, V

*, the vector from the magnet to the magnetometer, and V*

_{r}*the vector orthogonal to V*

_{p}*in the plane formed by V*

_{r}*and V*

_{m}*.*

_{r}We will make an assumption that the magnet is at a far enough distance from the magnetometer such that the magnet can be treated as a dipole, thus the shape of the magnet does not affect *B*, the magnetic field read by the magnetometer. Based on the magnetic field created by a dipole, we can model the magnetic field by finding it’s components in the V* _{t}* and V

*directions B*

_{p}*and B*

_{r }*respectively . In the following equations*

_{Θ}**m**is the magnetic moment constant, Θ

*is the angle between the magnet, and*

_{m}*r*is the distance between the magnet and the magnetometer.

To find Θ

*and*

_{m}*r*we will first define V

*, which is the vector from the magnet to the magnetometer by the following equation.*

_{r}Next, we can find the Θ

*, by using the dot product, where V*

_{m}*• V*

_{r}*= |V*

_{m}*| •|V*

_{m}*| • cos(Θ*

_{r}*) , thus we can express*

_{m}*r*and Θ

*as with the following equations.*

_{m}Lastly, we need to calculate V* _{p}*. We can do that by projecting V

*onto V*

_{m}*, and subtracting that projection from V*

_{t}*, where the projection of V*

_{m}*onto V*

_{m }*can be expressed as V*

_{t}*• (V*

_{t}*• V*

_{m}*)/(V*

_{t}*• V*

_{t }*). This leaves us with the component of V*

_{t}*that is perpendicular to V*

_{m}*, however, since we want V*

_{t}*directed away from direction of V*

_{p}*, we will find its inverse. Knowing V*

_{m}*and V*

_{r}*we can calculate V*

_{m}*, a vector perpendicular to V*

_{p}*in the field formed by V*

_{r}*and V*

_{r}*by the following equation.*

_{m}Lastly, we will multiply B* _{r}* and B

*by the unit vectors of V*

_{Θ}*and V*

_{r}*to find the component vectors of the*

_{p}*B*, the magnetic field read by the magnetometer, and combine them to find

*B*.

Using the magnetometer’s readings as input, we can find the Ψ, Θ, and φ, such that the calculated *B* equals the magnetic field read by the magnetometer. This lets us identify the position of the arm, and the position of the magnet.

One issue that arises with this model is that for every magnetic field, there exist two locations that will produce the same magnetometer reading. If we fix φ to equal 0, such that the shoulder does not rotate, then we only get one solution, however, this limits the model significantly. On the other hand, if we know a previous position of the shoulder and the motion of the arm, we would be able to choose between the two solutions to identify the position of the arm.

With this model in place, the next step would be to apply the model to the real world. I will need to figure out how to exclude the earths magnetic field from the magnetometer’s reading, how to remove noise from the magnetometer moving when the shoulder moves, and how to fix the location of the magnetometer on the shoulder to know where the magnetic field is being measured.