XYZ to lon/lat

I have sphere and when I click on it, I can get X and Y coords - all needed parameters are known (radius=1, viewport: topleft=[-1;-1] bottomright=[1;1]). Z is computed. If sphere isn’t rotated, computation of lon/lat is easy:
lon = Arcsin(X)*180/pi 'in deg where x=<-1;1> for radius=1
lat = -Arcsin(Y)*180/pi ’ in deg where y=<-1;1>

but when I rotate this sphere in two axis (anglex, angley), I am LOST. When I try add these incremental angles to my computed lon/lat, no way is o.k. Who will help me with trigonometrics?
Thanks. No6