I have two lines: Line1 and Line2. Each line is defined by two points (P1L1(x1, y1), P2L1(x2, y2)
and P1L1(x1, y1), P2L3(x2, y3))
. I want to know t
The whole point is much easier than the given answers:
When you use atan(slope) you lose (literally) one bit of information, that is there are exactly two angles (theta) and (theta+PI) in the range (0..2*PI), which give the same value for the function tan().
Just use atan2(deltax, deltay) and you get the right angle. For instance
atan2(1,1) == PI/4
atan2(-1,-1) == 5*PI/4
Then subtract, take absolute value, and if greater than PI subtract from 2*PI.