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:
3D plotting of a partial sphere

Subject: 3D plotting of a partial sphere

From: Eyal Fleminger

Date: 25 Apr, 2010 16:57:05

Message: 1 of 4

I am trying to plot a 3D volume defined as part of a sphere. The volume is defined by six numbers in spherical coordinates (r, el & az): minimum/maximum range, minimum/maximum elevation (from -90 to 90), minimum/maximum azimuth (between 0 and 360). In general, the volume will have the shape of a wedge buth with one concave (at r=minimum range) and one convex (at r=maximum range) face. Particular cases will look different - for example, if minimum range=0, minimum azimuth=0, maximum azimuth=360, minimum elevation=0 and maximum elevation=90 the volume will have the shape of a hemisphere with a radius equal to the maximum range.

I need to plot this volume as a surface or patch. While I know how to plot a sphere or hemisphere (using sphere or ellipsoid), I can't figure out how to define the shape for other cases. I could use convhulln if not for the concave face at r=minimum range.
Can anyone offer any suggestions?

Thanks

Subject: 3D plotting of a partial sphere

From: Roger Stafford

Date: 25 Apr, 2010 17:34:04

Message: 2 of 4

"Eyal Fleminger" <efleminge@gmail.com> wrote in message <hr1s91$qtv$1@fred.mathworks.com>...
> I am trying to plot a 3D volume defined as part of a sphere. The volume is defined by six numbers in spherical coordinates (r, el & az): minimum/maximum range, minimum/maximum elevation (from -90 to 90), minimum/maximum azimuth (between 0 and 360). In general, the volume will have the shape of a wedge buth with one concave (at r=minimum range) and one convex (at r=maximum range) face. Particular cases will look different - for example, if minimum range=0, minimum azimuth=0, maximum azimuth=360, minimum elevation=0 and maximum elevation=90 the volume will have the shape of a hemisphere with a radius equal to the maximum range.
>
> I need to plot this volume as a surface or patch. While I know how to plot a sphere or hemisphere (using sphere or ellipsoid), I can't figure out how to define the shape for other cases. I could use convhulln if not for the concave face at r=minimum range.
> Can anyone offer any suggestions?
>
> Thanks
-----------
  Just make spherical coordinate meshes of each of the surfaces involved and combine them into one big mesh. Then convert it from spherical to cartesian coordinates. Piece of cake!

Roger Stafford

Subject: 3D plotting of a partial sphere

From: Eyal Fleminger

Date: 26 Apr, 2010 06:54:05

Message: 3 of 4

> -----------
> Just make spherical coordinate meshes of each of the surfaces involved and combine them into one big mesh. Then convert it from spherical to cartesian coordinates. Piece of cake!
>
> Roger Stafford

How would I generate the meshes? Could you maybe give a simple example?

Thanks

Subject: 3D plotting of a partial sphere

From: Roger Stafford

Date: 26 Apr, 2010 21:53:04

Message: 4 of 4

"Eyal Fleminger" <efleminge@gmail.com> wrote in message <hr3dad$17g$1@fred.mathworks.com>...
> > -----------
> > Just make spherical coordinate meshes of each of the surfaces involved and combine them into one big mesh. Then convert it from spherical to cartesian coordinates. Piece of cake!
> >
> > Roger Stafford
>
> How would I generate the meshes? Could you maybe give a simple example?
>
> Thanks
---------
  I had something along these lines in mind. If you adjust the 'view' function, you can see this "wedge" from other directions.

r = 5;
[theta,phi] = meshgrid(linspace(0,.4*pi,32),linspace(-pi/2,pi/2,32));
x1 = r.*cos(theta).*cos(phi);
y1 = r.*sin(theta).*cos(phi);
z1 = r.*sin(phi);
theta = 0;
[r,phi] = meshgrid(linspace(0,5,32),linspace(-pi/2,pi/2,32));
x2 = r.*cos(theta).*cos(phi);
y2 = r.*sin(theta).*cos(phi);
z2 = r.*sin(phi);
theta = .4*pi;
[r,phi] = meshgrid(linspace(0,5,32),linspace(-pi/2,pi/2,32));
x3 = r.*cos(theta).*cos(phi);
y3 = r.*sin(theta).*cos(phi);
z3 = r.*sin(phi);
x = [x1;x2;x3];
y = [y1;y2;y3];
z = [z1;z2;z3];
surf(x,y,z)
axis square

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