distance2point: Distance to Point

Description Usage Arguments Value Author(s) Examples

Description

Takes an x and y screen coordinate and returns the physical distance (in centimeters) from the observer to that point on the screen.

Usage

1
distance2point(x, y, viewerDistance, viewerHeight, resolutionX, resolutionY, screenWidth, screenHeight)

Arguments

x

The x coordinate of a point on a screen

y

The y coordinate of 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

A distance in centimeters

Author(s)

Ryan M. Hope

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
function( x, y, viewerDistance, viewerHeight, resolutionX, resolutionY, screenWidth, screenHeight ) {
    
    centerX <- screenWidth / 2
    centerY <- screenHeight / 2 - viewerHeight
    
    targetX <- x / resolutionX * screenWidth
    targetY <- y / resolutionY * screenHeight
    
    dX <- targetX - centerX
    dY <- targetY - centerY
    
    screenDistance <- sqrt( dX^2 + dY^2 )
    
    sqrt( ( viewerDistance^2 + screenDistance^2) )
    
  }

eyetracking documentation built on May 2, 2019, 11:06 a.m.