Atan2 returns me only 4 sides (90,180,270,360)

Well, so i have created a simple algorithm for creating equal side triangles and when i wanted to implement possibility of rotating the triangle i tried using Atan2 function, but it miserably failed me.
image

-without rotation function