Browse Source

Changed PPD calculation

Ioannis Agtzidis 5 years ago
parent
commit
3663f48dbf
1 changed files with 9 additions and 2 deletions
  1. 9 2
      PixelsPerDegree.m

+ 9 - 2
PixelsPerDegree.m

@@ -15,8 +15,15 @@
 %   pyPerDeg     - pixels per degree on Y axis(approx.)
 
 function [pxPerDeg, pyPerDeg] = PixelsPerDegree(width, height, distance, widthPixels, heightPixels)
-    thetaWtotal = 2*atan(width/(2*distance))*180/pi;
-    thetaHtotal = 2*atan(height/(2*distance))*180/pi;
+    thetaWtotal = 2*atan2(width/2,distance)*180/pi;
+    if (thetaWtotal < 0)
+        thetaWtotal = 360 + thetaWtotal;
+    end
+    thetaHtotal = 2*atan2(height/2,distance)*180/pi;
+    if (thetaHtotal < 0)
+        thetaHtotal = 360 + thetaHtotal;
+    end
+
 
     pxPerDeg = widthPixels/thetaWtotal;
     pyPerDeg = heightPixels/thetaHtotal;