Law Of Cosines Confusion I am trying to understand finding the joint angles to a robot arm and i am reading this tutorial on  a website and either i am really dense or it is wrong.. 
https://appliedgo.net/roboticarm/ 

The 5th picture from the top where the author starts to label angles for law of cosines, he previously states that Angle A1 is split into D1 and D2
and then he applies law of cosines but it looks more like Pythagorean theorem he is saying that angle D1^2 = X^2 + Y^2 which i dont understand ? He has two unknowns , side C and angle c, so how does he solve for law of cosines?

enter image description here
The figure is nonsense. As you say, the Pythagorean theorem involves side lengths, not angles. The correct way to compute D1 is via arctangent (as the author does do later in the code).
The pythagorean theorem is just a generalization of the Law of Cosines. 

As per your given link, the author first uses the pythagorean theorem to find out the value of $D1$. He then uses this value (by substituting it into the formula for the law of cosines) to find $D2$ by considering the second triangle (which is not right-angled). 

He then reuses the Law of Cosines but considering another angle now $A2$ to find out its cosine. And Hence. he deduces the value of the angle itself. 

In short, he uses the law of cosines two times. One to find out the side $D2$ and one time to find out $A2$