Description Usage Arguments Details Value Functions Examples
The functions convert between visual degrees and centimeters, inches or pixels.
1 2 3 4 5 6 7 |
x |
The value to convert. This can be a single number or a numerical vector. |
dist |
The distance to the screen. See Details for the measurement unit. |
res |
A vector indicating the screen resolution in the horizontal direction (in pixels). |
screenW |
The width of the screen in the horizontal direction. See Details for the measurement unit. |
When converting from size to degrees (size2deg
), the measurement
unit of the distance to the screen (dist
) should be consistent with
the measurement unit of the size you are converting from (x
.
Namely if the size is in centimeters, then the distance should be to, and if
the size is in inches, then the distance should be in inches.
When converting from pixels to degrees (px2deg
), the measurement
unit of the distance to the screen (dist
) should be consistent with
the measurement unit of the screen width (screen width
). Namely if
the size is in centimeters, then the screen width should be to, and if the
size is in inches, then the screen width should be in inches.
Returns a value or vector of values indicating the corresponding visual degrees.
size2deg
: converts from centimeters to visual degrees
px2deg
: converts from pixels to visual degrees
deg2size
: converts from visual degrees to centimeters
deg2px
: converts from visual degrees to pixels
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | ### these functions convert between units
## from size to degrees
# for single values
size2deg( x = 2, dist = 30 ) # 3.818304866
# and multiple values
size2deg( x = c( 2, 0.5, 7, 2, 20, 0.5 ),
dist = c( 30, 30, 60, 15, 30, 15 ) )
# 3.818304866, 0.954907555, 6.676941008, 7.628149669, 36.86989765,
# 1.909682508
## from pixels to degrees
# for single values
px2deg( x = 2, dist = 30, res = 1024, screenW = 32 ) # 0.119366164
# and multiple values
px2deg( x = c( 2, 8, 100 ), dist = 30, res = 1024, screenW = 32 )
# 0.119366164, 0.477462066, 5.96292244
## from degrees to size
# for single values
deg2size( x = 2, dist = 30 ) # 1.047303896
# and multiple values
deg2size( x = c( 2, 8, 100 ), dist = 30 )
# 1.047303896, 4.195608717, 71.50521556
## from degrees to pixels
# for single values
deg2px( x = 0.119366164, dist = 30, res = 1024, screenW = 32 ) # 2
# and multiple values
deg2px( x = c( 0.119366164, 0.477462066, 5.96292244 ), dist = 30,
res = 1024, screenW = 32 )
# 2, 8, 100
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.