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:
Circumscribed Cylinder and Inscribed Cylinder

Subject: Circumscribed Cylinder and Inscribed Cylinder

From: Deepak

Date: 13 Jun, 2011 16:26:04

Message: 1 of 4

clc
clear all
n = 50;

h = rand(n,1)*100;
r = 10+(rand(n,1)-0.9)*3;
theta = 360*rand(n,1);
x=r.*cos(theta);
y=r.*sin(theta);
X=ones(n,3);
for i=1:n
    X(i,1)=x(i,1);
    X(i,2)=y(i,1);
    X(i,3)=h(i,1);
end
figure(1)
% plot3(X(:,1),X(:,2),X(:,3),'*');
hold on

Hi,

The sample code given above generates a random cylindrical set of points. Is there a standard code for generating the minimum circumscribed cylinder and the maximum inscribed cylinder from these points ?

Thank You

Subject: Circumscribed Cylinder and Inscribed Cylinder

From: Florin Neacsu

Date: 13 Jun, 2011 16:54:05

Message: 2 of 4

"Deepak " <deepak.tss@gmail.com> wrote in message <it5dms$2o3$1@newscl01ah.mathworks.com>...
> clc
> clear all
> n = 50;
>
> h = rand(n,1)*100;
> r = 10+(rand(n,1)-0.9)*3;
> theta = 360*rand(n,1);
> x=r.*cos(theta);
> y=r.*sin(theta);
> X=ones(n,3);
> for i=1:n
> X(i,1)=x(i,1);
> X(i,2)=y(i,1);
> X(i,3)=h(i,1);
> end
> figure(1)
> % plot3(X(:,1),X(:,2),X(:,3),'*');
> hold on
>
> Hi,
>
> The sample code given above generates a random cylindrical set of points. Is there a standard code for generating the minimum circumscribed cylinder and the maximum inscribed cylinder from these points ?
>
> Thank You

Hello,

Try projecting all the points to a plane, which will give you a cloud of 2D points, that are more or less on a round band. From there you can find both circles you need. Maybe try Hough or level sets approach(find the center of mass, start with a small/large circle and expand/contract until the circle touches one of your points).

I know my answer is somehow vague, but this was my initial thought. Hope it helps.

Regards,
Florin

Subject: Circumscribed Cylinder and Inscribed Cylinder

From: Deepak

Date: 13 Jun, 2011 17:21:04

Message: 3 of 4

"Florin Neacsu" wrote in message <it5fbd$7d1$1@newscl01ah.mathworks.com>...
> "Deepak " <deepak.tss@gmail.com> wrote in message <it5dms$2o3$1@newscl01ah.mathworks.com>...
> > clc
> > clear all
> > n = 50;
> >
> > h = rand(n,1)*100;
> > r = 10+(rand(n,1)-0.9)*3;
> > theta = 360*rand(n,1);
> > x=r.*cos(theta);
> > y=r.*sin(theta);
> > X=ones(n,3);
> > for i=1:n
> > X(i,1)=x(i,1);
> > X(i,2)=y(i,1);
> > X(i,3)=h(i,1);
> > end
> > figure(1)
> > % plot3(X(:,1),X(:,2),X(:,3),'*');
> > hold on
> >
> > Hi,
> >
> > The sample code given above generates a random cylindrical set of points. Is there a standard code for generating the minimum circumscribed cylinder and the maximum inscribed cylinder from these points ?
> >
> > Thank You
>
> Hello,
>
> Try projecting all the points to a plane, which will give you a cloud of 2D points, that are more or less on a round band. From there you can find both circles you need. Maybe try Hough or level sets approach(find the center of mass, start with a small/large circle and expand/contract until the circle touches one of your points).
>
> I know my answer is somehow vague, but this was my initial thought. Hope it helps.
>
> Regards,
> Florin

Any thoughts on how i could extrapolate these into the cylinders that i need ??

Subject: Circumscribed Cylinder and Inscribed Cylinder

From: Roger Stafford

Date: 13 Jun, 2011 19:03:19

Message: 4 of 4

"Deepak " <deepak.tss@gmail.com> wrote in message <it5dms$2o3$1@newscl01ah.mathworks.com>...
> The sample code given above generates a random cylindrical set of points. Is there a standard code for generating the minimum circumscribed cylinder and the maximum inscribed cylinder from these points ?
- - - - - - - - - -
  It takes four parameters to characterize a line in 3D. It is possible to compute both the maximum and minimum volumes of circular cylinders with such a defined line as axis that are to be inscribed in, or are to circumscribe, respectively, your set of points. (I assume it is the volume you want optimized.)

  You could use 'fminunc' in the Optimization Toolbox with four such parameters to find the optima you seek if you write m-file functions to compute the above volumes using these parameters as inputs. Writing such functions is of course the hard part of the problem. It means you would need to perform the appropriate transformations on your coordinates.

  The z-axis which was used to generate your random points would furnish an excellent starting estimate, which 'fminunc' needs.

  You should realize that 'fminunc' may encounter difficulties because of the derivative discontinuities that will inevitably occur in your objectives functions.

  By the way, matlab's 'sin' and 'cos' functions use radian measure, so your multiplication by 360 is inappropriate. Either multiply by 2*pi or else use 'sind' and 'cosd' which operate in degrees.

Roger Stafford

Tags for this Thread

No tags are associated with 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