points_on_line: Determine coordinates of points on a line

View source: R/core.R

points_on_lineR Documentation

Determine coordinates of points on a line

Description

\loadmathjax

Determine coordinates of points on a line with center and direction, based on the distances from the center given in dist_center.

This works by using the vector formulation of the line equation assuming direction is a \mjseqnn-dimensional unit vector. In other words, considering \mjeqn\mathbfd=d = as.matrix(direction) (\mjeqnn \times 1n x 1 vector), \mjeqn\mathbfc=c = as.matrix(center) (\mjeqnn \times 1n x 1 vector), and \mjeqn\mathbfw=w = as.matrix(dist_center) (\mjeqnp \times 1p x 1 vector), the coordinates of points on the line are given by:

\mjdeqn\mathbf

P=\mathbf1\,\mathbfc^T + \mathbfw\mathbfd^T P = 1c' + wd'

where \mjeqn\mathbfPP is the \mjeqnp \times np x n matrix of point coordinates on the line, and \mjeqn\mathbf11 is a \mjeqnp \times 1p x 1 vector with all entries equal to 1.

Usage

points_on_line(center, direction, dist_center)

Arguments

center

Center of the line (\mjseqnn-component vector).

direction

Line direction (\mjseqnn-component unit vector).

dist_center

Distance of each point to the center of the line (\mjseqnn-component vector, where \mjseqnn is the number of points).

Value

Coordinates of points on the specified line (\mjeqnp \times np x n matrix).

Examples

points_on_line(c(5, 5), c(1, 0), seq(-4, 4, length.out=5)) # 2D, 5 points

points_on_line(c(-2, 0, 0, 2), c(0, 0, -1, 0), c(10, -10)) # 4D, 2 points

clugenr documentation built on Aug. 8, 2025, 6:05 p.m.