The focus of this vignette are the two functions
raytrace()
and raytrace2trans()
. The former is
for the boundary of the zonohedron and the latter is for the associated
2-transition surface. We revisit the example at the end of section 6 in
Scott Burns’ paper [1], which is also
illustrated in the 1nm plot from Figure 8. His example is from
colorimetry, where the boundary of the zonohedron is the set of optimal
colors and the 2-transition surface is the set of Schrödinger colors
(both for Illuminant E). The correspondence for the optimal colors was
discovered by Paul Centore, see [2].
Other featured functions are invertboundary()
,
inside()
and inside2trans()
.
In Burns’ example, the base of the ray is the center of the zonohedron Z:
matgen = colorimetry.genlist[["xyz1931.1nm"]] # the CIE 1931 CMFs at 1nm step
matgen = 100 * matgen / sum( matgen[2, ] ) # it is traditional to scale so the center has Y=50, recall we use Illuminant E
zono = zonohedron( matgen )
base = getcenter(zono) ; base
## x y z
## 50.00400 50.00000 50.01653
The vector base
corresponds to Burns’ vector XYZ50%.
The direction of the ray is given by spherical angles, which define a
unit vector u
:
## [1] 0.03331263 0.36131522 0.93184848
Calculate the intersection of the ray with the boundary of Z.
## base.1 base.2 base.3 direction.1 direction.2 direction.3 facetidx sign tmax point.1 point.2 point.3 timetrace
## 1 50.00400 50.00000 50.01653 0.03331263 0.36131522 0.93184848 49283 -1 53.63393 51.79069 69.37875 99.99523 0.001214916
## [1] 51.79069 69.37875 99.99523
This matches Burns’ value of XYZLPsoln. From Figure 8 of [1] we see that this point (and every point in the same parallelogram) comes from a reflectance spectrum with 4 transitions. This can be verified by inverting:
## [1] 4
Now calculate the intersection of the ray with the 2-transition surface associated with Z.
## base.1 base.2 base.3 direction.1 direction.2 direction.3 gndpair.1 gndpair.2 alpha.1 alpha.2 tmax point.1 point.2 point.3
## 1 50.00400 50.00000 50.01653 0.03331263 0.36131522 0.93184848 629 575 0.2246808 0.4459951 53.63263 51.79065 69.37829 99.99402
## iters timetrace
## 1 107564 0.003704921
## [1] 51.79065 69.37829 99.99402
This matches Burns’ value of XYZtwo-trans to 4 decimal places. The transition wavelengths 629 and 575nm, and the parallelogram coordinates 0.2246808 and 0.4459951 (these are the corresponding reflectances), are clearly visible in Figure 8.
Now consider the distance between these 2 points XYZLPsoln
and XYZtwo-trans.
The parameter tmax
in both data frames is the parameter on
the ray where it intersects the boundary or the surface. Since
u
is a unit vector, the difference between the parameters
is this distance.
## [1] 0.001292229
This matches Burns’ value of 1.29 × 10−3, which is very tiny especially compared to the two XYZs.
What is the maximum that this distance can be over the entire ∂Z ? To get a rough estimate, a search was made over the rays passing though the centers of all the 21900 deficient parallelograms, and with the same basepoint as before. The largest distance over these rays was 2.47 × 10−3. This distance is for the parallelogram with generators corresponding to 592 and 608 nm; the generating ‘spectrum’ has 8 transitions. The actual maximum distance between the boundary of the color solid and the 2-transition surface is not much larger than this sampling. This confirms Burns’ statement from [1] that the distance between these surfaces has “… no practical impact on typical colorimetric calculations”.
If the zonohedron Z is called the Object Color Solid (OCS), and the inside of the 2-transition surface is called the Schrödinger Color Solid (SCS), we see that the OCS is obtained by adding a very thin “skin” on some regions of the SCS.
Consider the midpoint of XYZLPsoln and XYZtwo-trans. It lies on the same ray as these 2 points, so it must be inside the zonohedron, but outside the 2-transition surface. We can verify this easily:
## p.1 p.2 p.3 idxhyper distance inside
## 1 51.79067 69.37852 99.99462 49283 -0.0006013682 TRUE
## p.1 p.2 p.3 distance linkingnumber inside timecalc
## 1 51.79067 69.37852 99.99462 0.0006013897 0 FALSE 0.01444886
R version 4.4.2 (2024-10-31) Platform: x86_64-pc-linux-gnu Running under: Ubuntu 24.04.2 LTS Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so; LAPACK version 3.12.0 locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8 LC_COLLATE=C [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C time zone: Etc/UTC tzcode source: system (glibc) attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] zonohedra_0.4-0 rmarkdown_2.29 loaded via a namespace (and not attached): [1] digest_0.6.37 R6_2.6.1 microbenchmark_1.5.0 [4] fastmap_1.2.0 xfun_0.51 maketools_1.3.2 [7] glue_1.8.0 cachem_1.1.0 knitr_1.49 [10] htmltools_0.5.8.1 logger_0.4.0 buildtools_1.0.0 [13] lifecycle_1.0.4 cli_3.6.4 sass_0.4.9 [16] jquerylib_0.1.4 compiler_4.4.2 sys_3.4.3 [19] tools_4.4.2 evaluate_1.0.3 bslib_0.9.0 [22] yaml_2.3.10 jsonlite_1.9.0 rlang_1.1.5