This is a bit like a very simple inverse kinematics, but should be so simple that it can be done exactly. Er, well, I think it can!
Problem definition: given armLength0, armLength1, and target (x,y), find angle0 and angle1 where
- Start at the origin
- Rotate angle0, then move forward a fixed length armLength0
- Rotate angle1, then move forward fixed length armLength1
- End on the target (x,y) coordinate.
It isn't quite a pure trig SAS, because I don't know any of the angles. I can find some angles:
targetLength = sqrt(x^2+y^2)cos(angle1)=(armLength0^2 + armLength1^2 − targetLength^2)/(2*armLength0*armLength1)SSS
aw man, SOHCAHTOA it has been too long.
angle0 is the sum of θA and θB:
cos(θA) = x / targetLengthCAHcos(θB) = (armLength0^2 + targetLength^2 - armLength1^2/(2*armLength0*targetLength))SSS
Huh. Seems dodgy.
You know the two arm lengths, $L_0$ and $L_1$. And you know $(x,y)$, so you also know the third side length of the triangle: $L=\sqrt{x^2+y^2}$.
Now you may use the law of cosines to find angle1, $\theta_1$. $$\cos(\theta_1)=\frac{L^2-L_1^2-L_2^2}{-2L_1L_2}\implies\theta_1=\arccos\left(\frac{L^2-L_1^2-L_2^2}{-2L_1L_2}\right)$$ (Applying $\arccos$ will give you an angle in $[0,\pi]$.)
Now angle0, $\theta_0$, is the sum of two angles. One of these is found in the same way using the law of cosines. The other is the arctangent of $y$ over $x$.
$$\theta_0=\arccos\left(\frac{L_2^2-L_1^2-L^2}{-2L_1L}\right)+\arctan\left(\frac{y}{x}\right)$$
(This all seems similar to what you found. I'm just tossing in the inverse trig functions. And using arctangent instead of arccos in one instance.)