# Model of a rotary joint driven by a linear motor [Part 2]

## Angle as a function of length

Let's calculate the angle $$\alpha$$ as a function of the motor length $$| \overrightarrow{AB} |$$.

Let's start by calculating the length $$| \overrightarrow{AC} |$$. Since the triangle $$ABC$$ is rectangle in $$B$$, let's write the Pythagorean theorem:

$$| \overrightarrow{AC} |^2 = | \overrightarrow{BC} |^2 + | \overrightarrow{BA} |^2$$

To get the rotation angle of the joint ($$\alpha$$), let use the law of cosines in the triangle $$OAC$$:

$$| \overrightarrow{AC} |^2 = | \overrightarrow{OA} |^2 + | \overrightarrow{OC} |^2 - 2 | \overrightarrow{OA} | | \overrightarrow{OC} | \cos(\alpha)$$

Let's replace $$| \overrightarrow{AC} |^2$$ by the previous equation:

$$| \overrightarrow{BC} |^2 + | \overrightarrow{BA} |^2 = | \overrightarrow{OA} |^2 + | \overrightarrow{OC} |^2 - 2 | \overrightarrow{OA} | | \overrightarrow{OC} | \cos(\alpha)$$

We can rewrite this equation:

$$\cos(\alpha) = \dfrac{| \overrightarrow{OA} |^2 + | \overrightarrow{OC} |^2 - | \overrightarrow{BC} |^2 - | \overrightarrow{BA} |^2 }{2 | \overrightarrow{OA} | | \overrightarrow{OC} |}$$

The angle $$\alpha$$ is given by:

$$\alpha = \arccos \left( \dfrac{| \overrightarrow{OA} |^2 + | \overrightarrow{OC} |^2 - | \overrightarrow{BC} |^2 - | \overrightarrow{BA} |^2 }{2 | \overrightarrow{OA} | | \overrightarrow{OC} ) |} \right)$$