10
$\begingroup$

I have a function which generates a curve on the surface of a unit sphere, parameterised by the azimuthal angle. How can I plot a sphere with two different colour above and below this curve?

f[t_] := Normalize[0.3 {Cos[t/2]^2, Cos[3 t] + Sin[t/2], 0} + {Cos[t], Sin[t], 0.3}];
Show[{
  Graphics3D[{Opacity[0.8], Sphere[]}],
  ParametricPlot3D[f[t], {t, 0, 2 Pi}]
}]

$\endgroup$

1 Answer 1

10
$\begingroup$

So a crude way is to add a second parameter which will guide surface towards e.g. the pole

enter image description here

Show[
   ParametricPlot3D[
     Normalize[a f[t] + (1 - a) {0, 0, 1}], {t, 0, 2 Pi}, {a, 0, 1}
   ],
   ParametricPlot3D[f[t], {t, 0, 2 Pi}, PlotStyle -> Thick],
   Graphics3D@Sphere[{0, 0, 0}, .99]
 , PlotRange -> All
 ]

enter image description here

Show[
 ParametricPlot3D[
  Normalize[a f[t] + (1 - a) {0, 0, 1}], {t, 0, 2 Pi}, {a, 0, 1}, 
  Mesh -> None, PlotStyle -> Red],
 ParametricPlot3D[
  Normalize[a f[t] + (1 - a) {0, 0, -1}], {t, 0, 2 Pi}, {a, 0, 1}, 
  Mesh -> None, PlotStyle -> Blue]
 , PlotRange -> All
 ]

enter image description here

$\endgroup$
1

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.