Last active
August 29, 2015 14:22
-
-
Save rainyear/d248788b841b9910d6d7 to your computer and use it in GitHub Desktop.
Visual Angle.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// cal Pix size with given visual angle and screen info. | |
var scr = { | |
xpixels: 1024, | |
ypixels: 768, | |
width: 360, //mm | |
height: 270, //mm | |
} | |
var ang2pix = function(screen, angle, distense){ | |
var targetWidth = angle.h * distense / (180 / 3.14); | |
var targetHeight = angle.v * distense / (180 / 3.14); | |
return { | |
xpixels: targetWidth * screen.xpixels / screen.width, | |
ypixels: targetHeight * screen.ypixels / screen.height | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @screen | |
var scr = { | |
xpixels: 1024, | |
ypixels: 768, | |
width: 360, //mm | |
height: 270, //mm | |
} | |
// @target | |
/* | |
{ | |
xpixels: 250, | |
ypixels: 250 | |
} | |
*/ | |
// @distense | |
// 120 cm = 1200 mm | |
var calVisualAngle = function(screen, target, distense){ | |
var targetWidth = screen.width * target.xpixels / screen.xpixels; | |
var targetHeight = screen.height * target.ypixels / screen.ypixels; | |
return { | |
h: targetWidth / distense * 180 / 3.14, | |
v: targetHeight / distense * 180 / 3.14 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment