I am trying to find heading angle for my three wheeled robot my robot setup is as below

I know all co-ordinate values. (x1 y1) (x2 y2) two back wheels and (x3 y3) is front wheel co-ordinate
(xm ym) is the midpoint of (x1 y1) and (x2 y2)
(xt yt) is the target point
I am trying to find angle between (x3 y3) and (xt yt)
For the first case angle range must be 0 to +180 and for second case angle range must be 0 to -180 to make necessary turnings.
How can I use atan2 method for this? Is there any other better method to find angle in the necessary range?
180 - |atan2(v1) - atan2(v2)|didn't work but thisatan2(v1) - atan2(v2)works. Not sure I'm doing right or wrong – ronroo Oct 22 '15 at 22:45