0% found this document useful (0 votes)
20 views4 pages

CEE-8813-2013: Sphere

The document contains code that generates 2D and 3D parametric plots of spherical and Cartesian coordinate systems. For Chart 1, it defines functions for spherical coordinates and plots the coordinate lines in 2D and 3D. For Chart 2, it modifies the functions to use pi instead of sqrt and plots the results in 2D and 3D as well. It then combines the 3D plots from both charts into one figure for comparison.

Uploaded by

aoz999
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views4 pages

CEE-8813-2013: Sphere

The document contains code that generates 2D and 3D parametric plots of spherical and Cartesian coordinate systems. For Chart 1, it defines functions for spherical coordinates and plots the coordinate lines in 2D and 3D. For Chart 2, it modifies the functions to use pi instead of sqrt and plots the results in 2D and 3D as well. It then combines the 3D plots from both charts into one figure for comparison.

Uploaded by

aoz999
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Chart 1

In[1]:=

th x_, y_ : Sqrt x2

y2 ; x ;

phi x_, y_ : ArcTan y


In[3]:=

x1 th_, ph_ : Sin th Cos ph ; x2 th_, ph_ : Sin th Sin ph ; x3 th_, ph_ : Cos th ; v x_, y_ Simplify x1 th x, y , phi x, y x3 th x, y , phi x, y , Assumptions epsilon Pi 16; minx Pi 2 epsilon; maxx Pi 2 epsilon; dx Pi 16; miny minx; maxy maxx; dy , x2 th x, y , phi x, y x 0, y 0 ; ,

In[6]:=

In[7]:=

dx;

In[12]:=

xvals Range minx, 0, dx Join Range 0, maxx, dx ; yvals Range miny, 0, dy Join Range 0, maxy, dy ; xgrid2 Table x, y0 , y0, yvals ; ygrid2 Table x0, y , x0, xvals ; xgrid3 Table v x, y0 , y0, yvals ; ygrid3 Table v x0, y , x0, xvals ; xplot2d yplot2d xplot3d yplot3d ParametricPlot xgrid2, x, minx, maxx , PlotStyle ParametricPlot ygrid2, y, miny, maxy , PlotStyle ParametricPlot3D xgrid3, x, minx, maxx , PlotStyle ParametricPlot3D ygrid3, y, miny, maxy , PlotStyle Show xplot2d, yplot2d ; Show xplot3d, yplot3d ; Red, Thick Blue, Thick ; ; ; ;

In[18]:=

In[20]:=

Red, Thick Blue, Thick

In[22]:=

plot2dChart1 plot3dChart1

CEE-8813-2013.nb

In[24]:=

Show GraphicsGrid

plot2dChart1, plot3dChart1

, ImageSize
1.0

600

1.5 0.0 0.5 1.0 1.0 1.0 0.5 0.5


Out[24]=

0.5

1.5

1.0

0.5

0.5

1.0

1.5

0.0

0.5

0.5

1.0

1.0 0.5 0.0

1.5

0.5 1.0

Chart 2
In[25]:=

th x_, y_ : Sqrt x2

y2 ; x ; th Cos ph ; th Sin ph ; th ; , x2 th x, y , phi x, y x 0, y 0 ; ,

phi x_, y_ : ArcTan y


In[27]:=

x1 th_, ph_ : Sin Pi x2 th_, ph_ : Sin Pi x3 th_, ph_ : Cos Pi

In[30]:=

v x_, y_ Simplify x1 th x, y , phi x, y x3 th x, y , phi x, y , Assumptions epsilon Pi 16; minx Pi 2 epsilon; maxx Pi 2 epsilon; dx Pi 16; miny minx; maxy maxx; dy

In[31]:=

dx;

In[36]:=

xvals Range minx, 0, dx Join Range 0, maxx, dx ; yvals Range miny, 0, dy Join Range 0, maxy, dy ; xgrid2 Table x, y0 , y0, yvals ; ygrid2 Table x0, y , x0, xvals ; xgrid3 Table v x, y0 , y0, yvals ; ygrid3 Table v x0, y , x0, xvals ; xplot2d ParametricPlot xgrid2, x, minx, maxx , PlotStyle yplot2d ParametricPlot ygrid2, y, miny, maxy , PlotStyle Darker Green , Thick ;

In[42]:=

Darker Magenta , Thick

CEE-8813-2013.nb

In[44]:=

xplot3d ParametricPlot3D xgrid3, x, minx, maxx , PlotStyle yplot3d ParametricPlot3D ygrid3, y, miny, maxy , PlotStyle Darker Green , Thick ; plot2dChart2 plot3dChart2 Show xplot2d, yplot2d ; Show xplot3d, yplot3d ; plot2dChart2, plot3dChart2

Darker Magenta , Thick

In[46]:=

In[48]:=

Show GraphicsGrid

, ImageSize
1.0

600

1.5 0.0 0.5 1.0 1.0 0.5

0.5

0.5

Out[48]=

1.5

1.0

0.5

0.5

1.0

1.5

0.0

0.5

0.5

1.0 1.0 1.0 0.5 0.0 1.5 0.5 1.0

CEE-8813-2013.nb

Both
In[49]:=

Show

plot3dChart1, plot3dChart2 , ImageSize


1.0 0.5

500, PlotRange

All

0.0

0.5

1.0 1.0

0.5

Out[49]=

0.0

0.5

1.0 1.0 0.5 0.0 0.5

1.0

You might also like