Description Usage Arguments Value Author(s) Examples
Takes two screen coordinates and returns the angle (in degrees) subtended by those two points.
1 | subtendedAngle(x1, y1, x2, y2, viewerDistance = 58.74, viewerHeight = 4.55, resolutionX = 1280, resolutionY = 1024, screenWidth = 33.97, screenHeight = 27.31)
|
x1 |
The x coordinate of the first point on a screen |
y1 |
The y coordinate of the first point on a screen |
x2 |
The x coordinate of the second point on a screen |
y2 |
The y coordinate of the second point on a screen |
viewerDistance |
Perpendicular distance from the viewer to the screen (cm) |
viewerHeight |
Vertical height of the viewer above screen center (cm) |
resolutionX |
The x resolution of the monitor (pixels) |
resolutionY |
The y resolution of the monitor (pixels) |
screenWidth |
The physical screen width (cm) |
screenHeight |
The physical screen height (cm) |
The angle (in degrees) subtended by two points
Ryan M. Hope
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | function( x1, y1, x2, y2, viewerDistance=58.74, viewerHeight=4.55, resolutionX=1280, resolutionY=1024, screenWidth=33.97, screenHeight=27.31 ) {
d1 <- distance2point(x1, y1, viewerDistance, viewerHeight, resolutionX, resolutionY, screenWidth, screenHeight)
d2 <- distance2point(x2, y2, viewerDistance, viewerHeight, resolutionX, resolutionY, screenWidth, screenHeight)
dX <- screenWidth * ( x2 - x1 ) / resolutionX
dY <- screenWidth * ( y2 - y1 ) / resolutionY
screenDistance <- sqrt( dX^2 + dY^2 )
angleRadians <- acos( ( d1^2 + d2^2 - screenDistance^2 ) / ( 2 * d1 * d2 ) )
angleRadians / ( 2 * pi ) * 360
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.