Bioplib
Protein Structure C Library
 All Data Structures Files Functions Variables Typedefs Macros Pages
Macros | Functions
pldist.c File Reference

Calculate distance from a point to a line. More...

#include <stdio.h>
#include <math.h>
#include "MathType.h"

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)
 

Detailed Description

Calculate distance from a point to a line.

Version
V1.1
Date
07.07.14
Author
Dr. Andrew C. R. Martin
Institute of Structural & Molecular Biology, University College London, Gower Street, London. WC1E 6BT.
andre.nosp@m.w@bi.nosp@m.oinf..nosp@m.org..nosp@m.uk andre.nosp@m.w.ma.nosp@m.rtin@.nosp@m.ucl..nosp@m.ac.uk

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.

Description:

Usage:

Revision History:

Definition in file pldist.c.

Macro Definition Documentation

#define CROSSPRODUCT (   p1,
  p2,
  p3 
)
Value:
(p3).x = (p1).y*(p2).z - (p1).z*(p2).y; \
(p3).y = (p1).z*(p2).x - (p1).x*(p2).z; \
(p3).z = (p1).x*(p2).y - (p1).y*(p2).x

Definition at line 73 of file pldist.c.

#define DOTPRODUCT (   v1,
  v2 
)    ((v1).x*(v2).x + (v1).y*(v2).y + (v1).z*(v2).z)

Definition at line 77 of file pldist.c.

Function Documentation

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 
)
Parameters
[in]PxPoint x coordinate
[in]PyPoint y coordinate
[in]PzPoint z coordinate
[in]P1xLine start x coordinate
[in]P1yLine start y coordinate
[in]P1zLine start z coordinate
[in]P2xLine end x coordinate
[in]P2yLine end y coordinate
[in]P2zLine end z coordinate
[out]*RxNearest point on line x coordinate
[out]*RyNearest point on line y coordinate
[out]*RzNearest point on line z coordinate
[out]*fracFraction along P1-P2 of R
Returns
Distance from P to 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

  • 16.11.99 Original By: ACRM
  • 07.07.14 Use bl prefix for functions By: CTP

Definition at line 126 of file pldist.c.