A band-based material spectrum is a superimposition of bandpass filters, and (optionally) a bandstop filter. The 2 functions in this topic convert a vector of numbers between 0 and 1 to a band representation, and back again.
1 2 3 4
a numeric Mx2 matrix with wavelength pairs in the rows,
or a vector that can be converted to such a matrix, by row.
The two wavelengths in a row (the transition wavelengths) define either a bandpass or bandstop filter,
and all the rows are superimposed to define the transmittance spectrum of the final material.
If the 2 wavelengths are denoted by λ_1 and λ_2,
and λ_1 < λ_2 then the filter is a bandpass filter.
If the 2 wavelengths are swapped, then the spectrum is "flipped"
and is a bandstop filter, and the band "wraps around" from long wavelengths to short.
There can be at most 1 bandstop filter in the matrix, otherwise it is an error.
The bands must be pairwise disjoint, otherwise it is an error.
To get a material with transmittance identically 0, set
a vector of wavelengths for the returned object
a colorSpec object with
bandRepresentation() is a right-inverse of
see Examples and the test script
For more mathematical details, see vignette convexity.
bandMaterial() returns a
colorSpec object with
quantity equal to
lambda is a matrix, then the object has 1 spectrum.
lambda is a list of matrices with length N, then the object has N spectra.
returns a list of matrices with 2 columns.
There is a matrix in the list for each spectrum in
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
# make a vector superimposing a bandpass and a bandstop filter, and of the proper length 401 vec = c( rep(1,100), 0.5, rep(0,40), .25, rep(1,50), 0.9, rep(0,100), 0.4, rep(1,107) ) # convert that vector to a colorSpec object, with a single spectrum spec = colorSpec( vec, wavelength=380:780, quantity='transmittance', specnames='sample' ) # extract and print the 2 bands lambda = bandRepresentation( spec ) ; print(lambda) ## $sample ## lambda1 lambda2 ## BS 673.10 480.0 ## BP1 521.25 572.4 # convert the 2 bands (the transition wavelengths) back to a vector of length 401 # and compare with the original vector delta = vec - coredata( bandMaterial(lambda) ) range(delta) ##  -9.092727e-14 2.275957e-14
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.