
Generate equidistant vectors in Euclidean space
Source:R/equidistant_vectors.R
equidistant_vectors.Rd
This 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.8884956
(center <- rnorm(dim))
#> [1] -1.6545922 -1.5794826 0.7969991
(V <- equidistant_vectors(dim = dim, n = n, dist = dist, center = center))
#> [,1] [,2] [,3]
#> [1,] -1.1709565 -1.8964101 -1.896410
#> [2,] -1.6649781 -1.1520049 -1.921465
#> [3,] 0.6489165 0.6489165 1.093164
rowMeans(V)
#> [1] -1.6545922 -1.5794826 0.7969991
dist(t(V))
#> 1 2
#> 2 0.8884956
#> 3 0.8884956 0.8884956