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()`

.

`library(zonohedra)`

In Burns’ example, the base of the ray is the center of the zonohedron \(Z\):

```
= colorimetry.genlist[[2]] # 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
matgen = zonohedron( matgen )
zono = getcenter(zono) ; base 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`

:

```
= 1.478858 ; phi = 0.371322
theta = c( sin(phi)*cos(theta), sin(phi)*sin(theta), cos(phi) ) ; u u
```

`## [1] 0.03331263 0.36131522 0.93184848`

Calculate the intersection of the ray with the boundary of \(Z\).

`= raytrace( zono, base, u ) ; df_opt 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
```

`= df_opt$point[1, ] ; xyz_opt xyz_opt `

`## [1] 51.79069 69.37875 99.99523`

This matches Burns’ value of \(XYZ_{\text{LPsoln}}\). 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:

`invertboundary( zono, xyz_opt )$transitions`

`## [1] 4`

Now calculate the intersection of the ray with the 2-transition surface associated with \(Z\).

`= raytrace2trans( zono, base, u ) ; df_2trans 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
```

`= df_2trans$point[1, ] ; xyz_2trans xyz_2trans `

`## [1] 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.

`$tmax - df_2trans$tmax df_opt`

`## [1] 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 [1] 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.

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_opt + xyz_2trans) / 2
xyz_mid 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
```

[1]

BURNS, Scott A. The location of optimal object colors with more than two transitions. *Color Research & Application* [online]. 2021, **46**(6), 1180–1193. Available at: doi:https://doi.org/10.1002/col.22693

[2]

CENTORE, Paul. A zonohedral approach to optimal colours. *Color Research & Application* [online]. 2013, **38**(2), 110–119. Available at: doi:10.1002/col.20713

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: [1] LC_COLLATE=C [2] LC_CTYPE=English_United States.utf8 [3] LC_MONETARY=English_United States.utf8 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.utf8 time zone: America/Los_Angeles tzcode source: internal attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] zonohedra_0.2-2 loaded via a namespace (and not attached): [1] digest_0.6.31 R6_2.5.1 microbenchmark_1.4.10 [4] fastmap_1.1.1 xfun_0.39 glue_1.6.2 [7] cachem_1.0.8 knitr_1.42 htmltools_0.5.5 [10] logger_0.2.2 rmarkdown_2.21 cli_3.6.1 [13] sass_0.4.6 jquerylib_0.1.4 compiler_4.3.0 [16] tools_4.3.0 evaluate_0.21 bslib_0.4.2 [19] yaml_2.3.7 rlang_1.1.1 jsonlite_1.8.4