
Generate equidistant vectors in Euclidean space
Source:R/equidistant_vectors.R
equidistant_vectors.RdThis function constructs the coordinates of vertices of a regular simplex
in \(\mathbb{R}^{\code{dim}}\) and returns the first n of them,
scaled so that the pairwise Euclidean distance between any two vertices equals
dist,and centered so their centroid is at
center.
Usage
equidistant_vectors(dim, n = dim + 1, dist = 1, center = rep(0, dim))Examples
dim <- n <- 3
(dist <- runif(1))
#> [1] 0.3746926
(center <- rnorm(dim))
#> [1] 1.0369321 -0.7828198 -0.4083905
(V <- equidistant_vectors(dim = dim, n = n, dist = dist, center = center))
#> [,1] [,2] [,3]
#> [1,] 1.2408889 0.9349537 0.9349537
#> [2,] -0.8188747 -0.6025458 -0.9270391
#> [3,] -0.4708392 -0.4708392 -0.2834929
rowMeans(V)
#> [1] 1.0369321 -0.7828198 -0.4083905
dist(t(V))
#> 1 2
#> 2 0.3746926
#> 3 0.3746926 0.3746926