**Definition 3:**
This definition works directly with vertices and squares of $Q^n$.
A _2-transition vertex_ is one with a single circular run of 0s,
and a single circular run of 1s.
A run is allowed to empty, and this yields the vertex of all 0s and all 1s.
A _2-transition square_ is a square whose 4 vertices are all 2-transition
vertices.
Note that the center of the square has exactly 2 coordinates with value 1/2,
and the other values are a circular arc of 0s and an arc of 1s.
We now define $Q^n_2$ to be the union of all these 2-transition squares.
It is an example of a cubical subcomplex of $Q^n$.
Once again, it is straightforward to show that
**Definition 3** and **Definition 1** are equivalent.
For an $x := (\alpha_1,...,\alpha_n) \in Q^n_2$,
we define the _level_ of $x$ be the number of $\alpha_i$'s that equal $1$.
The level varies from 0 to $n$.
The level is constant on the interior of an edge and the interior of a square.
We define the _level_ of a square to be the level on the interior.
The level of a square varies from 0 to $n{-}2$.
It is helpful to think of level=0 squares at the "bottom" of the subcomplex,
and level=$n{-}2$ squares at the "top".
So we know that $Q^n_2$ is a union of squares, but what does it "look like",
and what is its topology?
We claim that $Q^n_2$ is a 2-sphere $\mathbb{S}^2$.
In the case of $n{=}3$ this is easy to see, since $Q^3_2$ = $\partial Q^3$.
In general, first consider all the 2-transition squares with level=0.
It is straighforward to show that such a square has 0 as a vertex,
and it has 2 vertices with level=1 and one vertex with level=2.
Each edge from 0 to a level 1 vertex is shared by two of the squares,
and so the squares are arranged in circular fashion around 0.
Their union is a topological disk $\mathbb{D}^2$ at the "bottom".
Similarly, the level=$n{-}2$ squares form a disk at the "top".
Now consider squares with fixed level $\mathcal{l}$ with $0 < \mathcal{l} < n{-}2$.
It is easy to show that in each square,
both of the level=$\mathcal{l}{+}1$ vertices are
in one other square, so the level $\mathcal{l}$ squares form a
"necklace of $n$ diamonds".
These $n{-}3$ necklaces are stacked on top of each other to form a cylinder,
and the cylinder is capped at bottom and top to form the
2-sphere $\mathbb{S}^2$.
We now verify the square count in $Q^n_2$;
$n + n(n{-}3) + n = n(n-1)$ which is correct.
The following figure is a helpful visualization.
```{r, rgl=TRUE, dev='png', echo=TRUE, message=TRUE, warning=TRUE, fig.width=6.5, fig.height=4, fig.cap='Figure 2.3 [these are interactive WebGL widgets]', fig.keep='none', fig.show='hide', out.width="100%", cache=FALSE }
rgl::par3d( zoom=0.7 )
rgl::mfrow3d( 1, 2 )
zono = polarzonohedron(9)
plot2trans( zono )
rgl::next3d()
plot2trans( zono, level=c(0,4,7) )
rgl::rglwidget( webgl=TRUE )
```
This figure plots the image of $Q^9_2$ in $\mathbb{R}^3$ under a
suitable linear map.
The squares are distorted into parallelograms.
The figure on the left draws the full subcomplex,
and the one on the right only draws levels 0, 4, and 7.
The "necklace of 9 diamonds" at level=4 is easily visible.
The black dot is the image of $(0,...,0)$,
and the white dot is the image of $(1,...,1)$.
More about these linear maps is given in the next section.
# The 2-Transition Surface $S_2 \subsetneq Z \subsetneq \mathbb{R}^3$
Let the zonohedron $Z := L(Q^n)$,
where $L : \mathbb{R}^n \twoheadrightarrow \mathbb{R}^3$ is a surjective linear map.
From now on we assume that $Z$ is _pointed_,
which means that 0 is a vertex of $Z$.
Let $S_2 := L(Q^n_2)$ be the image of the 2-transition subcomplex $Q^n_2$.
Since the subcomplex is a union of squares glued on the edges to form a 2-sphere $\mathbb{S}^2$,
$S_2$ is a union of parallelograms glued on the edges.
$S_2$ is a tesselated surface,
but may not be a sphere because it may have self-intersections.
We are mainly interested in the case that there are _no_ self-intersections,
and there is a precise way to state this.
Let $L_2$ be the restriction of $L$ to $Q^n_2$.
So $L_2 : Q^n_2 \to \mathbb{R}^3$ is the composition of the
inclusion $Q^n_2 \subsetneq \mathbb{R}^n$ followed by $L$.
The surface has no self-intersections iff $L_2$ is injective.
For example, in the previous figure $S_2$ does **not**
have self-intersections and is a topological 2-sphere.
$L_2$ is injective.
If $L_2$ is injective,
then it is well-known (@Alexander1924, @Moise1977 p. 117, and @Bing1983 p. 161)
that $S_2$ divides $\mathbb{R}^3$ into
an inside region and an outside region whose intersection is $S_2$.
Moreover, the inside region is homeomorphic to a closed ball,
and $S_2$ is the boundary of that ball.
Since $Q^n_2 \subsetneq Q^n$, $S_2 = L(Q^n_2) \subsetneq L(Q^n) = Z$.
We emphasize that $S_2$ is a surface, and $Z$ is a solid.
We also emphasize that $S_2$ depends intimately on the order of the generators,
and $Z$ does not depend on the order at all.
# Polygons
A polygon for us is more than just a subset of the plane.
A _polygon_ is a finite and cyclically ordered set of distinct _vertices_,
plus the line segments that connect the vertices in cyclic order.
The line segments are called the _edges_.
The union of the edges is a subset of the plane,
but two different sets of vertices can generate the same subset -
the vertices matter.
A _simple polygon_ is a polygon whose edges do not intersect,
except at corresponding endpoints;
i.e. the polygon has no self-intersections.
By the _Jordan Curve Theorem_, a simple polygon,
as just a set, has an inside region
and an outside region, and both are connected.
Note that a non-simple polygon may also have a connected inside region;
it might "double-back" on itself within an edge, and then proceed forward again.
A _convex polygon_ is a polygon with an inside region that is convex.
There is an equivalent definition of polygon using functions.
Let $U_n$ be the set of $n$'th root of unity on the unit circle in $\mathbb{C}$,
plus the edges connecting these vertices in order.
So $U_n$ is sort of a _quintessential_ or _template_ polygon.
A general polygon is a function $f : U_n \to \mathbb{R}^2$ which is
injective _on the vertices_ (the image vertices are distinct) and
linear _on each edge_.
Since $f$ is injective on the vertices, it is also injective on each edge;
one can think of $f$ as a _piecewise-linear immersion_ of $U_n$.
A polygon defined this way is _simple_ iff $f$ is injective.
This is an unintuitive way to define a polygon,
but has the advantage that it generalizes easily to one higher dimension,
as we see later in **Section 9**.
# The Generator Polygon $P$
Since $Z$ is pointed, there is a plane $K$ in $\mathbb{R}^3$ that has 0
in one open halfspace, and all the generators of $Z$ in the other open halfspace.
This "cutting" hyperplane intersects $S_2$ in a polygon.
Each vertex of the polygon is the intersection of $K$
and the segment from 0 to a generator.
The cyclic order of its vertices is inherited from the order of the generators.
We call this the _generator polygon_ and let $P := K \cap S_2$ denote it.
$P$ may not be a simple polygon in general; it may have self-intersections.
Since there can be many cutting hyperplanes $K$,
$P$ is only defined up to a projective transformation.
In colorimetry for example, there are three chromaticity diagrams,
from 1931, 1960, and 1976.
They are all generator polygons for the same set of generators,
and the 3 polygons differ by projective transformations,
see @Wyszecki&Stiles.
# Parallelograms in $S_2$ and $\partial Z$
Given $\partial Z$ and $S_2$ as above,
the goal in this section is to show that each is a union
of $n(n{-}1)$ parallelograms, and to set up a 1-1 correspondence
between the parallelograms in $S_2$ and those in $\partial Z$.
Each parallelogram will also be assigned a unit normal
in such a way that corresponding parallelograms have the same normal.
First consider $\partial Z$.
If a facet of $Z$ is not a parallelogram, let it be tiled
with the _standard tiling_ by parallelograms,
see the [Zonotopes](zonotopes.html) vignette.
Given an unordered pair $\{ i,j \}$ with $1 \le i , j \le n$
and $i \ne j$,
there are 2 antipodal parallelograms in $\partial Z$.
The edges of both parallelograms are the generators $L(e_i)$ and $L(e_j)$.
If $\mathcal{P}$ is one of those parallelograms,
we know that $\mathcal{P}$ is the image of some square in $Q^n$.
The following Lemma algebraically characterizes which squares map to
a parallelogram $\mathcal{P} \subset \partial Z$.
**Lemma:**
Let $\Sigma$ be a square in $Q^n$.
By definition $\Sigma$ is determined by an unordered pair $\{ i,j \}$
and for all $k \notin \{ i,j \}$, an assignment of $\alpha_k$ to either 0 or 1.
The coordinates $\alpha_i$ and $\alpha_j$ are 'free' in [0,1]
and sweep out the square.
Let the parallelogram
$\mathcal{P} := L(\Sigma) \subsetneq Z$ be the image of the square.
Let $w := L(e_i) \times L(e_j)$ be the cross product of the edges of $\mathcal{P}$.
Then $\mathcal{P} \subset \partial Z$
iff
for all $k \notin \{ i,j \}$
\begin{equation}
\alpha_k =
\begin{cases}
0 & \langle L(e_k),w \rangle < 0 \\
1 & \langle L(e_k),w \rangle > 0 \\
0 ~\text{or} ~ 1 & \langle L(e_k),w \rangle = 0
\end{cases}
\hspace{20pt} \text{or} \hspace{20pt}
\alpha_k =
\begin{cases}
1 & \langle L(e_k),w \rangle < 0 \\
0 & \langle L(e_k),w \rangle > 0 \\
0 ~\text{or} ~ 1 & \langle L(e_k),w \rangle = 0
\end{cases}
\end{equation}
Note that the two conditions are almost the same;
the first 2 cases merely swap 0 and 1,
and the third case is the same in both conditions.
The third case is not really new;
it comes from the definition of the square.
Also note that the order of $i$ and $j$ affects the definition of $w$,
but if $i$ and $j$ are swapped,
$w$ is changed to $-w$ which merely swaps the two conditions.
**Proof:**
Let $\lambda$ be the linear functional $z \mapsto \langle z,w \rangle$.
Since $\langle L(e_i),w \rangle = \langle L(e_j),w \rangle = 0$,
the values of $\alpha_i$ and $\alpha_j$ have no effect on $\lambda( L(x) )$.
Similarly, in the last case where $\langle L(e_k),w \rangle = 0$,
$\alpha_k$ has no effect.
This case only happens when $L(e_k)$ is a linear combination of $L(e_i)$ and $L(e_j)$,
and the corresponding facet is non-trivial with 6 or more edges.
The facet then requires a selected tiling,
and different tilings yield different assignments of 0 and 1 to $\alpha_k$.
If the square $\Sigma$ satisfies the first condition above,
then any $x \in \Sigma$ maximizes $\lambda( L(x) )$ over _all_ $x \in Q^n$.
Therefore $L(\Sigma) \subset \partial Z$, by the definition of $Z$.
If the square $\Sigma$ satisfies the second condition,
then $\lambda( L(x) )$ is minimized and the conclusion is the same.
Conversely, if the square satisfies neither condition,
then $\lambda( L(x) )$ for $x \in \Sigma$ is strictly between
the maximum and the minimum.
This means that $L(\Sigma)$ is in an intermediate hyperplane
orthogonal to $w$.
The intersection of an intermediate hyperplane with $\partial Z$
is only a 1-dimensional polygon and cannot contain a parallelogram.
Thus $L(\Sigma) \not\subset \partial Z$.
$\square$
Define a _slab_ in $\mathbb{R}^3$ to be the region between two parallel planes,
including the planes themselves.
In equation form, a slab $\mathcal{S}$ is given by
\begin{equation}
\mathcal{S} := \{ ~ x : \alpha \le \langle x,w \rangle \le \beta ~ \}
\end{equation}
where $w \in \mathbb{R}^3$ is the non-zero plane normal,
and $\langle x,w \rangle {=} \alpha$ and $\langle x,w \rangle {=} \beta$ are the two planes.
If $\alpha {<} \beta$ then each point in the boundary planes of $\mathcal{S}$
has a unique outward-pointing unit normal.
But if $\alpha {=} \beta$ then the planes coincide,
the slab degenerates to that plane,
and a normal cannot be assigned unambiguously.
Given an unordered pair $\{ i,j \}$ with $1 \le i , j \le n$
and $i \ne j$,
there are 2 antipodal parallelograms in $\partial Z$.
The edges of both parallelograms are the generators $L(e_i)$ and $L(e_j)$.
They define two distinct parallel planes and therefore a non-degenerate slab
denoted by $\mathcal{S}^{ \{i,j\} }$.
The slab has 2 well defined boundary normals,
which we assign to the 2 parallelograms in the boundary of the slab.
Note that if $u$ is the unit normal for one of the parallelograms $\mathcal{P}$,
then $u$ is a multiple of the cross product $L(e_i) \times L(e_j)$.
Now consider $S_2$.
Given an unordered pair $\{ i,j \}$ as above,
there are 2 antipodal parallelograms in $S_2$
and the edges of both are the generators $L(e_i)$ and $L(e_j)$.
These 2 parallelograms are parallel to each other;
let $\mathcal{S}_2^{ \{i,j\} }$ be the slab defined by them.
The 2 parallelograms in $\partial Z$ given by $\{ i,j \}$ have the same
edges - the generators $L(e_i)$ and $L(e_j)$.
So it is clear that $\mathcal{S}_2^{ \{i,j\} } \subseteq \mathcal{S}^{ \{i,j\} }$.
If this new slab is non-degenerate,
then each of the two parallelograms in $S_2$ can be matched to exactly one
of the two parallelogram in $\partial Z$
by choosing the one with the same normal vector.
If this new slab is degenerate, its outward-pointing normal is not defined,
and we can pick an assignment at random.
This completes the goal of this section.
An interesting observation:
since corresponding parallelograms are congruent,
they have the same surface area,
and therefore $S_2$ and $\partial Z$ have the same surface area as well.
# A Theorem about $S_2$ and the Convexity of $P$
We have seen that $S_2 \subsetneq Z$.
It is natural to ask:
When is $S_2$ as large as possible, namely the entire boundary of $Z$ ?
Recall our assumptions that $Z$ has a simple matroid, and is pointed.
**Theorem:**
With $Z$, $S_2$, $L_2$, and $P$ defined as above, the following are equivalent:
- $S_2 = \partial Z$
- $L_2$ is injective, and the inside region of $S_2$ is convex
- $P$ is a simple convex polygon, possibly with collinear vertices
The equivalence of properties 1 and 3 is proved in West & Brill @Brill1983,
except the sequence of vector generators in this theorem
is replaced by a continuous path of vectors in @Brill1983.
To our knowledge, property 2 is new.
**Proof:**
$1. \implies 2.$
$L_2$ is clearly injective on each square.
If a parallelogram of $S_2$ is in $\partial Z$ then it must be the
corresponding parallelogram (or its antipodal) in $\partial Z$
from the previous section.
This mapping of parallelograms is 1-1,
and since the parallelograms of $\partial Z$ are disjoint
(except on the edges)
the parallelograms of $S_2$ are disjoint (except on the edges).
Therefore $L_2$ is injective.
The inside region of $S_2$ is
the inside region of $\partial Z$, which is $Z$, which is convex.
$2. \implies 3.$ (trivial) The polygon $P$ is the
intersection of a hyperplane and the boundary of a convex polyhedron,
and that intersection is a convex polygon.
Since $L_2$ is injective, $P$ is simple.
$3. \implies 1.$
For a generator $L(e_i)$, let $v_i$ be the corresponding vertex of $P$.
It is the intersection of the ray generated by $L(e_i)$ and the
cutting hyperplane $K$.
Note that $v_i$ is a _positive_ multiple of $L(e_i)$.
Firstly we show that $S_2 \subseteq \partial Z$.
Let ${ \{i,j\} }$ be an unordered pair of indexes as above.
These indexes divide the remaining indexes into 2 contiguous circular sequences.
Let $\mathcal{P}$ be one of the corresponding parallelograms of $S_2$,
and let $u$ be its unit normal.
By definition, $\mathcal{P}$ is the image under $L$
of a 2-transition square $\Sigma$ in $Q^n_2$.
For $\Sigma$, all $\alpha_k$ in one sequence are 0,
and all $\alpha_k$ in the other sequence are 1.
We want to show that $\mathcal{P}$ is also in $\partial Z$.
Let $\mathcal{L}$ be the line through $v_i$ and $v_j$.
The plane given by $\langle x,u \rangle = 0$ contains both $L(e_i)$ and $L(e_j)$,
and so $\langle v_i,u \rangle = \langle v_j,u \rangle = 0$.
The line $\mathcal{L}$ divides $K$ into a positive side and a negative side.
For another vertex $v_k$,
$\langle L(e_k),u \rangle > 0$ iff $v_k$ is on the positive side of $\mathcal{L}$,
and
$\langle L(e_k),u \rangle < 0$ iff $v_k$ is on the negative side of $\mathcal{L}$.
Consider the relationship between $\mathcal{L}$ and $P$.
**Case i).** $\mathcal{L}$ intersects the interior of $P$
Since $P$ is convex, all the $v_k$ in one contiguous sequence
are on the positive side of $\mathcal{L}$ and
all the $v_k$ in the other contiguous sequence are on the negative side of $\mathcal{L}$.
This implies that
all the generators $L(e_k)$ in one contiguous sequence,
have $\langle L(e_k),u \rangle > 0$,
and all the generators $L(e_k)$ in the other contiguous sequence
have $\langle L(e_k),u \rangle < 0$.
But we saw earlier that the $\alpha_k$ in one sequence are all 0,
and the $\alpha_k$ in the other sequence are all 1.
This is exactly the condition given by the Lemma in the previous section.
Therefore $\mathcal{P} \subseteq \partial Z$.
**Case ii).** $\mathcal{L}$ intersects $\partial P$, but not the interior of $P$
This case is a little more subtle, but basically the same.
Since $P$ is convex, w.l.o.g. we can assume all $v_k$ are
either on $\mathcal{L}$ or on the negative side of $\mathcal{L}$.
Those on the negative side are part of contiguous sequence,
so for all these $k$, $\alpha_k$ is either 0 or 1.
For the $v_k$ that are **on** the line, $\langle L(e_k),u \rangle = 0$,
so the conditions in the above Lemma do not care whether
$\alpha_k$ is 0 or 1.
Thus all $\alpha_k$ satisfy the conditions of the Lemma
and so $\mathcal{P} \subset \partial Z$.
Secondly we show that $\partial Z \subseteq S_2$.
Let $\mathcal{P} \subset \partial Z$ and let $\Sigma$ be the square
whose image is $\mathcal{P}$.
We want to show that every $x \in \Sigma$ has 2-transitions.
**Case i).** $\mathcal{L}$ intersects the interior of $P$
Then for $k \not\in \{ i,j \}$,
all the generators $L(e_k)$ in one contiguous sequence
have $\langle L(e_k),u \rangle > 0$,
and all the generators $L(e_k)$ in the other contiguous sequence
have $\langle L(e_k),u \rangle < 0$.
In no case is $\langle L(e_k),u \rangle = 0$.
The Lemma then forces two possibilities for $\alpha_k$,
and both of them have 2 transitions.
**Case ii).** $\mathcal{L}$ intersects $\partial P$, but not the interior of $P$
We know $v_i$ and $v_j$ are on the line $\mathcal{L}$.
Let $\mathcal{I} := \{ ~ l : v_l \in \mathcal{L} ~ \}$.
Since $P$ is simple, the set of $v_l$ for $l \in \mathcal{I}$ is
contiguous in $P$.
If $i$ and $j$ are the only indexes in $\mathcal{I}$,
then since $P$ is simple and convex,
all the _other_ $v_k$ are contiguous and on one side of $\mathcal{L}$.
So by the Lemma, for all the _other_ $v_k$ either $\alpha_k=0$ or $\alpha_k=1$.
Therefore every $x \in \Sigma$ has 2 transitions.
If $\mathcal{I}$ has more than $i$ and $j$ then the generators
$L(e_l)$ for $l \in \mathcal{I}$ generate a non-trivial zonogon facet of $Z$.
Recall that this facet is tiled with the standard tiling.
Since $Z$ is pointed, the zonogon facet is also pointed.
And since $P$ is simple, the generators of the facet are in angular order.
By the property of the standard tiling in the [Zonotopes](zonotopes.html)
vignette,
we know that there are 2 transitions in the sequence of $\alpha_l$
for $l \in \mathcal{I}$.
Assume now that all vertices of the complementary sequence are
on the *negative* side of $\mathcal{L}$,
so all the complementary $\alpha_k = 0$.
When combined with the $\alpha_l$, the result is a 2-transition sequence,
for every $x \in \Sigma$.
If all vertices of the complementary sequence are
on the *positive* side of $\mathcal{L}$, then we can use the central
symmetry of $Z$ to show that the sequence for $x$ is the reflection,
and thus still has 2 transitions.
$\square$
# Strictly Starshaped Surfaces
`raytrace2trans()` is one of the important functions in the package **zonohedra**.
It expects that the 2-transition surface is nice enough
so that a given ray intersects the surface in a unique point.
This section explores the mathematics of this situation.
It is convenient to deal with abstract polyhedral surfaces in $\mathbb{R}^3$.
Let $S$ be a _polyhedral_ 2-sphere,
i.e. a sphere $\mathbb{S}^2$ that is tesselated by polygons,
and let $f: S \to \mathbb{R}^3$ be a continuous map that is injective
and linear on each polygon.
One can think of $f$ as a _piecewise-linear immersion_.
It may not be injective on all $S$, so the surface $f(S)$ may have self-intersections.
$f(S)$ is a _polyhedral surface_ in $\mathbb{R}^3$.
We call the surface polygons of $f(S)$ _facets_.
Since $S$ is orientable, we can choose a normal vector $n_i$ for each facet,
so that these normals are consistent across the edges.
A facet and its normal defines a positive halfspace for the facet,
and a negative halfspace for the facet.
The example we have in mind is the 2-transition surface $S_2$
associated with a zonohedron.
Given the vectors $n_i$ and a point $p \notin f(S)$
the _linking number_ of $p$ and $f(S)$ is defined as follows.
Choose a ray based at $p$ and not intersecting any edge of $f(S)$;
this is always possible.
Now examine every intersection of the ray with the interior of a facet.
If the ray crosses with the same orientation as $n_i$, assign a +1;
otherwise assign a -1.
The _linking number_ is defined to be the sum of all these +1s and -1s.
It is independent of the chosen ray.
Reversing the sign of every $n_i$ yields a consistent vector field
and changes the sign of the linking number.
The linking number is a straightforward generalization of the
_winding number_
of a closed polygonal curve in the plane
and a point not on the curve.
The linking number is the _degree_ of a certain projection map
(sometimes called the _Gauss map_ or _linking map_) that depends on $p$ and $f(S)$.
For more on this subject,
see @Milnor1997 p 53
and @Spivak1999 p. 296.
Suppose now that $f: S \to \mathbb{R}^3$ is injective.
It is well-known (@Alexander1924, @Moise1977 p. 117, and @Bing1983 p. 161)
that $f(S)$ divides $\mathbb{R}^3$ into
an inside region and an outside region whose intersection is $f(S)$.
Moreover, the inside region is homeomorphic to a closed ball,
and $f(S)$ is the boundary of that ball.
**Definition:**
Let $B \subseteq \mathbb{R}^3$ be a closed set and $b_0 \in B$.
Then $B$ is _starshaped at_ $b_0$ iff
for any $b \in B$ the segment $[b_0,b] \subseteq B$.
**Definition:**
Let $B \subseteq \mathbb{R}^3$ be a closed set with interior
and $b_0 \in \operatorname{int}(B)$.
Then $B$ is _strictly starshaped at_ $b_0$ iff
for any $b \in B$ the half-open segment
$[b_0,b) \subseteq \operatorname{int}(B)$.
So to be strictly starshaped, the segment $[b_0,b]$
cannot intersect $\partial B$ except possibly at $b$.
We now want to extend the concept of strictly starshaped
from bodies $B$ to surfaces $f(S)$.
**Definition:**
Let $f: S \to \mathbb{R}^3$ be as above, and $p \notin f(S)$.
Then $f(S)$ is _strictly starshaped at_ $p$ iff $f$ is injective
and the inside region $B$ is strictly starshaped at $p$.
Note that this definition forces $p$ to be in the interior of $B$.
**Theorem:**
Let $f: S \to \mathbb{R}^3$ be as above, and $p \notin f(S)$.
Then these are equivalent:
- $f(S)$ is strictly starshaped at $p$
- $f$ is injective, and every ray based at $p$ intersects $f(S)$ in
exactly one point
- the linking number of $f(S)$ and $p$ is +1 (resp. -1) and $p$
is in the negative (resp. positive) open halfspace of every facet of $f(S)$
`raytrace2trans()` is one of the important functions in the package **zonohedra**.
For the function to work well, we want Property b to be true
for the 2-transition surface $S_2$,
but its truth or falsity is not readily computable.
However, Property c. is easily computed, and if the surface fails the test,
then `raytrace2trans()` issues a warning
that the computed ray intersection may not be unique.
# Higher-Transition Points in the Cube $Q^n$
In Section 2, the 2-transition subcomplex $Q_2^n \subsetneq Q^n$ was defined;
it is the subset of points with 2 transitions.
We now want to define the number of transitions for _any_ point $x \in Q^n$.
When defining the subcomplex $Q_2^n$ above,
**Definition 2** used the set $J_2$ of all (step) functions on $[\beta_0,\beta_n]$
that take the values 0 or 1 and have two transitions or no transitions (jumps).
Let $J_\infty$ be the bigger set of all (step) functions on $[\beta_0,\beta_n]$
that take the values 0 or 1 and have a finite number of transitions.
The endpoints $\beta_0$ and $\beta_n$ are identified, to form a circle.
Equivalently, $J_\infty$ is the set of all indicator functions
$\mathbf{1}_{A^+}$ where $A^+$ is a finite disjoint union of arcs in the circle.
The symbol $\infty$ does not mean that there can be infinitely many transitions;
it means that the transition count is finite
but can be arbitrarily large.
The transition count is twice the number of arcs,
so for any $f \in J_\infty$
the transition count of $f$ is a well-defined even integer.
We now want to define the transition count of $x \in Q^n$ using
the function $p : J_\infty \twoheadrightarrow Q^n$,
which is defined exactly as in Section 2.
**Definition:** For any $x \in Q^n$ define
\begin{equation}
\text{transition count of} ~ x ~ := \min_{f \in p^{-1}(x)} \{ ~ \text{transition count of} ~ f ~ \}
\end{equation}
By this definition, all $x \in Q_2^n$ have 2 or 0 transitions.
But if $x \not\in Q_2^n$ then $x$ has more than 2 transitions.
Following @Burns2021, we say that $x$ is a _higher-transition point_.
Given an $x \in Q^n$, the transition count of $x$ is easily computable.
In the interval [0,1] the endpoints 0 and 1 are _boundary values_,
and all other values are _interior values_.
First consider the case when all coordinate values
of $x$ are 0 or 1, so $x$ is a vertex.
The maximum transition count is when 0 and 1 alternate.
A little consideration of small $n$ yields the following table of counts.
| | 3 | 4 | 5 | 6 | 7 | ... | $n$ |
|:-------------:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:---:|:-:|
| max transition count for a vertex $x$ | 2 | 4 | 4 | 6 | 6 | ... | $2 \lfloor n/2 \rfloor$ |
At the other extreme is when all coordinate values are interior values,
so $x$ is an interior point.
A little consideration of small $n$ shows that
one can make $x = p(f)$ when $f$ has transition counts in this table:
| | 3 | 4 | 5 | 6 | 7 | ... | $n$ |
|:-------------:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:---:|:-:|
| transition count for an interior point $x$ | 4 | 4 | 6 | 6 | 8 | ... | $2 \lfloor (n+1)/2 \rfloor$ |
Finally, consider the general $x \in Q^n$.
Find all runs of interior values,
and the 2 border values on either side of the run.
These 2 border values are either **equal** or **not equal**.
Let $r$ be the length of a run and look up the # of transitions
for this specific run in this table:
| | 1 | 2 | 3 | 4 | ... | $r$ |
|--------------:|:-:|:-:|:-:|:-:|:---:|:-:|
| equal border values | 2 | 2 | 4 | 4 | ... | $2 \lfloor (r+1)/2 \rfloor$ |
| unequal border values | 0 | 2 | 2 | 4 | ... | $2 \lfloor r/2 \rfloor$ |
The numbers in the header row are the possible lengths of the run of interior values.
For example, if the length of the run is 1, and the border values are equal
the transition count for this sequence is 2.
Take the sum of these counts over all runs of interior values.
Next, strip out all interior values completely, to leave a circular sequence of 0s and 1s.
Compute the number of transitions of this "stripped" sequence in the usual way,
and add to the previous sum.
This final sum is the transition count for any $x \in Q^n$.
This shows that $p : J_\infty \twoheadrightarrow Q^n$ truly is surjective.
We are mostly interested in the case when $L(x) \in \partial Z$,
and then $x$ has at most 2 interior values and
the length of a run of interior values is either 1 or 2.
From the above algorithm it is clear that for a fixed parallelogram
$\mathcal{P} \subset \partial Z$,
and for any $x$ that maps to the interior of $\mathcal{P}$,
the transition count of $x$ is a constant.
Thus we can write about the transition count for any
parallelogram $\mathcal{P} \subset \partial Z$.
Given indexes $i$ and $j$ of generators of $Z$, the transition count for
the corresponding parallelogram(s) in $\partial Z$ is fairly easy to compute.
The algorithm is in the proof of the theorem in section 7.
Let $\mathcal{L}$ be the line through vertices $v_i$ and $v_j$ in
the generator polygon $P$.
Then then transition count is the number of times that $\mathcal{L}$ cuts $P$.
This algorithm is also present in @Brill1983.
# Parallelograms in $S_2$ and $\partial Z$, revisited
By the previous theorem, if the generator polygon $P$ is **not** simple and convex,
then $S_2 \ne \partial Z$.
This means there is a parallelogram in $S_2$ that is in the interior of $Z$.
Let $\{ i,j \}$ be an unordered pair of indexes for such a parallelogram.
Consider the slabs $\mathcal{S}^{ \{i,j\} }$ and $\mathcal{S}_2^{ \{i,j\} }$ defined above.
For simplicity, drop the $\{ i,j \}$ to get just $\mathcal{S}$ and $\mathcal{S}_2$.
Since this parallelogram in $S_2$ is in the _interior_ of the slab,
the functional defining the slabs is not maximized on the parallelogram,
so we call it _deficient_.
The difference between the functional values on the two parallelograms is
called the _deficit_.
The corresponding parallelogram in $\partial Z$
is called _abundant_ because every $z$ in this parallelogram
is the image under $L$ of a higher-transition $x \in Q^n$.
To summarize, each deficient parallogram in $S_2$ has a matching
abundant parallelogram in $\partial Z$.
This is illustrated in the left side of the next figure.
The bold line segments correspond to the parallelograms and their antipodals.
The outward-pointing normals define the functionals to be maximized.
The 2 slabs are labeled.
Note $\mathcal{S}_2$ is a proper subset of $\mathcal{S}$;
in symbols $\mathcal{S}_2 \subsetneq \mathcal{S}$.
```{r, echo=FALSE, message=TRUE, warning=TRUE, fig.width=8, fig.height=3, fig.cap='Figure 10.1', out.width="100%", cache=FALSE }
plot_slabs <- function()
{
plot.new()
xlim = c(-10,10)
ylim = c(-7,7)
theta = 20 * pi/180
rot2x2 = matrix( c(cos(theta),sin(theta),-sin(theta),cos(theta)), 2, 2 )
plot.window( xlim, ylim, asp=1 )
# big slab
x = c(-15,15,15,-15)
y = c(-5,-5,5,5)
xy = rbind( x, y )
xyrot = rot2x2 %*% xy
polygon( xyrot[1, ], xyrot[2, ], col='gray90' )
xya = cbind( c(1,5), c(4,5) )
xyrot = rot2x2 %*% xya
xymid = rowMeans(xyrot)
lines( xyrot[1, ], xyrot[2, ], lwd=5 )
text( xymid[1], xymid[2], "abundant", adj=c(1,-1/2) )
lines( -xyrot[1, ], -xyrot[2, ], lwd=5 )
text( -xymid[1], -xymid[2], "abundant", adj=c(0,3/2) )
# small slab
ytop = 2.5
x = c(-15,15,15,-15)
y = c(-ytop,-ytop,ytop,ytop)
xy = rbind( x, y )
xyrot = rot2x2 %*% xy
polygon( xyrot[1, ], xyrot[2, ], col='gray80', lty=2 )
xyd = cbind( c(-ytop,ytop), c(0,ytop) )
xyrot = rot2x2 %*% xyd
xymid = rowMeans(xyrot)
lines( xyrot[1, ], xyrot[2, ], lwd=5 )
text( xymid[1], xymid[2], "deficient", adj=c(1,-1/2) )
lines( -xyrot[1, ], -xyrot[2, ], lwd=5 )
text( -xymid[1], -xymid[2], "deficient", adj=c(0,3/2) )
xya = cbind( c(-6,5), c(-6,5+2) )
xyrot = rot2x2 %*% xya
arrows( xyrot[1,1], xyrot[2,1], xyrot[1,2], xyrot[2,2], length=0.1, angle=20 )
arrows( -xyrot[1,1], -xyrot[2,1], -xyrot[1,2], -xyrot[2,2], length=0.1, angle=20 )
# label both slabs
x0 = 7
xy = cbind( c( x0, (5+ytop)/2 ), c( x0, -(5+ytop)/2 ) )
xyrot = rot2x2 %*% xy
text( xyrot[1, ], xyrot[2, ], expression( S ) )
xy = c( x0, 0 )
xyrot = rot2x2 %*% xy
text( xyrot[1], xyrot[2], expression( S[2] ) )
points( 0, 0, pch=20 )
#return( TRUE )
}
plot_slab <- function()
{
plot.new()
xlim = c(-10,10)
ylim = c(-8,8)
theta = 20 * pi/180
rot2x2 = matrix( c(cos(theta),sin(theta),-sin(theta),cos(theta)), 2, 2 )
plot.window( xlim, ylim, asp=1 )
# big slab
x = c(-15,15,15,-15)
y = c(-5,-5,5,5)
xy = rbind( x, y )
xyrot = rot2x2 %*% xy
polygon( xyrot[1, ], xyrot[2, ], col='gray80' )
xya = cbind( c(1,5), c(4,5) )
xyrot = rot2x2 %*% xya
xymid = rowMeans(xyrot)
lines( xyrot[1, ], xyrot[2, ], lwd=5 )
text( xymid[1], xymid[2], "coincident", adj=c(1,-1/2) )
lines( -xyrot[1, ], -xyrot[2, ], lwd=5 )
text( -xymid[1], -xymid[2], "coincident", adj=c(0,3/2) )
# arrows
xya = cbind( c(-6,5), c(-6,5+2) )
xyrot = rot2x2 %*% xya
arrows( xyrot[1,1], xyrot[2,1], xyrot[1,2], xyrot[2,2], length=0.1, angle=20 )
arrows( -xyrot[1,1], -xyrot[2,1], -xyrot[1,2], -xyrot[2,2], length=0.1, angle=20 )
# label slab
xy = c( 6, 0 )
xyrot = rot2x2 %*% xy
text( xyrot[1], xyrot[2], expression( S[2] == S ) )
points( 0, 0, pch=20 )
}
oldpar = par( mfrow=c(1,2) , omi=c(0,0,0,0), mai=c(0,0.1,0,0.1) )
plot_slabs() ; plot_slab()
par( oldpar )
```
On the other hand,
if a parallelogram of $S_2$ is in the boundary of the slab $\mathcal{S}$,
then the two parallelograms are equal and we call them _coincident_.
It means that every $z$ in this parallelogram
is the image of an $x \in Q^n$ that has 2 (or 0) transitions.
This is illustrated in the right side of the above figure.
To get data about the abundant and coincident parallelograms in $\partial Z$,
use the functions `transitionsdf()`, for example:
```{r, echo=TRUE, message=TRUE, warning=TRUE }
matgen = colorimetry.genlist[[2]] # the CIE 1931 CMFs at 1nm step
matgen = 100 * matgen / sum( matgen[2, ] ) # it's traditional to scale so the center has Y=50
zono = zonohedron( matgen )
getcenter(zono) ; dim( getmatrix( getsimplified( getmatroid(zono) ) ) )
transitionsdf( zono )
```
The number of (simplified) generators of `zono` is $n{=}340$,
indexed from 360 to 699.
So the total number of parallelograms is $340(340{-}1)=115260$.
Data in the first row are for the coincident parallelograms, with 2 transitions.
These form the majority of $\partial Z$,
with about 33110/34669 = 95.5% of the surface area.
Data in the rows below is for the abundant parallelograms.
More transitions typically have fewer parallelograms.
The last column has an example of a parallelogram with the given
transition count.
For example, there are 1802 parallelograms in $\partial Z$ with 8 transitions,
and the one given by generators $\{ 570,608 \}$ is one of them.
This means that the line through $v_{570}$ and $v_{608}$ cuts $P$ in 8 places.
Here is a plot of the point in the cube that maps to the center
of the parallelogram:
```{r, echo=TRUE, message=TRUE, warning=TRUE, fig.width=6.5, fig.height=3, fig.cap='Figure 10.2', out.width="100%", cache=FALSE }
oldpar = par( omi=c(0,0,0,0), mai=c(0.45,0.5,0.1,0) )
gnd = getground( getsimplified( getmatroid(zono) ) )
pcube = boundarypgramdata( zono, c(570,608), cube=TRUE )$pcube
xlim = range( gnd[which(0
The following figure is a helpful 3D visualization
of *all* the abundant parallelograms:
```{r, rgl=TRUE, dev='png', echo=TRUE, message=TRUE, warning=FALSE, fig.width=6.5, fig.height=4, fig.cap='Figure 10.3', fig.keep='last', fig.show='hold', out.width="100%", cache=FALSE }
library( orientlib )
user3x3 = orientlib::rotmatrix( orientlib::eulerzyx( -0.249417, 0.7116067, 2.324364 ) )@x
dim(user3x3) = c(3,3)
par3d( userMatrix=rotationMatrix(matrix=user3x3), zoom=0.35 )
plothighertrans( zono )
```
In this figure, the abundant parallelograms are color-coded following @Burns2021;
dark red for 4, yellow for 6, blue for 8, and purple for 10 transitions.
The view is looking up the "neutral axis" with a black point at 0,
a white point at the opposite point, and a gray point at the
center of symmetry.
The central symmetry of the abundant parallelograms is clear.
Compare this with Figure 7 in @Burns2021.
# References
# Session Information
This document was prepared
`r format(Sys.Date(), "%a %b %d, %Y")`
with the following configuration:
```{r, echo=FALSE, results='asis'}
options( old_opt )
sessionInfo()
```