MATLAB: Finding a circle enclosing data points in a tilted plane

circleenclose data

My input is x,y,z coordinates of some data points lying in a tilted plane. I am trying to find a way to compute the minimum radius circle enclosing these data.
but it only works when the points are in the x-y plane. I know I can rotate and translate my points to bring them in x-y plane, but I am looking for an easier way.
I have also considered using convhulln() but it does not work, apparently because all my points are coplanar.
Any help is much appreciated.

Best Answer

Hi Doctor61,
First, from your previous posts and this one I see that you're doing lots of stuff with 3d geometry. I think that you will find this FEX entry very very useful: http://www.mathworks.com/matlabcentral/fileexchange/24484
However, if I understand your problem correctly I think there's a simple answer. My understanding is that you have a set of planar points and you want to find the radius of a circle tilted to that plane that would enclose them.
If the points are indeed exactly coplanar, then a minimum bounding sphere of the points in 3D would actually have the same radius as the circle you describe.
It has a minboundsphere which would do the job.
If your points aren't exactly coplanar, then what you're actually talking about is a minimum bounding cylinder, tilted to align with the plane. In that case, I think that you'll find that the easiest way to answer the question is to:
  1. rotate your points into a plane
  2. get the minimum bounding circle of the local XY-coordinates
The good news is that with geom3d it's actually very easy to do this. If you don't have your plane (but you know 3 points lying on that plane), you can get it by:
myPlane = createPlane(P1, P2, P3);
Then you can get local coordinates of those points by transforming them:
Tform = createBasisTransform3d('global', myPlane);
PTS_WRT_PLANE = transformPoint3d(myPts, Tform);
At this point, your task of finding a minimum bounding circle gets quite a bit easier because we're only working in 2d. John D'Errico's suite of minimal-bounding-objects also has a minboundcircle.
Thanks, Sven.
Related Question