Home > matGeom > geom3d > distancePointLine3d.m

distancePointLine3d

PURPOSE ^

DISTANCEPOINTLINE3D Euclidean distance between 3D point and line.

SYNOPSIS ^

function d = distancePointLine3d(point, line)

DESCRIPTION ^

DISTANCEPOINTLINE3D Euclidean distance between 3D point and line.

   D = distancePointLine3d(POINT, LINE);
   Returns the distance between point POINT and the line LINE, given as:
   POINT : [x0 y0 z0]
   LINE  : [x0 y0 z0 dx dy dz]
   D     : (positive) scalar  
   
   See also:
   lines3d, isPointOnLine3d, distancePointEdge3d, projPointOnLine3d,


   References
   http://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function d = distancePointLine3d(point, line)
0002 %DISTANCEPOINTLINE3D Euclidean distance between 3D point and line.
0003 %
0004 %   D = distancePointLine3d(POINT, LINE);
0005 %   Returns the distance between point POINT and the line LINE, given as:
0006 %   POINT : [x0 y0 z0]
0007 %   LINE  : [x0 y0 z0 dx dy dz]
0008 %   D     : (positive) scalar
0009 %
0010 %   See also:
0011 %   lines3d, isPointOnLine3d, distancePointEdge3d, projPointOnLine3d,
0012 %
0013 %
0014 %   References
0015 %   http://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html
0016 
0017 %   ---------
0018 %   author : David Legland
0019 %   INRA - TPV URPOI - BIA IMASTE
0020 %   created the 23/05/2005.
0021 %
0022 
0023 %   HISTORY
0024 %   15/01/2007 unify size of input data
0025 %   31/01/2007 typo in data formatting, and replace norm by vecnorm3d
0026 %   12/12/2010 changed to bsxfun implementation - Sven Holcombe
0027 
0028 % cf. Mathworld (distance point line 3d)  for formula
0029 d = bsxfun(@rdivide, vectorNorm3d( ...
0030         crossProduct3d(line(:,4:6), bsxfun(@minus, line(:,1:3), point)) ), ...
0031         vectorNorm3d(line(:,4:6)));

Generated on Wed 16-Feb-2022 15:10:47 by m2html © 2003-2019