I have a planar arm with two servo joints, link lengths 100 mm and 80 mm, and I want to place the tip at a given (x, y). My inverse kinematics code uses the law of cosines. It works for most points, but it gives a pose that looks mirrored from what I expected, and for targets near the edge of the workspace it returns NaN.
What is the correct set of equations, how do I choose between the two solutions, and how should the code deal with points it cannot reach?




