01 / THE ARM
Drag the target.
Drag the target · drag space to orbit · scroll to zoom
REACH A POINT IN SPACE
A turning base, a shoulder and an elbow. Move the target and the arm solves its own joint angles. Then find out why some points have two answers, some have none, and some are easy to reach but not safe.
01 / THE ARM
Drag the target · drag space to orbit · scroll to zoom
02 / THE DIAGRAM
Drawn to scale in the vertical plane that faces the target. Drag anywhere on it, or tab to the target and use the arrow keys.
WHAT’S HAPPENING
TRY THIS
One plane at a time. The base turns to the target’s direction, yaw = atan2(z, x). After that the shoulder and elbow only have to reach a point in a flat vertical plane: u = √(x² + z²) out and y up.
The elbow sets the distance. The upper arm (l1), the forearm (l2) and the line from shoulder to target (r) make a triangle. The law of cosines gives the elbow angle: cos q2 = (r² − l1² − l2²) / (2·l1·l2). It has two answers, +q2 and −q2. These are elbow down and elbow up.
The shoulder sets the direction. q1 = atan2(y, u) − atan2(l2·sin q2, l1 + l2·cos q2). This tilts the bent arm so the tip lands on the target.
Reach. The triangle only exists when |l1 − l2| ≤ r ≤ l1 + l2. Further than that, no elbow angle works. Closer than |l1 − l2|, the arm cannot fold tight enough. That is the hole in the middle.
Motion. Each joint closes the same fraction of its remaining gap every instant, 1 − e^(−3·dt). That makes a straight line on the joint map. It is not a straight line for the tip. If there is no answer, or the answer is past a joint limit, the arm stays where it is.
The floor (this page’s rule). The model has no floor, so the page adds one, 0.405 m below the shoulder. No part of the arm may go below it. The links are checked at the width of the 3D covers: 0.25 m around the upper arm and elbow, 0.19 m around the forearm and wrist. If the chosen elbow would hit the floor and the other one is clear, the arm uses the other one and says so. If both would, it stops at the closest pose that stays above the floor and shows how far short it is. Before each move the page samples the straight joint path; if it would dip into the floor, the arm goes round on a safe path instead.
Contact. Each link is treated as a rod 7.5 cm in radius. The pose touches the obstacle when either rod comes closer to its centre than radius + 0.075 m. The page samples this 60 times per model second during a move, so it can show contact on the way as well as at the end.
Near full stretch the elbow angle changes fastest with distance: |dq2/dr| = r / (l1·l2·|sin q2|). At full stretch sin q2 = 0, so no joint motion can push the tip further out. Engineers call this a singularity.
The model notes are in RESEARCH.md. Related labs: Chain Reaction Builder and Motion Design Playground.