insideOptimalColors: test whether points are inside the surface of _optimal...

View source: R/colorSpec.optimal.R

insideR Documentation

test whether points are inside the surface of optimal colors

Description

Test points for being inside the surface of optimal colors, which is the boundary of the object color solid. It is essentially a wrapper around zonohedra::inside().

Usage

## S3 method for class 'colorSpec'
insideOptimalColors( x, p )

Arguments

x

a colorSpec object - with 1, 2, or 3 spectra

p

an NxM numeric matrix, where M is the number of spectra. The points to be tested are in the rows. p can also be a numeric vector that can be converted to such a matrix, by row.

Value

insideOptimalColors() returns a data.frame with N rows and these columns:

p

the given point

distance

the signed distance from the point to the boundary surface of optimal colors. When distance < 0, the point is in the interior, and the distance is the true Euclidean distance. For boundary points, distance is 0. When distance > 0, it may be larger than the true Euclidean distance, so distance is really a pseudo-distance.

inside

whether the point is inside the zonotope. inside = distance<=0

If the row names of p are unique, they are copied to the row names of the output.
In case of error, the function returns NULL.

See Also

zonohedra::inside()

Examples

wave = seq(400,800,by=4)

D50.eye = product( D50.5nm, 'varmat', xyz1931.1nm, wave=wave )

white = colSums( 4 * as.matrix(D50.eye) )

insideOptimalColors( D50.eye,  c(30,50,70,  0,0,0, white, white+1 )  )

##          p.1       p.2       p.3 inside  distance
##  1  30.00000  50.00000  70.00000   TRUE -7.528005
##  2   0.00000   0.00000   0.00000   TRUE  0.000000
##  3 101.24793 105.04021  86.52988   TRUE  0.000000
##  4 102.24793 106.04021  87.52988  FALSE  1.259912

colorSpec documentation built on April 4, 2025, 1:59 a.m.