spherical harmonics


    Jun 14 2006 | 8:50 am
    dear friends of spheres and cubes!
    has anyone taken a look at the spherical harmonics at:
    has anyone written an expression for this "simple formula"?
    i constantly fuck up. my state of mind visible at
    cheers!

    • Jun 15 2006 | 1:10 am
      On Jun 14, 2006, at 1:50 AM, didi bruckmayr wrote:
      >
      > has anyone taken a look at the spherical harmonics at:
      > http://astronomy.swin.edu.au/~pbourke/surfaces/sphericalh/
      > has anyone written an expression for this "simple formula"?
      XYZ Eval(double theta,double phi, int *m)
      {
      double r = 0;
      XYZ p;
      r += pow(sin(m[0]*phi),(double)m[1]);
      r += pow(cos(m[2]*phi),(double)m[3]);
      r += pow(sin(m[4]*theta),(double)m[5]);
      r += pow(cos(m[6]*theta),(double)m[7]);
      p.x = r * sin(phi) * cos(theta);
      p.y = r * cos(phi);
      p.z = r * sin(phi) * sin(theta);
      return(p);
      }
      is probably easiest to accomplish with two cascaded expressions. One
      to compute radius, r, and then passed to a second one to convert to
      xyz based on r, theta, and phi.
      In the above, replace m[N] with in[N] (to create adjustable
      parameters); replace theta with norm[0]*TWOPI, and phi with norm[1]
      *PI (to convert our normalized X and Y axis values to normalized
      radian based coordinates across the surface of the sphere), and that
      should be it.
      So the expression for r would be:
      "pow(in[0]*PI*norm[1],in[1]) + pow(cos(in[2]*PI*norm[1]),in[3]) +
      pow(sin(in[4]*TWOPI*norm[0]),in[5]) + pow(cos(in[6]*TWOPI*norm[0]),
      [7])"
      then your output expressions for xyz would be the following (where
      theta and phi are replaced by the same, and r is replaced by in[0]).
      You could do with a single instance of jit.expr by replacing r with
      the first expression above, but it will be more expensive to compute
      for each x, y, and z rather than once for all, as I've suggested.
      "in[0]*sin(PI*norm[1])*cos(TWOPI*norm[0])"
      "in[0]*cos(PI*norm[1])"
      "in[0]*sin(PI*norm[1])*sin(TWOPI*norm[0])"
      Quick hack example below. There's some stupid problem with updating
      the float values and jit.expr, which requires banging the input
      again, which I'll look into (might be some bug for jit.expr float
      input), but this should give a decent example of how to convert such
      stuff into jit.expr expressions.
      -Joshua