# Introduction

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 , 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 .

Other featured functions are invertboundary(), inside() and inside2trans().

library(zonohedra)

# A Ray Tracing Example

In Burns’ example, the base of the ray is the center of the zonohedron $$Z$$:

matgen = colorimetry.genlist[]   # 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 $$XYZ_{\text{50%}}$$.

The direction of the ray is given by spherical angles, which define a unit vector u:

theta = 1.478858 ; phi = 0.371322
u = c( sin(phi)*cos(theta), sin(phi)*sin(theta), cos(phi) ) ; u
##  0.03331263 0.36131522 0.93184848

Calculate the intersection of the ray with the boundary of $$Z$$.

df_opt = raytrace( zono, base, u ) ; df_opt
##     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.0026449
xyz_opt = df_opt$point[1, ] ; xyz_opt ##  51.79069 69.37875 99.99523 This matches Burns’ value of $$XYZ_{\text{LPsoln}}$$. From Figure 8 of  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: invertboundary( zono, xyz_opt )$transitions
##  4

Now calculate the intersection of the ray with the 2-transition surface associated with $$Z$$.

df_2trans = raytrace2trans( zono, base, u ) ; df_2trans
##     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.0038576
xyz_2trans = df_2trans$point[1, ] ; xyz_2trans ##  51.79065 69.37829 99.99402 This matches Burns’ value of $$XYZ_{\text{two-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 $$XYZ_{\text{LPsoln}}$$ and $$XYZ_{\text{two-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. df_opt$tmax - df_2trans\$tmax
##  0.001292229

This matches Burns’ value of $$1.29 \times 10^{-3}$$, which is very tiny especially compared to the two $$XYZ$$s.

What is the maximum that this distance can be over the entire $$\partial 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 \times 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  that the distance between these surfaces has “… no practical impact on typical colorimetric calculations”.

If the zonohedron $$Z$$ is called the Optimal 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.

# Inside or Outside ?

Consider the midpoint of $$XYZ_{\text{LPsoln}}$$ and $$XYZ_{\text{two-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:

xyz_mid = (xyz_opt + xyz_2trans) / 2
inside( zono, xyz_mid )
##        p.1      p.2      p.3 inside      distance idxhyper
## 1 51.79067 69.37852 99.99462   TRUE -0.0006013682    49283
inside2trans( zono, xyz_mid )
##        p.1      p.2      p.3     distance linkingnumber inside  timecalc
## 1 51.79067 69.37852 99.99462 0.0006013897             0  FALSE 0.0488543

# Session Information

This document was prepared Tue May 30, 2023 with the following configuration:
R version 4.3.0 (2023-04-21 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale:
 LC_COLLATE=C
 LC_CTYPE=English_United States.utf8
 LC_MONETARY=English_United States.utf8
 LC_NUMERIC=C
 LC_TIME=English_United States.utf8

time zone: America/Los_Angeles
tzcode source: internal

attached base packages:
 stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
 zonohedra_0.2-2

loaded via a namespace (and not attached):
 digest_0.6.31         R6_2.5.1              microbenchmark_1.4.10
 fastmap_1.1.1         xfun_0.39             glue_1.6.2
 cachem_1.0.8          knitr_1.42            htmltools_0.5.5
 logger_0.2.2          rmarkdown_2.21        cli_3.6.1
 sass_0.4.6            jquerylib_0.1.4       compiler_4.3.0
 tools_4.3.0           evaluate_0.21         bslib_0.4.2
 yaml_2.3.7            rlang_1.1.1           jsonlite_1.8.4