points_positions: Find point locations when distances between them are known

View source: R/main.R

points_positionsR Documentation

Find point locations when distances between them are known

Description

If you have k points and distances between all pairs function will try to find locations for those points in n-dimensional Cartesian Space.

Usage

points_positions(dm, error = 0.001, fnc = "mean", n_dim = NULL, max_iter = 200)

Arguments

dm

Distance matrix

error

error threshold, stop condition - default value 0.001 means 0.1%

fnc

method for calculation tolerance for stop conditions, by default "mean" (mean error for all distances between points), other option - "max", see vignette "dist2location algorithms" for details

n_dim

Dimension of space where points should be located. When distance matrix includes information about k points and n is not set, n-1 dimensional space will be chosen

max_iter

stop condition, if number of iteration is exceeded (default value = 200) function will stop

Details

Algorithms used by this function adjust point locations to optimize error related with difference between current and expected (set as input in Distance Matrix) distances between points. The criterion for decision to stop the calculations is set in parameters error and max_iter Default values (stop = 0.001, max_iter = 100).

Run vignette("dist2location_algorithms") for details.

To check how to create Distance Matrix run: vignette("dist2location")

Value

list l l[["positions]] - data frame with point with positions (n rows for n points, m columns for m dimensions) l[["error]] - error

Examples

# Find positions of vertexes of Regular tetrahedron (where distances between all vertexes are equal to 1)

# Define distance matrix
dist_m <- matrix(c(0,1,1,1,
                  1,0,1,1,
                  1,1,0,1,
                  1,1,1,0), nrow = 4, ncol = 4, byrow = TRUE)

# Find positions
result <- points_positions(dist_m)

positions <- result[["positions"]]


maszdev/dist2location documentation built on June 11, 2025, 11:55 a.m.