Reach with Maths
A robot arm has two joints. Drag the red dot and the arm works out how to bend to reach it, using only triangle maths.
Drag the red dot. I use a triangle trick to find the joint angles. There are usually two ways to reach, elbow down or up. Can you spot them?
The arm
chosen poseother posestar to collectproblem
Challenges
Collect 3 stars: move the hand onto each yellow star.
Two ways: reach a target, then flip the elbow to see the other pose.
Out of reach: drag the target farther than the arm can stretch (or too close to the shoulder).
Limits bite: turn joint limits on so only one of the two poses is allowed. Try targets where the arm is almost stretched out.
Forward mode: switch to Turn joints and collect a star using only the two sliders.
What just happened?
- Forward kinematics goes from joint angles to hand position. It is just a bit of trigonometry.
- Inverse kinematics goes backwards, from a target to angles. The law of cosines on the arm triangle gives the answer directly.
- Most reachable targets have two solutions: elbow down and elbow up, mirror images of each other.
- Targets farther than both links stretched, or closer than their difference, have no solution at all.
- Real joints cannot spin freely, so limits can rule out one of the two solutions.
For grown-ups: what's really going on
Two links of length l1 = 100 and l2 = 70. Forward kinematics: x = l1 cos θ1 + l2 cos(θ1+θ2), y = l1 sin θ1 + l2 sin(θ1+θ2).
- Analytic inverse kinematics:
cos θ2 = (x² + y² − l1² − l2²) / (2 l1 l2), soθ2 = ± arccos(·)(the two elbow configurations). Thenθ1 = atan2(y, x) − atan2(l2 sin θ2, l1 + l2 cos θ2). - The workspace is an annulus: reachable when
|l1 − l2| ≤ √(x²+y²) ≤ l1 + l2. On the boundary the two solutions merge (a singularity). - Joint limits select among the analytic solutions. Arms with more joints than needed are redundant and have infinitely many solutions, so numerical methods (the Jacobian) are used.
- This is classical control geometry, not learning. The games chapter shows how a learned controller can do a similar job without being given the formulas.
Further reading: Craig, Introduction to Robotics, ch. 3 · Lynch and Park, Modern Robotics, ch. 6.