Giving upvotes because the answer is correct.
The mathematics of 3D worlds is linear algebra. You need to understand the fundamentals of linear algebra to program 3D software effectively. Otherwise you will be entirely at the mercy of people online providing your basic formulas every time you need them.
The mathematics of 2D worlds is trigonometry and geometry. You need to understand the fundamentals to program 2D software effectively.
For how to apply the law of cosines, you can compute the angle between any two vectors using the function provided above. It applies just as well in 2D if you set the third component to zero; the two vectors are the legs of a triangle and the cosine (or inverse cosine) is used for calculating the angle between the legs of the triangle.
If you need the last line without 'math notation', the angle is equal to the inverse cosine of the dot product of two normalized vectors. If you don't know what those words mean, work through this or similar.