Could anybody help to solve this? Relative angle between 2 rays(lines) which starts from same point. They could point anywhere 360 clockwise, but angle should be always relative (just inside angle).
Did you try even a cursory search for this? It's pretty standard vector math:
v1 = normalize(end1X - startX, end1Y - startY); v2 = normalize(end2X - startX, end2Y - startY); angle = acos(dot(v1, v2)) * 180.0/pi;
This will always give a value from 0 to 180, giving you the smallest positive angle clockwise or counter-clockwise.
In 2D, you can fix a rotation direction like so:
v1perp = (-v1.y, v1.x); if(dot(v2, v1perp) > 0) angle = 360.0 - angle;
This will give a clockwise angle in the range 0...180 if v2 points to the right of v1, or 180...360 if v2 is pointing to the left of v1.