Skip to contents

The “woylier” package provides alternative method for generating a tour path by interpolating between d-D frames in p-D space rather than d-D planes. A tour path is a sequence of projection and we use interpolation method to produce the path. The package uses geodesic interpolation between planes. Geodesic interpolation path is the locally shortest path between planes with no within-plane spin. As a result of this method, the rendered target plane could be the rotated version of the target plane we wanted. This is not a problem when the structure we are looking can be identified without turning the axis around.

The “woylier” package implements the Givens interpolation paths method proposed by Buja et al. (2005) in R. This algorithm adapts Given’s matrix decomposition technique which allows the interpolation to be between frames rather than planes.

Installation

You can install the development version of woylier from GitHub with:

# install.packages("remotes")
remotes::install_github("numbats/woylier")
library(woylier)
library(geozoo)
library(ggplot2)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(purrr)

Example 1

In this example, we have 2 random 1D basis in 6D data space and the givens_full_path() function returns the intermediate interpolation step projections in given number of steps. The code chunk below demonstrates the interpolation between 2 random basis in 5 steps.

# Generate 1D example

set.seed(2022)
p <- 6
base1 <- tourr::basis_random(p, d=1)
base2 <- tourr::basis_random(p, d=1)

base1
#>             [,1]
#> [1,]  0.24406482
#> [2,] -0.31814139
#> [3,] -0.24334450
#> [4,] -0.39166263
#> [5,] -0.08975114
#> [6,] -0.78647758

base2
#>            [,1]
#> [1,] -0.6256883
#> [2,]  0.1641842
#> [3,]  0.4427114
#> [4,]  0.1426996
#> [5,]  0.5943406
#> [6,] -0.1093633

givens_full_path(base1, base2, nsteps = 5)
#> , , 1
#> 
#>             [,1]
#> [1,]  0.01086858
#> [2,] -0.27240617
#> [3,] -0.08264232
#> [4,] -0.35891689
#> [5,]  0.14040479
#> [6,] -0.87767429
#> 
#> , , 2
#> 
#>             [,1]
#> [1,] -0.22389989
#> [2,] -0.18726515
#> [3,]  0.09001476
#> [4,] -0.27425086
#> [5,]  0.35025000
#> [6,] -0.84190816
#> 
#> , , 3
#> 
#>             [,1]
#> [1,] -0.42627939
#> [2,] -0.07503468
#> [3,]  0.24965046
#> [4,] -0.14991218
#> [5,]  0.50942866
#> [6,] -0.68435306
#> 
#> , , 4
#> 
#>              [,1]
#> [1,] -0.566994057
#> [2,]  0.048050183
#> [3,]  0.373172156
#> [4,] -0.003887462
#> [5,]  0.594914254
#> [6,] -0.427800630
#> 
#> , , 5
#> 
#>            [,1]
#> [1,] -0.6256883
#> [2,]  0.1641842
#> [3,]  0.4427114
#> [4,]  0.1426996
#> [5,]  0.5943406
#> [6,] -0.1093633

Example 2

In this example, we have 2 random 2D basis in 6D data space and the givens_full_path() function returns the intermediate interpolation step projections in given number of steps. The code chunk below demonstrates the interpolation between 2 random basis in 5 steps.

# Generate 2D example

set.seed(2022)
p <- 6
base3 <- tourr::basis_random(p, d=2)
base4 <- tourr::basis_random(p, d=2)

base3
#>             [,1]        [,2]
#> [1,]  0.24406482 -0.57724655
#> [2,] -0.31814139  0.06085804
#> [3,] -0.24334450  0.38323969
#> [4,] -0.39166263  0.01182949
#> [5,] -0.08975114  0.59899558
#> [6,] -0.78647758 -0.39657839

base4
#>             [,1]        [,2]
#> [1,] -0.64550501 -0.17034478
#> [2,]  0.06108262  0.87051018
#> [3,] -0.03470326  0.26771612
#> [4,] -0.05281183  0.25452167
#> [5,] -0.43004248  0.27472455
#> [6,] -0.62502981  0.03560765

givens_full_path(base3, base4, nsteps = 5)
#> , , 1
#> 
#>             [,1]        [,2]
#> [1,]  0.02498501 -0.57102411
#> [2,] -0.26080833  0.26278410
#> [3,] -0.19820064  0.40434178
#> [4,] -0.35542927  0.08341593
#> [5,] -0.14433023  0.57626698
#> [6,] -0.86308174 -0.31951242
#> 
#> , , 2
#> 
#>            [,1]       [,2]
#> [1,] -0.1909937 -0.5290164
#> [2,] -0.1874044  0.4550600
#> [3,] -0.1459678  0.4046873
#> [4,] -0.2970111  0.1522888
#> [5,] -0.2003186  0.5261305
#> [6,] -0.8824688 -0.2197674
#> 
#> , , 3
#> 
#>             [,1]       [,2]
#> [1,] -0.38527579 -0.4457635
#> [2,] -0.10411664  0.6258684
#> [3,] -0.09577045  0.3811614
#> [4,] -0.22183655  0.2089977
#> [5,] -0.26412984  0.4533801
#> [6,] -0.84414115 -0.1137724
#> 
#> , , 4
#> 
#>             [,1]        [,2]
#> [1,] -0.54115467 -0.32350096
#> [2,] -0.01855341  0.76518462
#> [3,] -0.05630484  0.33422743
#> [4,] -0.13748432  0.24504604
#> [5,] -0.34020920  0.36617868
#> [6,] -0.75431619 -0.02150119
#> 
#> , , 5
#> 
#>             [,1]        [,2]
#> [1,] -0.64550501 -0.17305000
#> [2,]  0.06108262  0.86649508
#> [3,] -0.03470326  0.26851774
#> [4,] -0.05281183  0.25487107
#> [5,] -0.43004248  0.27511042
#> [6,] -0.62502981  0.03766958