---
title: "Paths in the Space of Arcs"
author: "Glenn Davis"
date: "`r Sys.Date()`"
output:
rmarkdown::html_vignette:
toc: true
toc_depth: 2
number_sections: false
bibliography: bibliography.bib
# csl: iso690-numeric-brackets-cs.csl
csl: personal.csl
# csl: institute-of-mathematical-statistics.csl
# csl: transactions-on-mathematical-software.csl
vignette: >
%\VignetteIndexEntry{Paths in the Space of Arcs}
%\VignetteEngine{knitr::rmarkdown}
---
```{css, echo=FALSE}
body {
max-width: 725px; /* make wider, default is 700px */
}
h1{
font-size: 20pt; /* make the level 1 headers smaller */
}
```
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
old_opt = options( width=144 )
```
# Introduction
```{r, echo=TRUE, message=FALSE}
library(polarzonoid)
```
In the [User Guide](../doc/polarzonoid-guide.html) vignette
it is shown that there is are homeomorphisms
\begin{equation}
A_n ~~ \longleftrightarrow ~~ \partial Z_n ~~ \longleftrightarrow ~~ \mathbb{S}^{2n}
\end{equation}
where $A_n$ is the space of $n$ or fewer pairwise disjoint arcs in the circle,
and $Z_n$ is the polar zonoid in $\mathbb{R}^{2n+1}$.
In this vignette, we take some easily-defined paths in the sphere $\mathbb{S}^{2n}$,
compute the corresponding paths in the space of arcs $A_n$,
and display those paths as animated GIF plots.
We make these plots with help of the package **gifski** and this function:
```{r, echo=TRUE, message=FALSE}
GIFfromarclist <- function( arclist, arcmat, index=1L, fps=5, vpsize=c(480,512) )
{
require( 'gifski' )
# make temp folder
pathtemp = tempdir() # "./figs" ; if( ! file.exists(pathtemp) ) dir.create(pathtemp)
count = length( arclist )
namevec = names( arclist )
for( k in 1:count )
{
filename = sprintf( "%s/plot%03d.png", pathtemp, k )
png( filename=filename, width=vpsize[1], height=vpsize[2], units = "px" )
u = spherefromarcs( arclist[[k]] )
plotarcs( arclist[[k]], labels=FALSE, margintext=namevec[k] )
plotarcs( arcmat, labels=FALSE, rad=0.95, col='blue', lwd=1, add=TRUE )
dev.off()
}
pathvec = dir( pathtemp, pattern="png$", full=T )
gif_file = sprintf( "%s/animation%g.gif", pathtemp, index )
out = gifski( pathvec, gif_file=gif_file, delay=1/fps, progress=F, width=vpsize[1], height=vpsize[2] )
res = file.remove( pathvec ) # cleanup the .PNG files, leaving just the .GIF
return(out)
}
```
# The Tubular Neighborhood of $A_n \subseteq A_{n+1}$
$A_n$ is a _stratum_ in $A_{n+1}$ and there is a _tubular neighborhood_
of $A_n$ in $A_{n+1}$.
Since the codimension is 2, the fiber of a point $a \in A_n$ in the neighborhood
is an open 2-disk $\text{int}(D^2)$.
The boundary of the 2-disk is a circle,
which we think of this circle as a closed path of points at
a small and equal distance from $a$.
We can compute this circle by mapping $a$ to $\mathbb{S}^{2n+2}$
using the homeomorphism
$A_{n+1} ~ \rightleftarrows ~ \mathbb{S}^{2n+2}$,
computing the circle in $\mathbb{S}^{2n+2}$,
and then mapping back to $A_{n+1}$ using the inverse homeomorphism.
The function we will use is:
```{r, echo=TRUE, message=FALSE}
circleofarcs <- function( arcmat, rad=0.1, count=180 )
{
res = spherefromarcs_plus( arcmat, n=nrow(arcmat)+1L )
out = vector( count, mode='list' )
namevec = character( count )
for( i in 1:count )
{
theta = 2*pi * (i-1)/count # theta is in radians, starting at 0
u = res$u + rad * ( cos(theta)*res$normal[ ,1] + sin(theta)*res$normal[ ,2] )
out[[i]] = arcsfromsphere( u ) # u is automatically unitized
namevec[i] = sprintf( "i = %d", i )
}
names(out) = namevec
return( out )
}
```
The case of $n{=}0$ is easy to visualize.
The space $A_0$ is 2 points, which map to the "poles" of the sphere $\mathbb{S}^2$.
The empty arc maps to the "south" and the full circle maps to the "north"
Around each pole is a small circle.
For the "south pole" it is a circle of tiny arcs, almost empty.
For the "north pole" it is a circle of very large arcs, almost the full circle.
In both cases, the length of the arcs is constant, while the center loops around
$\mathbb{S}^1$.
# A Circle of Arcs in $A_2$ around a Single Arc in $A_1$
The goal of this section is to take a single arc $a \in A_1$
and plot the 2 arcs in $A_2$ that circle around $a$.
```{r, echo=TRUE, message=FALSE, warning=TRUE, fig.cap='caption', fig.keep='last', fig.show='hide', cache=FALSE }
# arcmat1 is a single semicircle centered at (1,0)
arcmat1 = matrix( c(0,pi), nrow=1, ncol=2 )
circle = circleofarcs( arcmat1, count=90 )
gif_file = GIFfromarclist( circle, arcmat1, index=1, vpsize=c(480,480) )
```
```{r, echo=FALSE, results='asis'} options(old_opt) sessionInfo() ```