# pointOnLine

0th

Percentile

##### Position of a point along a line

A utility function for drawing vector diagrams. Find position of an interpolated point along a line from x1 to x2.

##### Usage
pointOnLine(x1, x2, d, absolute = TRUE)
##### Arguments
x1

A vector of length 2 or 3, representing the starting point of a line in 2D or 3D space

x2

A vector of length 2 or 3, representing the ending point of a line in 2D or 3D space

d

The distance along the line from x1 to x2 of the point to be found.

absolute

logical; if TRUE, d is taken as an absolute distance along the line; otherwise it is calculated as a relative distance, i.e., a fraction of the length of the line.

##### Details

The function takes a step of length d along the line defined by the difference between the two points, x2 - x1. When absolute=FALSE, this step is proportional to the difference, while when absolute=TRUE, the difference is first scaled to unit length so that the step is always of length d. Note that the physical length of a line in different directions in a graph depends on the aspect ratio of the plot axes, and lines of the same length will only appear equal if the aspect ratio is one (asp=1 in 2D, or aspect3d("iso") in 3D).

##### Value

The interpolated point, a vector of the same length as x1

Other vector diagrams: Proj, arc, arrows3d, circle3d, corner, plot.regvec3d, regvec3d, vectors3d, vectors

• pointOnLine
##### Examples
# NOT RUN {
x1 <- c(0, 0)
x2 <- c(1, 4)
pointOnLine(x1, x2, 0.5)
pointOnLine(x1, x2, 0.5, absolute=FALSE)
pointOnLine(x1, x2, 1.1)

y1 <- c(1, 2, 3)
y2 <- c(3, 2, 1)
pointOnLine(y1, y2, 0.5)
pointOnLine(y1, y2, 0.5, absolute=FALSE)
# }

Documentation reproduced from package matlib, version 0.9.2, License: GPL (>= 2)

### Community examples

Looks like there are no examples yet.