-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdistancePointLine3d.m
More file actions
executable file
·31 lines (29 loc) · 1.01 KB
/
distancePointLine3d.m
File metadata and controls
executable file
·31 lines (29 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function d = distancePointLine3d(point, line)
%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
%
% ---------
% author : David Legland
% INRA - TPV URPOI - BIA IMASTE
% created the 23/05/2005.
%
% HISTORY
% 15/01/2007 unify size of input data
% 31/01/2007 typo in data formatting, and replace norm by vecnorm3d
% 12/12/2010 changed to bsxfun implementation - Sven Holcombe
% cf. Mathworld (distance point line 3d) for formula
d = bsxfun(@rdivide, vectorNorm3d( ...
vectorCross3d(line(:,4:6), bsxfun(@minus, line(:,1:3), point)) ), ...
vectorNorm3d(line(:,4:6)));