1
$\begingroup$

I wish to draw a closed shape in 3D using a list of points. Specifically, I want to plot the product of an expensive function "qfun" of angular coordinate theta, with a simple function of angular coordinate phi. For example:

qfun[theta_] = Cos[5 theta] Sin[theta]^2
ParametricPlot3D[
 (1+0.2 qfun[theta] Cos[2 phi]) {Cos[phi] Sin[theta],Sin[phi] Sin[theta], Cos[theta]}
 , {theta, 0, Pi}
 , {phi, -Pi, Pi}]

will plot the shape r[theta,phi]=(1+0.2 qfun[theta]*Cos[2 phi]). However, in my case qfun is a very complicated mess (so I won't post the specific form). I can calculate qfun in a useful time only at rational values of theta. It would be easy to create a grid of values for the skeleton of a parametric plot, or to smoothly join a series of ellipses at different values of theta. (I wish this were a figure of rotation!) Could it be treated as a polyhedron, and smoothed?

$\endgroup$

1 Answer 1

3
$\begingroup$

You can make a table of values, then interpolate, then plot the interpolated function like in your example.

qfun[theta_Rationnal] = Cos[5 theta] Sin[theta]^2

table00 = Table[
     {{theta, phi}
      , (1+2/10 qfun[theta] Cos[2 phi]) {Cos[phi] Sin[theta],Sin[phi] Sin[theta], Cos[theta]}
      }
, {theta, -Pi (* Not 0 ! *), Pi, Pi/10}
, {phi, -Pi, Pi , 
      Pi/10}] // N // Flatten[#, 1] &;

fInterpol = 
 Interpolation[table00, InterpolationOrder -> 3, 
  PeriodicInterpolation -> True]

ParametricPlot3D[
 fInterpol[theta, phi], {theta, 0, Pi}, {phi, -Pi, Pi}]  

enter image description here

$\endgroup$

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.