#include "xmfract.h" #include "fractype.h" #include "macros.h" #include "helpdefs.h" #include "mpmath.h" #include "globals.h" #include "prototyp.h" #ifndef NO_IDENT #ident "$Id: newton.c,v 1.400 1995/06/20 15:39:23 darryl Exp $" #endif /* static variables */ static _CMPLX staticroots[16]; static double d1overd; static double roverd; int NewtonSetup() /* Newton/NewtBasin Routines */ { int i; if (debugflag != 1010) { if(fractype == MPNEWTON) fractype = NEWTON; else if(fractype == MPNEWTBASIN) fractype = NEWTBASIN; curfractalspecific = &fractalspecific[fractype]; } /* set up table of roots of 1 along unit circle */ degree = (int)parm.x; if(degree < 2) degree = 3; /* defaults to 3, but 2 is possible */ root = 1; /* precalculated values */ roverd = (double)root / (double)degree; d1overd = (double)(degree - 1) / (double)degree; maxcolor = 0; threshold = .3*PI/degree; /* less than half distance between roots */ floatmin = FLT_MIN; floatmax = FLT_MAX; basin = 0; if(roots != staticroots) { XtFree((char *) roots); roots = staticroots; } if (fractype==NEWTBASIN) { if(parm.y) basin = 2; /*stripes */ else basin = 1; if(degree > 16) { if((roots=(_CMPLX *)XtMalloc(degree*sizeof(_CMPLX)))==NULL) { roots = staticroots; degree = 16; } } else roots = staticroots; /* list of roots to discover where we converged for newtbasin */ for(i=0;i