Learn R Programming

clugenr (version 1.0.4)

points_on_line: Determine coordinates of points on a line

Description

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 n-dimensional unit vector. In other words, considering d=d = as.matrix(direction) (n 1n x 1 vector), c=c = as.matrix(center) (n 1n x 1 vector), and w=w = as.matrix(dist_center) (p 1p x 1 vector), the coordinates of points on the line are given by:

P=1\,c^T + wd^T P = 1c' + wd'

where PP is the p np x n matrix of point coordinates on the line, and 11 is a p 1p x 1 vector with all entries equal to 1.

Usage

points_on_line(center, direction, dist_center)

Value

Coordinates of points on the specified line (p np x n matrix).

Arguments

center

Center of the line (n-component vector).

direction

Line direction (n-component unit vector).

dist_center

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

Examples

Run this code
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

Run the code above in your browser using DataLab