Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to put a sphere into a 3D parametric plot, but I seem to have a strange problem. Here's the code:

(Gravitational Constant)
G = 6.672*10^-11
(Mass of Earth and rocket)
M = AstronomicalData["Earth", "Mass"]
m = 2800000
(Rocket thrust)
T = 34020000
(Radius of Earth)
r = AstronomicalData["Earth", "Radius"]
(Numerical solution modelling the gravitation interaction between Earth and a launching rocket)
(NOTE: Rocket mass will change over time; also, add in drag)
soln = NDSolve[{
   x''[t] == -((G M x[t])/(x[t]^2 + y[t]^2 + z[t]^2)^(3/2)),
   y''[t] == -((G M y[t])/(x[t]^2 + y[t]^2 + z[t]^2)^(3/2)) + 
     If[t > 1000, 0, 0.25 T/m],
   z''[t] == -((G M z[t])/(x[t]^2 + y[t]^2 + z[t]^2)^(3/2)) + 
     If[t > 1000, 0, 0.75 T/m],
   x[0] == 0, y[0] == 0, z[0] == r, x'[0] == 0, y'[0] == 0, 
   z'[0] == 0}, {x[t], y[t], z[t]}, {t, 0, 20000}, 
  MaxSteps -> 1000000, Method -> "StiffnessSwitching"]

Show[ParametricPlot3D[ Evaluate[{x[t], y[t], z[t]} /. soln], {t, 0, 20000}, AxesLabel -> {x, y, z}, AspectRatio -> 1, BoxRatios -> 1, PlotStyle -> Automatic, ImageSize -> Large], Graphics3D[{Green, Sphere[{0, 0, 0}, r]}]]

And this is the output that I get, not a sphere but a curved plane:

Sphere Plot

Does anyone know what I'm doing wrong?

share|improve this question
Everything is correct. It is part of sphere and with not so good parameters the orbit is inside the Earth :) – Kuba Aug 23 '13 at 21:58
Please don't use <pre><code> and instead, indent by 4 spaces to format it as code. The former strips away the the asterisks in the comments and they now appear as invalid code. I edited this in your previous question. Please edit the above in the same manner. Thanks :) – R. M. Aug 23 '13 at 22:31
@rm-rf It's too localized or simple mistake I think. – Kuba Aug 23 '13 at 22:49
up vote 1 down vote accepted

If you want to show everything use PlotRange->All in Show. Without this it will take options from first argument which is ParamatricPlot.

Motion equation you are using assumes that Earth mass is focused in its center so the result might look strange since the orbit is inside for not efficient initial conditions:

     ParametricPlot3D[Evaluate[{x[t], y[t], z[t]} /. soln], {t, 0, 20000},
                      AxesLabel -> {x, y, z}, AspectRatio -> 1, BoxRatios -> 1, 
                      PlotStyle -> Thick, ImageSize -> Large],
     Graphics3D[{AbsolutePointSize@10, Red, Point[{0, 0, 0}], Green, 
                 Opacity@.1, Sphere[{0, 0, 0}, r]}]
     , PlotRange -> All, ImageSize -> 350]

enter image description here

share|improve this answer
Whoops hahaha, thanks again Kuba! – user7388 Aug 23 '13 at 22:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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