MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

Asked by Doctor61
on 4 Feb 2013

I have the cartesian coordinates (x,y,z) of set of points that are distributed in a region of space that could be circumscribed by an ellipse if your camera is angled from origin towards the centre of this region. I plot these points with scatter3.

I want to find the ellipse (in any form that defines its location and shape in space) that encompass these points so that it passes through the ones at the edge and has the minimum area. Thanks in advance for your help.

*No products are associated with this question.*

Answer by Walter Roberson
on 4 Feb 2013

Edited by Walter Roberson
on 4 Feb 2013

The two-dimensional case is talked about in this technical solution and perhaps it could be extended.

And there is a FEX contribution to fit ellipsoids

An algorithm paper is here

Image Analyst
on 4 Feb 2013

Matt J's post here: http://www.mathworks.com/matlabcentral/newsreader/view_thread/320964#879842 but it's also on fitting, not doing a minimum enclosing ellipsoid shell like John's. And here's is torstens solution - again, fitting, not min enclosing.

Walter Roberson
on 4 Feb 2013

You can fit the plane through the points using techniques such as http://www.mathworks.com/support/solutions/en/data/1-1AVW5/index.html?solution=1-1AVW5

You could then rotate and use ellipse fitting. There is a discussion of circumscribing an ellipse here

Answer by Image Analyst
on 4 Feb 2013

Maybe you could modify insphere() by John D'Errico: http://www.mathworks.com/matlabcentral/fileexchange/34767-a-suite-of-minimal-bounding-objects

## 5 Comments

## Cedric Wannaz (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/62101#comment_126899

Are you looking for the parameters of this/an ellipse in the plane, or for a set of points in the 3D space that define numerically this ellipse, or.. what is the purpose?

Also, do you want for example and ellipse that would be some best fit (to define) with respect to your points, or the ellipse with minimal surface area that encompasses all you points, or anything else?

I have no simple/direct answer, but I think that these elements will be important for the discussion, whoever ends up answering.

## Youssef Khmou (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/62101#comment_126905

what are x,y,z : vectors or matrices(meshes) ? what function do you use to plot the quantities, mesh, surf or plot3 ...?

please specify your question thoroughly .

## Doctor61 (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/62101#comment_126925

Sorry I did not make it clear enough. I have the cartesian coordinates (x,y,z) of set of points that are distributed in a region of space that could be circumscribed by an ellipse if your camera is angled from origin towards the centre of this region. I plot these points with scatter3.

I want to find the ellipse (in any form that defines its location and shape in space) that circumscribe these points so that it passes through the ones at the edge and has the minimum surface area.

My matrix has 116 number of points, otherwise I would have included here for more clarification of how my they look like. Thanks in advance for your help.

## Walter Roberson (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/62101#comment_126926

Minimum surface area is, at least in theory, perimeter of a 2D case, extended by revolution.

One of the presentations I found about the 2D case (that was explicitly talking about circumscribing) indicated that minimizing area for the 2D case is easier than minimizing perimeter for the 2D case, because perimeter is an integral that does not have a closed-form solution. I would imagine the same difficulty would apply for ellipsoids.

When you say the points could be circumscribed by an ellipse, do you mean that the points lie in a titled plane, or do you mean that there is a perspective in which the projection onto a titled plane could be circumscribed by an ellipse? The "lie in a titled plane" option would imply that "surface area" would not be the real concern, and that instead perimeter in the titled plane would be, but "projection into a titled plane" does offer meaning to "surface area" but requires specification of the method of completing the containing

volumeonce one has a trialellipse(which is 2D). Are you definitely talking about ellipses and not ellipsoids ??## Doctor61 (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/62101#comment_127082

RE your question, yes I mean "there is a perspective in which the projection onto a

tilted(you mean tilted not titled, right?) plane could be circumscribed by an ellipse". So maybe I have expressed my question unclearly again, this could be even considered as a 2D case where you have several points in a plane and want to circumscribe a shape (here an ellipse) to them. The only thing will be that in my case these points would be the projection of my points into that 2D plane, which I also don't know how to do. It is true that I am not talking about ellipsoids here, only ellipse. So probably surface area is misleading here, I should have used only area.