
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))See also
Other vector helpers:
check_numeric_vector(),
check_probability_vector(),
chunk_vector(),
insert_vector_entry(),
map_indices(),
match_numerics(),
permutations(),
split_vector_at(),
subsets(),
vector_occurrence()
Examples
dim <- n <- 3
(dist <- runif(1))
#> [1] 0.1585943
(center <- rnorm(dim))
#> [1] 0.795886 -1.094739 1.073491
(V <- equidistant_vectors(dim = dim, n = n, dist = dist, center = center))
#> [,1] [,2] [,3]
#> [1,] 0.8822138 0.752722 0.752722
#> [2,] -1.1100001 -1.018436 -1.155782
#> [3,] 1.0470585 1.047058 1.126356
rowMeans(V)
#> [1] 0.795886 -1.094739 1.073491
dist(t(V))
#> 1 2
#> 2 0.1585943
#> 3 0.1585943 0.1585943