Description Usage Arguments Value Author(s) Examples

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

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

`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) |

A distance in centimeters

Ryan M. Hope

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) )
}
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.