points_on_line | R Documentation |
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:
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.
points_on_line(center, direction, dist_center)
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). |
Coordinates of points on the specified line (\mjeqnp \times np x n matrix).
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.