3

I am trying to plot several level curves of the cone: [x=ucos[v], y=usin[v], z=u],[0<=u<=2,0<=v<=2Pi] in the x-y plane. Does anyone know how to do this? Thanks

Logan
  • 517
  • 1
  • 6
  • 15
  • 1
    The level curves are circles with radius z. All we have to know is how to plot a circle, which can be done in lots of simple ways. – C. E. Nov 12 '13 at 05:01

2 Answers2

10

EDIT Correcting the mmismatch related to Frame and padding pointed out by Markus Roellig

Using Cartesian parametrization and upper cone:

ContourPlot[x^2 + y^2, {x, -5, 5}, {y, -5, 5}, 
 ContourShading -> False, Contours -> {4, 9, 16, 25}, 
 ContourLabels -> (Text[Style[Sqrt[#3],20],{#1, #2}] &)]

enter image description here

Using MeshFunctions:

Plot3D[Sqrt[x^2 + y^2], {x, -5, 5}, {y, -5, 5}, 
 MeshFunctions -> (#3 &), Mesh -> {Table[{j}, {j, 2, 5}]}, 
 BoxRatios -> {1, 1, 1}, MeshStyle -> {Thick, Red}]

enter image description here

Here is a link to approaches to combine both plots.

Combining (using approach from link):

cp = ContourPlot[x^2 + y^2, {x, -5, 5}, {y, -5, 5}, Frame -> False, 
   Axes -> False, PlotRangePadding -> 0, Contours -> {4, 9, 16, 25}, 
   ContourShading -> False, 
   ContourLabels -> (Text[Style[Sqrt[#3], 20], {#1, #2}] &), 
   ContourStyle -> {{Thick, Red}}];
p1 = Plot3D[Sqrt[x^2 + y^2], {x, -5, 5}, {y, -5, 5}, 
   MeshFunctions -> (#3 &), Mesh -> {Table[{j}, {j, 2, 5}]}, 
   BoxRatios -> {1, 1, 1}, MeshStyle -> {Thick, Red}];




level = -1.2 10^-8; gr = 
 Graphics3D[{Texture[cp], EdgeForm[], 
   Polygon[{{-5, -5, level}, {5, -5, level}, {5, 5, level}, {-5, 5, 
      level}}, 
    VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}]}, 
  Lighting -> "Neutral"];
Show[p1, gr]

enter image description here

ubpdqn
  • 60,617
  • 3
  • 59
  • 148
  • Isn't there a small coordinate mismatch between the ContourPlot and the 3D box? – Markus Roellig Nov 13 '13 at 10:18
  • 2
    Yes, thank you...I did this in a rush to be illustrative and motivating, the texturing plot padding leads to the mismatch...you are absolutely right the non composed images should ok and I should have been more pedantic – ubpdqn Nov 13 '13 at 10:22
  • Would you elaborate how ContourLabels -> (Text[Style[Sqrt[#3],20],{#1, #2}] &)] works? –  Oct 19 '14 at 21:00
3

Analysis: Parameter u is the height z of a contour, so take the first two equations for a fixed value of u, e.g.:

 ParametricPlot[{1.25 Cos[v], 1.25 Sin[v]}, {v, 0, 2 Pi}]

whose result, not shown here, is the expected circle.

Implementation: For several heights, apply a function with the height as argument to a list of those heights, producing a list of individual circular images; then combine them all with Show:

 Show[(ParametricPlot[{# Cos[v], # Sin[v]}, {v, 0, 2 Pi}, 
 PlotRange -> {-2.25, 2.25}] &) /@ {0.5, 1, 1.25, 1.5, 1.75, 2}

enter image description here

Note that your syntax for the parametric equations had syntax errors: spaces missing between u and the trig function names; trig functions should be Cos and Sin, not cos and sin (built-in names begin with lower-case, and Mathematica is case-sensitive).

murray
  • 11,888
  • 2
  • 26
  • 50