Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Get the distance and normal line between a point and line
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. | |
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]= |
Using Point and Line is optional:
In[13]:= |
Out[15]= |
Use PointLineDistance on a point and line in 3D:
In[16]:= |
Out[17]= |
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]= |
This work is licensed under a Creative Commons Attribution 4.0 International License