Bioplib
Protein Structure C Library
|
Calculate distance from a point to a line. More...
Go to the source code of this file.
Macros | |
#define | CROSSPRODUCT(p1, p2, p3) |
#define | DOTPRODUCT(v1, v2) ((v1).x*(v2).x + (v1).y*(v2).y + (v1).z*(v2).z) |
Functions | |
REAL | blPointLineDistance (REAL Px, REAL Py, REAL Pz, REAL P1x, REAL P1y, REAL P1z, REAL P2x, REAL P2y, REAL P2z, REAL *Rx, REAL *Ry, REAL *Rz, REAL *frac) |
Calculate distance from a point to a line.
This code is NOT IN THE PUBLIC DOMAIN, but it may be copied according to the conditions laid out in the accompanying file COPYING.DOC.
The code may be modified as required, but any modifications must be documented so that the person responsible can be identified.
The code may not be sold commercially or included as part of a commercial product except as described in the file COPYING.DOC.
Definition in file pldist.c.
#define CROSSPRODUCT | ( | p1, | |
p2, | |||
p3 | |||
) |
#define DOTPRODUCT | ( | v1, | |
v2 | |||
) | ((v1).x*(v2).x + (v1).y*(v2).y + (v1).z*(v2).z) |
REAL blPointLineDistance | ( | REAL | Px, |
REAL | Py, | ||
REAL | Pz, | ||
REAL | P1x, | ||
REAL | P1y, | ||
REAL | P1z, | ||
REAL | P2x, | ||
REAL | P2y, | ||
REAL | P2z, | ||
REAL * | Rx, | ||
REAL * | Ry, | ||
REAL * | Rz, | ||
REAL * | frac | ||
) |
[in] | Px | Point x coordinate |
[in] | Py | Point y coordinate |
[in] | Pz | Point z coordinate |
[in] | P1x | Line start x coordinate |
[in] | P1y | Line start y coordinate |
[in] | P1z | Line start z coordinate |
[in] | P2x | Line end x coordinate |
[in] | P2y | Line end y coordinate |
[in] | P2z | Line end z coordinate |
[out] | *Rx | Nearest point on line x coordinate |
[out] | *Ry | Nearest point on line y coordinate |
[out] | *Rz | Nearest point on line z coordinate |
[out] | *frac | Fraction along P1-P2 of R |
Calculates the shortest distance from a point P to a line between points P1 and P2. This value is returned.
If the Rx,Ry,Rz pointers are all non-NULL, then the point on the line nearest to P is output.
If the frac pointer is non-NULL then the fraction of R along the P1-P2 vector is output. Thus: R==P1 ==> frac=0 R==P2 ==> frac=1 Thus if (0<=frac<=1) then the point R is within the line segment P1-P2