Define your second line. In 3D, you can get infinite number of angles, depending of this second line definition.
(This is true for 2D too, but considering Ox axis as reference, there is only one possibility)
It seems you know the angle in your code is wrong, so you know what this angle should be. If you cannot describe the problem better, then upload a dwg and explain the desired output.