POV-Ray : Newsgroups : povray.newusers : Isosurface and f_spiral - bug or feature? : Re: Isosurface and f_spiral - bug or feature? Server Time
20 Apr 2024 01:36:19 EDT (-0400)
  Re: Isosurface and f_spiral - bug or feature?  
From: Bald Eagle
Date: 29 Sep 2017 15:15:00
Message: <web.59ce9b17808cf402c437ac910@news.povray.org>
DBL f_spiral(FPUContext *ctx, DBL *ptr, unsigned int fn); // 64
.....
{ f_spiral,                  6 + 3 }, // 64
.....

DBL f_spiral (FPUContext *ctx, DBL *ptr, unsigned int) // 64

{
     DBL r, r2, th, temp;

     r = sqrt(PARAM_X * PARAM_X + PARAM_Z * PARAM_Z);
     if ((PARAM_X == 0) && (PARAM_Z == 0))
          PARAM_X = 0.000001;
          th = atan2(PARAM_Z, PARAM_X);
          r = r + PARAM(0) * th / TWO_M_PI;
          r2 = fmod(r, PARAM(0)) - PARAM(0) * 0.5;

     if (PARAM(5) == 1)
          r2 = sqrt(r2 * r2 + PARAM_Y * PARAM_Y);

     else if (PARAM(5) != 0)
     {
          temp = 2 / PARAM(5);
          r2 = pow((pow(fabs(r2), temp) + pow(fabs(PARAM_Y), temp)), 1. / temp);
     }

     else
          r2 = max(fabs(r2), fabs(PARAM_Y));
          r = sqrt(PARAM_X * PARAM_X + PARAM_Y * PARAM_Y + PARAM_Z * PARAM_Z);

     return (-min(PARAM(2) - r, PARAM(1) - min(r2, r)));
}


I'd say that the very last r defines sqrt of x-squared + y-squared + z-squared -
which is the implicit / closed form of the surface of a sphere.
So, I'd start looking there....

Maybe rewrite it out in SDL so it's easier to play with.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.