When I graph:

  If[11*Cos[t] <= 5, 
    {9*Cos[s]*Sin[t], 10*Sin[s]*Sin[t], 
    11*Cos[t]}, Null], 
{s, 0, 2*Pi}, {t, 0, Pi}]

I get


but I want to get:

enter image description here

Why does my code generate those spike and etches on top of the partially cut ellipsoid, instead of giving a smooth top like the second picture?

  • $\begingroup$ Hi "user9197"! I edited your question a bit - if you want to see how, click on the "edit/edited" links above. $\endgroup$
    – cormullion
    Aug 23, 2013 at 16:48
  • $\begingroup$ Thank You, I wasn't able to add pictures since I did not have enough reputation. $\endgroup$
    – user9197
    Aug 23, 2013 at 16:52
  • $\begingroup$ How did you get 2nd graph? $\endgroup$ Aug 23, 2013 at 16:53
  • $\begingroup$ I used ContourPlot3D, but I want to make the graph using a parametric setting. $\endgroup$
    – user9197
    Aug 23, 2013 at 16:54

2 Answers 2


Better solution

Actually, you don't need a different parametrization as I suggest below. I haven't really looked at your formula before which I should have done. The probably best solution is to transform your condition into explicit values for t like this:

Reduce[11*Cos[t] <= 5 && 0 <= t <= Pi, t]

(* ArcCos[5/11] <= t <= Pi *)

And now you remove your if condition and adjust your time interval

ParametricPlot3D[{9*Cos[s]*Sin[t], 10*Sin[s]*Sin[t], 11*Cos[t]}, 
 {s, 0, 2*Pi}, {t, ArcCos[5/11], Pi}]

That's far easier.

Quick Hack

ParametricPlot3D expects 3d point for all input values of s and t. What you do by returning Null is kind of rude and most likely confuses the algorithm which tries to construct a polygon surface.

I would really recommend that you transform your expression into a better parameterization, but for a quick hack it seems sufficient to not return Null but the point on the ring at z=5.

expr = {9*Cos[s]*Sin[t], 10*Sin[s]*Sin[t], 11*Cos[t]}; 
sol = Last@Solve[11*Cos[t] == 5, t];
With[{surf = expr, ring = expr /. sol},
  If[11*Cos[t] <= 5, surf, ring], {s, 0, 2*Pi}, {t, 0, Pi}]

Mathematica graphics

  • $\begingroup$ THANKS. Can you please recommend how transform this into a better parametrization. $\endgroup$
    – user9197
    Aug 23, 2013 at 17:31
  • $\begingroup$ @user9197 Please see my update. Sorry, you parametrization is fine, but what you can do is, you can calculate explicit settings for your time interval which fulfill the if if condition you are using. $\endgroup$
    – halirutan
    Aug 23, 2013 at 17:46

You can also do this with RegionFunction:

ParametricPlot3D[{9*Cos[s]*Sin[t], 10*Sin[s]*Sin[t], 11*Cos[t]}, 
 {s, 0, 2*Pi}, {t, 0, Pi}, RegionFunction -> (11 Cos[#5] <= 5 &)]

enter image description here

  • 1
    $\begingroup$ What does #5 mean. $\endgroup$
    – user9197
    Sep 14, 2013 at 22:27

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.