From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Distance from 3D point to line segments
Date: Fri, 19 Oct 2012 21:46:15 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 16
Message-ID: <k5shn7$c08$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1350683175 12296 (19 Oct 2012 21:46:15 GMT)
NNTP-Posting-Date: Fri, 19 Oct 2012 21:46:15 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1117006
Xref: comp.soft-sys.matlab:781005

I have a set of 2000 X,Y,Z data points creating a rectangle with rounded corners.

Here is a plot of my data:

I need to verify that each x,y,z point is within a certain distance from a calculated path of the same shape. I plan on recreating this plot with calculated points, 4 line segments and 4 curves, and then comparing the distance of each point in my dataset to the appropriate segment that I calculate. 

I am using the following for finding distance between a point and line, I am struggling with creating the arcs/curves in 3D. I have the 2 end points and the radius. I then need to compare distance of a 3D point to this 3D curve... Any help would be greatly appreciated.

%loop comparing distance of every found point to calculated line with end points P1_1 and P1_2

for i=min:max
 	error(i) = norm(cross(P1_2-P1_1,point-P1_1))/norm(P1_2-P1_1)