insideSchrodingerColors: test whether points are inside the surface of Schrödinger...

View source: R/colorSpec.optimal.R

insideSchrodingerColorsR Documentation

test whether points are inside the surface of Schrödinger colors

Description

Consider a colorSpec object x with type equal to 'responsivity.material'. The set of all possible material reflectance functions (or transmittance functions) that take the value 0 or 1, and with 2 or 0 transitions is called the 2-transition spectrum space. When there are 2 transitions, there are 2 types of spectra: bandpass and bandstop. When there are 0 transitions, the spectrum is either identically 0 or identically 1. When x is applied to this space, the corresponding surface in response space is called the 2-transition surface. The surface is closed. The special points 0 and W (the response to the perfect reflecting diffuser) are on this surface. The surface is symmetrical about the neutral gray midpoint G=W/2. Following West and Brill, colors on the surface are called Schrödinger colors. Denote the surface by S_2.

This function computes whether given points are inside S_2. It only supports x with 3 channels. It is essentially a wrapper around zonohedra::inside2trans().

Usage

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

Arguments

x

a zonohedron object

p

an Nx3 numeric matrix. 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.

Details

If the surface has no self-intersections, the the definition of whether a point p is "inside" is fairly straightforward: it is where the linking number of p and the surface is non-zero. In fact, if it is non-zero then it must be +1 or -1. The linking number is analogous the winding number in 2D.

Unfortunately, there is currently no test for whether the surface has self-intersections, For a bad surface with self-intersections, the linking number might be any integer. Since there is no such test, we simply use the same non-zero linking number rule always.

The computed linkingnumber is returned so that the user can apply the non-zero rule, or the even-odd rule, as appropriate for their situation. These 2 rules are analogous to the two winding number rules used for polygons in computer graphics, see Point in polygon.

The case where a point is on the surface (i.e. the distance to the surface is 0) is problematic. The linkingnumber is then undefined, and we currently set inside to be undefined as well. Thus inside should be interpreted as strictly inside. However, in some situations, the user may want to consider inside to be TRUE in this problematic case. Or the user may want to consider points that are within a very small epsilon of the surface, where roundoff might have occurred, to have inside=FALSE or inside=NA. So the both the computed linkingnumber and distance are returned so the user can use them to make their own definition of what "inside" means.

Value

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

p

the given point

distance

the distance from the point to the surface. This is the true Euclidean distance, and not a signed distance. If the point is on the surface, the distance should be 0 up to numerical precision.

linkingnumber

the linking number of the point and the surface. If the point is on the surface (distance==0), the (mathematical) linking number is undefined, and the computed linkingnumber is NA (integer).

inside

whether the point is inside the surface; a logical. This is currently set to linkingnumber != 0. If the linkingnumber is NA (integer), then inside is NA (logical).

timecalc

the time to do the calculations, in seconds

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.

References

Point in polygon — Wikipedia, The Free Encyclopedia. https://en.wikipedia.org/w/index.php?title=Point_in_polygon&oldid=1139808558. 2023.

Spivak, Michael. A Comprehensive Introduction to Differential Geometry. Volume 1. 3rd edition. Publish or Perish. 1999.

West, G. and M. H. Brill. Conditions under which Schrödinger object colors are optimal. Journal of the Optical Society of America. 73. pp. 1223-1225. 1983.

See Also

zonohedra::inside2trans()

Examples

D50.eye = product( D50.5nm, 'varmat', xyz1931.1nm, wave=seq(360,830,by=5) )

insideSchrodingerColors( D50.eye,  c(30,50,70,  0,0,0)  )

##    p.1 p.2 p.3 distance linkingnumber inside     timecalc
##  1  30  50  70 7.516577             1   TRUE 4.858999e-04
##  2   0   0   0 0.000000            NA     NA 9.399839e-06

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