This vignette will demonstrate how to plot the interpolated path with the woylier package.
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)
1D projection of data in high dimension linear combination of data that is normalized. Therefore, we can plot the point on the surface of a hypersphere. The plot below the Givens interpolation steps between 2 points, 1D projection of 6D data that is.
# Generate 1D example
set.seed(2022)
<- 6
p <- tourr::basis_random(p, d=1)
base1 <- tourr::basis_random(p, d=1)
base2
# First example
<- givens_full_path(base1, base2, nsteps = 10)
frames <- generate_space_view(p=p)
sp <- add_path(sp, frames)
sp_path <- as.data.frame(t(base1))
point1 $type <- "point1"
point1<- as.data.frame(t(base2))
point2 $type <- "point2"
point2<- rbind(sp_path, point1, point2)
sp_path
p#> [1] 6
::animate_xy(sp_path[,1:p], col=sp_path$type,
tourraxes="bottomleft")
#> Converting input data to the required matrix format.
#> Using half_range 0.55
In case of 2D projections, we can plot the interpolated path between 2 frames on the surface of torus. Torus can be seen as crossing of 2 circles that are orthonormal.
# Generate 2D example
set.seed(2022)
<- 1000
n <- 3
p <- 2
d <- tourr::basis_random(p, d)
base1 <- tourr::basis_random(p, d)
base2 <- givens_full_path(base1, base2, 10)
frames_2d <- map(1:n, ~tourr::basis_random(n = p, d=d)) %>%
proj_2d ::flatten_dbl() %>%
purrrmatrix(ncol = p*2, byrow = TRUE) %>%
as_tibble()
#> Warning: The `x` argument of `as_tibble.matrix()` must have unique column names if
#> `.name_repair` is omitted as of tibble 2.0.0.
#> ℹ Using compatibility `.name_repair`.
# Path
<- t(apply(frames_2d, 3, c)) %>%
path_2d as.data.frame()
# Join
<- proj_2d %>%
proj_2d mutate(type="torus")
<- path_2d %>%
path_2d mutate(type="path")
<- bind_rows(proj_2d, path_2d)
proj_path ::animate_xy(proj_path[,1:6],
tourrcol=proj_path$type,
axes="bottomleft")
#> Converting input data to the required matrix format.
#> Using half_range 0.73