Synopsis
double mth_PointToLineDistProjParm(long option, int dim, double *pnt, double *line_pnt, double *line_vec_or_pnt, double *proj_pnt, double *parm)
Purpose
Find the projection of a point to a line
Description
The distance between a point and a straight line, the projected point of the point to the line, and the parameter of the projected point on the line are computed. If the line is a degenerate one, i.e. a point, the distance between the point and line_pnt on the line will be returned as the needed distance and line_pnt will be the projected point.
When the distance is 0, the parameter value can be used to determine if the point is located between the two endpoints, yes if 0 <= parm <= 1; no otherwise.
Input
option
MTH_PTVEC
Option giving form of line definition. If MTH_PTVEC is set, the line is in point/vector format, and line_vec_or_pnt is a direction vector; otherwise, it is a point on the line.
dim
The dimension of points (2 or 3)
pnt
The point
line_pnt
The point on the line
line_vec_or_pnt
Either a second point on the line or a direction vector
Output
proj_pnt
The projected point
parm
MTH_NOOPT
proj_pnt = (1-parm)*line_pnt + parm*line_vec_or_pnt;
MTH_PTVEC
proj_pnt = line_pnt + parm*line_vec_or_pnt.
Tolerances
MTH_ZERO_TOL
Return
Distance between the point and the line