Index: /trunk/FACT++/src/drivectrl.cc
===================================================================
--- /trunk/FACT++/src/drivectrl.cc	(revision 12880)
+++ /trunk/FACT++/src/drivectrl.cc	(revision 12881)
@@ -843,6 +843,6 @@
         }
 
-        const double costheta = cosdec*cosoff + sindec*sinoff*cosdir;
-        if (costheta >= 1)
+        const double sintheta = sindec*cosoff + cosdec*sinoff*cosdir;
+        if (sintheta >= 1)
         {
             T::Error("cos(Zd) > 1");
@@ -850,10 +850,10 @@
         }
 
-        const double sintheta = sqrt(1 - costheta*costheta);
-
-        const double cosdeltara = (cosoff - cosdec*costheta)/(sindec*sintheta);
-        const double sindeltara = sindir*sinoff/sintheta;
-
-        const double ndec = acos(costheta)*180/M_PI;
+        const double costheta = sqrt(1 - sintheta*sintheta);
+
+        const double cosdeltara = (cosoff - sindec*sintheta)/(cosdec*costheta);
+        const double sindeltara = sindir*sinoff/costheta;
+
+        const double ndec = asin(sintheta)*180/M_PI;
         const double nra  = (atan2(sindeltara, cosdeltara) + ra)*12/M_PI;
 
