Function Repository Resource:

# PointLineDistance

Get the distance and normal line between a point and line

Contributed by: Ed Pegg Jr
 ResourceFunction["PointLineDistance"][p,{a,b}] returns the distance between the point p and the infinite line through points a and b, as well as the coordinates realizing that distance. ResourceFunction["PointLineDistance"][Point[p],Line[{a,b}]] returns the distance between point p and the infinite line through points a and b, as well as the Line realizing that distance.

## Examples

### Basic Examples (2)

Calculate distance and normal line for (1,1) and the x-axis:

 In[1]:=
 Out[3]=

Show the construction:

 In[4]:=
 Out[5]=

For just the distance, RegionDistance can be used:

 In[6]:=
 Out[6]=

For the point on the line, RegionNearest can be used:

 In[7]:=
 Out[7]=

For a more arbitrary point, the line is assumed to be infinite:

 In[8]:=
 Out[10]=

With RegionNearest, InfiniteLine must be specified:

 In[11]:=
 Out[12]=

### Scope (2)

Using Point and Line is optional:

 In[13]:=
 Out[15]=

Use PointLineDistance on a point and line in 3D:

 In[16]:=
 Out[17]=

### Applications (2)

Plot a tilted cylinder:

 In[18]:=
 Out[18]=

A parabola can be defined as the locus of points that are equidistant between a given point (the focus) and a given line (the directrix). Plot a parabola, given a focus and directrix:

 In[19]:=
 Out[19]=

## Version History

• 1.0.0 – 18 April 2022