3
$\begingroup$

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

$\endgroup$
1
  • 1
    $\begingroup$ 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. $\endgroup$
    – C. E.
    Commented Nov 12, 2013 at 5:01

2 Answers 2

10
$\begingroup$

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

$\endgroup$
3
  • $\begingroup$ Isn't there a small coordinate mismatch between the ContourPlot and the 3D box? $\endgroup$ Commented Nov 13, 2013 at 10:18
  • 2
    $\begingroup$ 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 $\endgroup$
    – ubpdqn
    Commented Nov 13, 2013 at 10:22
  • $\begingroup$ Would you elaborate how ContourLabels -> (Text[Style[Sqrt[#3],20],{#1, #2}] &)] works? $\endgroup$
    – user664
    Commented Oct 19, 2014 at 21:00
3
$\begingroup$

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).

$\endgroup$
1
  • $\begingroup$ Cool, thanks Murray! $\endgroup$
    – Logan
    Commented Nov 11, 2013 at 22:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.