Group Abstract Group Abstract

Message Boards Message Boards

0
|
13.4K Views
|
9 Replies
|
5 Total Likes
View groups...
Share
Share this post:

Measure the diameters of an ellipsoidal shape?

Posted 10 years ago

Hi,

I have a set of data points (x,y,z). It has an ellipsoidal shape and I would like to measure the maximum and minimum diameters of this shape using Mathematica, but I am not sure how to carry this out. Can you please help me?

Thanks.

Attachments:
POSTED BY: SAMM Hill
9 Replies

One way to approximate it is to get a best-fit ellipse by singular values decomposition. Since only the stretch factors are of interest we just compute the singular values. If I recall correctly it is their square roots that give the stretch. The method below requires that we center at the origin, hence the subtracting of the mean.

dataCentered = Map[# - Mean[data1] &, data1];
Sqrt[SingularValueList[dataCentered]]

(* Out[34]= {4.5038878147, 4.19597091008, 4.18475712383} *)

To check this we normalize and see if we get something that looks like the unit sphere.

dataNormed = Map[#/Sqrt[svals] &, dataCentered];
ListPointPlot3D[dataNormed, BoxRatios -> {1, 1, 1}]

enter image description here

POSTED BY: Daniel Lichtblau
Posted 10 years ago
Attachments:
POSTED BY: David Keith

I'm not sure what BoundedRegion does internally but it has a "FastEllipse" form specification. This is not a 'fit' as Daniel does (right?). i.e. with a fit you have data that is above/below the fit (or inside/outside) but this does not do that, it is always 'outside' of the data.

Depending what you are after this might be a alternative/better solution.

POSTED BY: Sander Huisman
POSTED BY: Daniel Lichtblau
Posted 10 years ago

And an improved visualization:

lines = data1 /. {x_, y_, z_} -> Line[{{xc, yc, zc}, {x, y, z}}] /. 
   fit;

p2 = Show[plot, Graphics3D[lines]]

enter image description here

POSTED BY: David Keith
Posted 10 years ago

Hi, It is hard for me to find it. What I can suggest is you need to split your data in two piece along the line (assume you have a plane that slice the ellipsoid in two half). Then find max the distance between two data. and similarly for other dimension..

BTW I modified @Marco Thiel ' s the code for this problem and here it is.

farpoints = 
  Take[data1[[#]] &@Flatten@Position[#, Max[#]] &@ DistanceMatrix[data1], 2];
distance = EuclideanDistance[First@farpoints , Last@farpoints ];
Show[ListPointPlot3D[{data1}], 
 Graphics3D[{{PointSize[Large], Red, 
    Point[#] & /@farpoints }, {Thick, Blue, Line[  farpoints ]}}], 
 ImageSize -> 500, 
 PlotLabel -> Framed@Style["distance = " <> ToString[distance], 20]]
POSTED BY: Okkes Dulgerci
Posted 10 years ago

I find your way is easiest to follow as I am only looking for an approximate length. I am trying to figure out now how to find the diameter of the other dimension of the ellipsoid.

POSTED BY: SAMM Hill
Posted 10 years ago

Geometric tool states least squares fitting method for ellipsoid with documentation and C code. https://www.geometrictools.com/Documentation/LeastSquaresFitting.pdf

POSTED BY: Frederick Wu
Posted 10 years ago

Hi I know this is not an efficient way to do it but I did this way. Note that data1=[{}]; is wrong notation, I changed to data1={{}};

 In[72]:= data3 = 
      Table[EuclideanDistance[data1[[j]], data1[[i]]], {i, 
        Length@data1}, {j, Length@data1}];
In[73]:= Max@data3

Out[73]= 8.50821

In[74]:= Position[data3, Max@data3]

Out[74]= {{5, 68}, {68, 5}}

In[75]:= data1[[5]]

Out[75]= {-1.47388, 2.66873, -0.915369}

In[76]:= data1[[68]]

Out[76]= {5.29808, -1.95733, 1.34955}



Show[HighlightMesh[ConvexHullMesh[data1], Style[2, Opacity[0.5]]], 
 Graphics3D[{Red, Line[{data1[[5]], data1[[68]]}]}], 
 Graphics3D[Point[data1]]]
Show[ListPointPlot3D[data1], 
 Graphics3D[{Red, Line[{data1[[5]], data1[[68]]}]}]]
POSTED BY: Okkes Dulgerci
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard