wave = seq(400,700,by=5)
D50.eye = product( D50.5nm, 'material', xyz1931.1nm, wavelength=wave )
probeOptimalColors( D50.eye, c(0.2,0.5,0.9), c(1,2,1, -1,-2,-1) )
## gray direction.1 direction.2 direction.3 s optimal.1 optimal.2
## 1 0.2 1 2 1 32.306207 52.533143 85.612065
## 2 0.2 -1 -2 -1 8.608798 11.618138 3.782055
## 3 0.5 1 2 1 20.993144 71.560483 94.485416
## 4 0.5 -1 -2 -1 20.993144 29.574196 10.512842
## 5 0.9 1 2 1 4.333700 95.354911 103.165832
## 6 0.9 -1 -2 -1 35.621938 55.399273 23.254556
## optimal.3 lambda.1 lambda.2 dol.delta dol.omega dol.lambda
## 1 49.616046 451.8013 598.9589 0.63409966 0.48287469 536.97618091
## 2 8.701041 636.3031 429.4659 0.08458527 0.99624955 674.30015903
## 3 64.267740 441.9105 615.0822 0.78101041 0.49048222 538.73234859
## 4 22.281453 615.0822 441.9105 0.21898959 0.99048222 662.20606601
## 5 82.227974 422.9191 648.7404 0.95800430 0.49825407 540.49590064
## 6 42.272337 593.2415 455.2425 0.42035428 0.97962398 650.57382749
# create a 0-1 spectrum with 2 transitions
rectspec = rectangularMaterial( lambda=c(579.8697,613.7544), alpha=1, wave=wave )
# compute the corresponding color XYZ
XYZ = product( rectspec, D50.eye )
XYZ
## X Y Z
## BP_[579.87,613.754] 33.42026 21.96895 0.02979764
# trace a ray from middle gray through XYZ
white.XYZ = product( neutralMaterial(1,wave=wave), D50.eye )
direction = XYZ - white.XYZ/2
res = probeOptimalColors( D50.eye, 0.5, direction, aux=FALSE )
res$s
## 1.00004 the ray has gone past the original color to the boundary
res$optimal
## X Y Z
## [1,] 33.41958 21.96774 0.02808178
res$lambda
## NA NA because there are more than 2 transitions in the true optimal
# since s=1.00004 > 1,
# XYZ is actually in the interior of the color solid, and not on the boundary.
# The boundary is a little-bit further along the ray,
# and the corresponding spectrum has more than 2 transitions.
Run the code above in your browser using DataLab