Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

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 am trying to plot a function $ {\bf x}(t) = r(t)\hat{v} + {\bf b}(t) $, with unit vector $ \hat{v} $ and vector $ {\bf b}(t) $ given in spherical coordinates. For simplicity, assume that $ \hat{v} = (\sin\theta\cos\phi, \sin\theta\sin\phi, \cos\theta) $, and $ {\bf b}(t) = [t, \sin(a+t), \cos(b + at^2)] $, where $ a $ and $ b $ are constants. This is easy to plot, however, I want the angles $ \theta $ and $ \phi $ to satisfy an implicit equation, say, $ \cos\theta + a(\phi + b t)^2 + c = 0 $.

share|improve this question
This is kind of confusing. Is $\mathbf x$ a function of both $t$ and $\hat v$? What is the function $a(t)$? Is it different from the constant $a$? Are they both different from the $a$ in your last equation? – Rahul Apr 10 '14 at 1:13
Sorry, that was a typo. It should have said $ r(t) $ instead of $ a(t) $. If it simplifies things, you can plot $ {\bf x}(t) $ as a function of $ \theta $ and $ \phi $ for fixed values of $ t $. – James Apr 10 '14 at 1:15
I guess you could define your desired surface as a 3D contour plot of $f(\theta,\phi,t) = 0$, transformed under the map $(\theta,\phi,t) \mapsto r(t)[\sin\theta\cos\phi,\sin\theta\sin\phi,\cos\theta]+\mathbf b(t)$. Unfortunately I don't know how to apply such a nonlinear transformation to a 3D plot. – Rahul Apr 10 '14 at 5:28

You can use an appropriately defined MeshFunction as per your constraint equation. For every t you should then get a line on the sphere. If you don't want the sphere to be visible you can change the opacity to zero in the relevant option. Here I've chosen the constants a, b, c so that the constraint equation has a solution:

 Module[{a = 1, b = -1, c = -2, r, AA, BB, constr, tolerance = 1},
  r[t_] := t;
  AA[θ_, ϕ_] := {Sin[θ] Cos[ϕ], Sin[θ] Sin[ϕ], Cos[θ]};
  BB[t_] := {t, Sin[a + t], Cos[b + a t^2]};
  constr = Function[{θ, ϕ}, Cos[θ] + a (ϕ + b t)^2 + c];
  ParametricPlot3D[r[t] AA[θ, ϕ] + BB[t],
   {θ, 0, 2 π},
   {ϕ, 0, π},
   MeshFunctions -> constr,
   Mesh -> {{0}},
   PlotRange -> {-10, 10},
   MeshStyle -> {Thick, Red},
   PlotStyle -> Opacity[0.7],
   PlotRange -> All]
  ], {t, -5, 5, .5}]


share|improve this answer

As you have one constraint equation, your surface $\vec{x}(\theta,\phi,t)$ is in fact parametrized by two parameters only. In this simple case you could solve $$ \cos\theta+a(\phi+bt)^2+c=0 $$ and get $$ \theta=\arccos(-a(\phi+bt)^2-c) $$ Then, by inserting it in $\vec{x}$ you see that $\vec{x}=\vec{x}(\phi,t)$, which can now be readily plotted.

share|improve this answer

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.