colour_space: N-dimensional colour spaces

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/colourvision_package.R

Description

Generates a colour space based on any number of photoreceptor types and finds a colour locus for a given photoreceptor output.

Usage

1
2
colour_space(n, type="length", length=NA, edge=NA,
          q=rep(1,n), recep.noise=FALSE, e=NA)

Arguments

n

Number of photoreceptor types. Function accepts any number of photoreceptor types >=2. For instance, trichromatic: n=3; tetrachromatic: n=4, etc.

type

Whether the colour space should be built with a fixed vector length (type="length"), or a fixed distance between vertices (type="edge"; e.g. Pike 2012 and Renoult et al. 2015).

length

Vector length used to construct the colour space. Used when type="length". Typically length=1.

edge

Edge length used to construct the colour space. Used when type="edge".

q

Photoreceptor output values

recep.noise

Whether receptor noise should be used to calculate colour locus coordinates.

e

Vector representing photoreceptor noises. Used when recep.noise=TRUE

Details

This function is used internally in colour vision models.

Value

A list with the following dimensions:

coordinates

Colour locus of photoreceptor output values q in the colour space

vector_matrix

Matrix of column vectors, each representing one photoreceptor type

Author(s)

Felipe M. Gawryszewski f.gawry@gmail.com

References

Pike, T.W. 2012. Generalised chromaticity diagrams for animals with n-chromatic colour vision. Journal of Insect Behavior 255: 277-286.

Renoult, J. P., A. Kelber, and H. M. Schaefer. 2015. Colour spaces in ecology and evolutionary biology. Biol Rev Camb Philos Soc, doi: 10.1111/brv.12230.

See Also

Q, Qr, CTTKmodel, EMmodel, RNLmodel, GENmodel

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#A trichromatic colour space based on Endler and Mielke (2005) 
tri<-colour_space(n=3, length=0.75, q=c(0.5,0.2,0.3))

#showing:
#(1) Limits of the colour space (triangle)
plot(0, ylim=c(-1,1), xlim=c(-1,1), asp=1, ylab="X2", xlab="X1", type="n")
polygon(x=tri$vector_matrix[1,], y=tri$vector_matrix[2,], lty=2)

#(2) Vectors (length=0.75) used to build the colour space (arrows)
arrows(x0=0,y0=0, x1=tri$vector_matrix[1,1], y1=tri$vector_matrix[2,1], col="red")
arrows(x0=0,y0=0, x1=tri$vector_matrix[1,2], y1=tri$vector_matrix[2,2], col="red")
arrows(x0=0,y0=0, x1=tri$vector_matrix[1,3], y1=tri$vector_matrix[2,3], col="red")

#(3) Colour loci of given photoreceptor outputs
points(x=tri$coordinates[[1]], y=tri$coordinates[[2]], pch=21, col="blue", bg="blue")

Example output

Warning messages:
1: In rgl.init(initValue, onlyNULL) : RGL: unable to open X11 display
2: 'rgl_init' failed, running with rgl.useNULL = TRUE 
3: .onUnload failed in unloadNamespace() for 'rgl', details:
  call: fun(...)
  error: object 'rgl_quit' not found 

colourvision documentation built on Aug. 2, 2021, 1:06 a.m.