Forward and inverse kinematics
Also available in: Català · Castellano
Forward kinematics (FK)
Two-link arm:
x = L1·cosθ1 + L2·cos(θ1+θ2)y = L1·sinθ1 + L2·sin(θ1+θ2)
Each link adds its vector, rotated by all the previous angles.
Inverse kinematics (IK)
You know where you want the hand and look for the angles. For two links there is a closed-form formula (law of cosines):
cosθ2 = (x² + y² − L1² − L2²) / (2·L1·L2)θ1 = atan2(y, x) − atan2(L2·sinθ2, L1 + L2·cosθ2)
Solutions: two (elbow up and down, the sign of θ2), one at the edge of the reach, none outside. The reach goes from |L1 − L2| to L1 + L2; outside it, the cosine comes out greater than 1.
Example
L1 = L2 = 1, target (1, 1): cosθ2 = (2 − 2) / 2 = 0 → θ2 = 90°, θ1 = 45° − 45° = 0°. Check: (1, 0) + (0, 1) = (1, 1). The other solution: θ2 = −90°, θ1 = 90°.
With more joints it is usually solved with numerical methods based on the Jacobian.
In the demo
Switch from FK to IK, drag the target, flip the elbow and take it outside the reach circle to see the warning.
Common questions
Why are there two solutions? Because the elbow can bend up or down and the hand still ends up in the same place, like your arm with your hand resting on the table.
Interactive demo
Related concepts
Coordinate frames and transforms
A point only has coordinates relative to a frame (origin + axes). To go from the robot's frame to the world's: p_world = R(θ) · p_robot + t.
The Jacobian
The Jacobian maps joint velocities to hand velocity (v = J·ω). When its determinant is zero, the arm is at a singularity and loses a direction of motion.