For RasterLayer arguments x and y, atan2(y, x) returns the angle in radians for the tangent y/x, handling the case when x is zero. See link[base]{Trig}
See Math-methods for other trigonometric and mathematical functions that can be used with a Raster* objects.