get_dist_point_line: Compute distance between a point and a line

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/analytical_functions.R

Description

Compute distance between a point and a line

Usage

1
get_dist_point_line(point, line_coord1, line_coord2)

Arguments

point

2D or 3D coordinates of the point as c(x,y) or c(x,y,z)

line_coord1

2D or 3D coordinates of one point on the line as c(x,y) or c(x,y,z)

line_coord2

2D or 3D coordinates of a second point on the line as c(x,y) or c(x,y,z)

Details

The function accepts 2D coordinates or 3D coordinates, but note that the dimensions of all supplied arguments must match; all coordinates must be 2D or they all must be 3D.

Value

A numeric vector of length 1 that provides the euclidean distance between the point and the line.

Author(s)

Vikram B. Baliga

See Also

Other mathematical functions: calc_min_dist_v(), deg_2_rad(), find_curve_elbow(), get_2d_angle(), get_3d_angle(), get_3d_cross_prod(), get_velocity(), rad_2_deg()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## 2D case
get_dist_point_line(
  point = c(0, 0),
  line_coord1 = c(1, 0),
  line_coord2 = c(1, 5)
)

## 3D case
get_dist_point_line(
  point = c(0, 0, 0),
  line_coord1 = c(1, 0, 0),
  line_coord2 = c(1, 5, 0)
)

pathviewr documentation built on May 6, 2021, 9:07 a.m.