eyetracking (version 1.1)

subtendedAngle: Subtended Angle

Description

Takes two screen coordinates and returns the angle (in degrees) subtended by those two points.

Usage

subtendedAngle(x1, y1, x2, y2, viewerDistance = 58.74, viewerHeight = 4.55, resolutionX = 1280, resolutionY = 1024, screenWidth = 33.97, screenHeight = 27.31)

Arguments

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)

Value

The angle (in degrees) subtended by two points

Examples

Run this code
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
    
  }

Run the code above in your browser using DataLab