Discover MakerZone

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

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Fitting an ellipsoid to a point cloud

Subject: Fitting an ellipsoid to a point cloud

From: Nic Roberts

Date: 21 Feb, 2012 13:25:11

Message: 1 of 5

Hi,

I have a 3D point cloud (distribution) centred at the origin and would like to fit the surface of an ellipsoid to the cloud.

The equation for an origin centred ellipsoid being:

(x^2)/(a^2) + (y^2)/((b^2) + (z^2)/(c^2) = 1

Where a, b and c are the semi-principle axes and x, y and z are points on the surface.

I was wondering if i could use lsqcurvefit?

But then started to get confused about what I use as 'xdata' and what for 'ydata'. Am I right in assuming that my point cloud data would be 'ydata' and my x0 would be seed values for a, b and c?

In which case what would I use for 'xdata'?

Thanks

Nic

Subject: Fitting an ellipsoid to a point cloud

From: Torsten

Date: 21 Feb, 2012 13:39:41

Message: 2 of 5

On 21 Feb., 14:25, "Nic Roberts" <efy2...@leeds.ac.uk> wrote:
> Hi,
>
> I have a 3D point cloud (distribution) centred at the origin and would like to fit the surface of an ellipsoid to the cloud.
>
> The equation for an origin centred ellipsoid being:
>
> (x^2)/(a^2) + (y^2)/((b^2) + (z^2)/(c^2) = 1
>
> Where a, b and c are the semi-principle axes and x, y  and z are points on the surface.
>
> I was wondering if i could use lsqcurvefit?
>
> But then started to get confused about what I use as 'xdata' and what for 'ydata'. Am I right in assuming that my point cloud data would be 'ydata' and my x0 would be seed values for a, b and c?
>
> In which case what would I use for 'xdata'?
>
> Thanks
>
> Nic

You are sure that the principle axis for your ellisoid are the usual
x-,y- and z-axis ?
Or may your ellipsoid be rotated around the origin ?

Anyhow:
Use lsqnonlin with the functions f_i defined as
f_i = (x_i^2)/(a^2) + (y_i^2)/(b^2) + (z_i^2)/(c^2) - 1
where (x_i,y_i,z_i) is your i-th point in the point cloud.

Best wishes
Torsten.

Subject: Fitting an ellipsoid to a point cloud

From: Nic Roberts

Date: 21 Feb, 2012 14:12:11

Message: 3 of 5

Torsten <Torsten.Hennig@umsicht.fraunhofer.de> wrote in message <26a8d4a0-77c4-42d6-b66e-005777c18742@w9g2000vbv.googlegroups.com>...
> On 21 Feb., 14:25, "Nic Roberts" <efy2...@leeds.ac.uk> wrote:
> > Hi,
> >
> > I have a 3D point cloud (distribution) centred at the origin and would like to fit the surface of an ellipsoid to the cloud.
> >
> > The equation for an origin centred ellipsoid being:
> >
> > (x^2)/(a^2) + (y^2)/((b^2) + (z^2)/(c^2) = 1
> >
> > Where a, b and c are the semi-principle axes and x, y  and z are points on the surface.
> >
> > I was wondering if i could use lsqcurvefit?
> >
> > But then started to get confused about what I use as 'xdata' and what for 'ydata'. Am I right in assuming that my point cloud data would be 'ydata' and my x0 would be seed values for a, b and c?
> >
> > In which case what would I use for 'xdata'?
> >
> > Thanks
> >
> > Nic
>
> You are sure that the principle axis for your ellisoid are the usual
> x-,y- and z-axis ?
> Or may your ellipsoid be rotated around the origin ?
>
> Anyhow:
> Use lsqnonlin with the functions f_i defined as
> f_i = (x_i^2)/(a^2) + (y_i^2)/(b^2) + (z_i^2)/(c^2) - 1
> where (x_i,y_i,z_i) is your i-th point in the point cloud.
>
> Best wishes
> Torsten.

Hi,
I suppose the ellipsoid could be rotated about the origin, I hadnt thought of that!

For lsqnonlin my a, b & c would be elements of x0 eg a=x(1)?

So I would have,

x0[1 1 1];
[x] = lsqnonlin(@ellipse_fit,x0);

function ellipse_fit(x)
f_i = (x_i^2)/(x(1)^2) + (y_i^2)/(x(2)^2) + (z_i^2)/(x(3)^2) - 1

?

Subject: Fitting an ellipsoid to a point cloud

From: Torsten

Date: 21 Feb, 2012 14:33:01

Message: 4 of 5

On 21 Feb., 15:12, "Nic Roberts" <efy2...@leeds.ac.uk> wrote:
> Torsten <Torsten.Hen...@umsicht.fraunhofer.de> wrote in message <26a8d4a0-77c4-42d6-b66e-005777c18...@w9g2000vbv.googlegroups.com>...
> > On 21 Feb., 14:25, "Nic Roberts" <efy2...@leeds.ac.uk> wrote:
> > > Hi,
>
> > > I have a 3D point cloud (distribution) centred at the origin and would like to fit the surface of an ellipsoid to the cloud.
>
> > > The equation for an origin centred ellipsoid being:
>
> > > (x^2)/(a^2) + (y^2)/((b^2) + (z^2)/(c^2) = 1
>
> > > Where a, b and c are the semi-principle axes and x, y  and z are points on the surface.
>
> > > I was wondering if i could use lsqcurvefit?
>
> > > But then started to get confused about what I use as 'xdata' and what for 'ydata'. Am I right in assuming that my point cloud data would be 'ydata' and my x0 would be seed values for a, b and c?
>
> > > In which case what would I use for 'xdata'?
>
> > > Thanks
>
> > > Nic
>
> > You are sure that the principle axis for your ellisoid are the usual
> > x-,y- and z-axis ?
> > Or may your ellipsoid be rotated around the origin ?
>
> > Anyhow:
> > Use lsqnonlin with the functions f_i defined as
> > f_i = (x_i^2)/(a^2) + (y_i^2)/(b^2) + (z_i^2)/(c^2) - 1
> > where (x_i,y_i,z_i) is your i-th point in the point cloud.
>
> > Best wishes
> > Torsten.
>
> Hi,
> I suppose the ellipsoid could be rotated about the origin, I hadnt thought of that!
>
> For lsqnonlin my a, b & c would be elements of x0 eg a=x(1)?
>
> So I would have,
>
> x0[1 1 1];
> [x] = lsqnonlin(@ellipse_fit,x0);
>
> function ellipse_fit(x)
> f_i = (x_i^2)/(x(1)^2) + (y_i^2)/(x(2)^2) + (z_i^2)/(x(3)^2) - 1
>
> ?- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -

Yes.

x0=[1 1 1];
x_data = ...
y_data = ...
z_data = ...
[x]=lsqnonlin(@(x)ellipse_fit(x,x_data,y_data,z_data),x0);

function F = ellipse_fit(x,x_data,y_data,z_data)
F = x_data.^2/x(1)^2 + y_data.^2/x(2)^2 + z_data.^2/x(3)^2 - 1;

First make a test with arrays x_data, y_data and z_data that are
slightly disturbed points on the ellipsoid x^2+x^2+z^2 = 1.

Best wishes
Torsten.

Subject: Fitting an ellipsoid to a point cloud

From: Nic Roberts

Date: 21 Feb, 2012 16:07:11

Message: 5 of 5

Thankyou

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us