Are you working out the individual angles of the lines from their origin, then trying to do some arithmetic on those values? If so then that would explain your issues. An easier solution is the dot product.
For two vectors, A and B:
A . B = |A||B|cos(angle between A and B)
|A| is the length of A, so you can find that with Pythagoras.
So, if you have A = (ax, ay) and B = (bx, by) then:
angle between = acos( ((ax * bx) + (ay * by)) / (sqrt(ax*ax + ay*ay) * sqrt(bx*bx + by*by))
If you use the acos from math.h then the result will be in the range -pi/2 to pi/2. Be careful though — it'll always give you the smallest angle between the vectors, so if two vectors start with the same orientation and then one stays still and the other rotates then the angle between them will go up from 0 to pi/2, then down again from pi/2 to -pi/2, then up from -pi/2 to 0.
If you want a full -pi to pi then you need to do a further check to decide if the two vectors are both pointing "the same way". Imagine one vector is lying exactly on the x-axis pointing right. Then you want to decide whether the other is pointing right or left.
You can do that using the dot product too — check whether ((ax * bx) + (ay * by)) is negative or positive and add or subtract pi from your result depending on its sign and which angle you want to measure.
E.g. (untested, written adhoc)
|1||float get_angle_between_in_radians(float ax, float ay, float bx, float by)|
|3|| float dotproduct, lengtha, lengthb, result;|
|5|| dotproduct = (ax * bx) + (ay * by);|
|6|| lengtha = sqrt(ax * ax + ay * ay);|
|7|| lengthb = sqrt(bx * bx + by * by);|
|9|| result = acos( dotproduct / (lengtha * lengthb) );|
|11|| if(dotproduct < 0)|
|13|| if(result > 0)|
|14|| result += M_PI;|
|16|| result -= M_PI;|
|18|| return result;|
There's lots on the web about the dot product, and it's something that's very easy to understand the properties of, even if it takes you a while to really see why it all works...