|
Written by Ryan Juckett
|
|
Monday, 29 December 2008 07:46 |
|
Page 6 of 8
Solving for θ2
Our first step will be solving for . In order to do this, we need to cancel out of our equations. By squaring and adding the equations for and , we can use the Pythagorean trigonometric identity to cancel out terms.
First off, lets square the equations.
 \quad + \quad 2 d_1 d_2 \cos (\theta_1) \cos(\theta_1 + \theta_2) \quad + \quad d_2^2 \cos^2(\theta_1 + \theta_2))
 \quad + \quad 2 d_1 d_2 \sin (\theta_1) \sin(\theta_1 + \theta_2) \quad + \quad d_2^2 \sin^2(\theta_1 + \theta_2))
Add the squared equations together.
 \quad+ \quad \cos^2(\theta_1)\Big)\\ \qquad\qquad\qquad\qquad\qquad\qquad + \quad 2 d_1 d_2 \Big(\sin(\theta_1) \sin(\theta_1 + \theta_2) \quad+ \quad \cos(\theta_1) \cos(\theta_1 + \theta_2)\Big)\\ \qquad\qquad\qquad\qquad\qquad\qquad + \quad d_2^2 \Big(\sin^2(\theta_1 + \theta_2) \quad + \quad \cos^2(\theta_1 + \theta_2)\Big))
Using Pythagorean trigonometric identity, simplify the and terms.
 \sin(\theta_1 + \theta_2) \quad+ \quad \cos(\theta_1) \cos(\theta_1 + \theta_2)\Big))
Using the angle sum and difference identities for cosine and sine, expand and .
 ( \sin \theta_1 \cos \theta_2 + \cos \theta_1 \sin \theta_2 ) + \cos(\theta_1) ( \cos \theta_1 \cos \theta_2 - \sin \theta_1 \sin \theta_2) \Big))
Distribute the and terms.
 \cos \theta_2 + \cos \theta_1 \sin \theta_1 \sin \theta_2 + \cos^2(\theta_1) \cos \theta_2 - \cos \theta_1 \sin \theta_1 \sin \theta_2 \Big))
The positive and negative terms cancel each other out, and we can factor out of the remaining terms.
 + \cos^2(\theta_1)) \cos \theta_2 \Big))
Use the Pythagorean trigonometric identity to simplify.

Solve for .


We now have our analytic equation for , but there are a few nuances to discuss in more detail.
- If
is not within the range [-1,1], it is outside of the domain. This will happen when our target point is a location the bones cannot reach. A value of -1 will give us an angle of 180° (i.e. bone2 is fully bent) and a value of 1 will give us an angle of 0° (i.e. bone2 is fully extended). When the value is less than -1, our bone is trying to bend father than is physically possible to reach a point that is too close to the origin. When the value is greater than 1, our bone is trying to extend farther than is physically possible to reach a point that is too far from the origin. This means that we can compute the best non-valid solution by clamping the value into the legal [-1,1] range.
- If
or is zero, we will divide by zero when computing . When one or both bones have a zero length, we can set to any value we desire (I suggest zero or the value used on a previous frame). When we solve for it will correct itself according to our selected . The solvable domain for this case has also been reduced to a single circle centered at the origin with a radius of .
- When we can evaluate
, our result is limited to the range . If we use the result as is, we will always find the solution where our second bone turns in the positive direction. If it is our intention to find the solution that bends in the negative direction, we need to negate the new .
|
|
Last Updated ( Sunday, 02 May 2010 06:32 )
|