perfect, thank you.
atan2 eh! never heard of it before.
It is very similar to atan except that it uses both X and Y instead of X/Y as an argument to return an angle that is in the correct quadrant. atan can only return a value between -90 and +90 degrees.
e.g. imagine a point that is at location X=1 Y=1. To find the angle from the origin you could use atan(X/Y) which correctly gives you 45 degrees. But imagine that the point is at coordinate X= -1, Y= -1 In that case X/Y is still 1, so atan will return the same angle of 45 degrees.
Using atan2 allows you to enter both X and Y coordinates which will give you the correct angle of 225 degrees (openscad returns -135 degrees which is the same thing).