1
$\begingroup$

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?

$\endgroup$
  • $\begingroup$ Everything is correct. It is part of sphere and with not so good parameters the orbit is inside the Earth :) $\endgroup$ – Kuba Aug 23 '13 at 21:58
  • $\begingroup$ 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 :) $\endgroup$ – rm -rf Aug 23 '13 at 22:31
  • $\begingroup$ @rm-rf It's too localized or simple mistake I think. $\endgroup$ – Kuba Aug 23 '13 at 22:49
1
$\begingroup$

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:

Show[
     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

$\endgroup$
  • $\begingroup$ Whoops hahaha, thanks again Kuba! $\endgroup$ – InquisitiveInquirer Aug 23 '13 at 22:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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