/*
	This file is part of 

	'FractalView' - A Fractal Calculation Program for NeXTStep 3.x

	Author: 
		Peter Merz 
		Kaerntner Str. 9a 
		57223 Kreuztal - GERMANY

	Copyright (C) 1995 Peter Merz

	THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS 
	OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE 
	IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 
	PARTICULAR PURPOSE.

	License to freely use and distribute this software is hereby granted,
 	by the author, subject to the condition that this copyright notice,
  	remains intact.  The author retains the exclusive right to publish,
	derivative works based on this work, including, but not limited to, 
  	revised versions of this work.

*/

/*
	This file is an example for a formula definition bundle and can be modified
	or copied for new formula.
*/

#import "Formula_p2.h"
#import "Complex.h"

/* We need to define the iteration functions as  C-functions: */
extern "C" 
{
/* Begin of iteration function definitions */

unsigned IterateExp(double KRe, double KIm, double CRe, double CIm,int MaxTiefe) {

	Complex	k(KRe,KIm), c(CRe,CIm), z;
	register unsigned Count;

	
	z=k;
	Count=MaxTiefe;
	do {
  		z=exp(z+c);
  		Count--;
 	}
	while(norm(z)<1e38 && Count);
	return MaxTiefe-Count;
 }

/* End of iteration function definitions */
}


@implementation Formula_p2
/* This is the Objective-C class that encapsulates one or more iteration functions */
 
- (List*)createFormulaList
{	
	[self createList];  /* First we create an empty list of formula */

	/* Begin of formula registration */

	/* Besides the Name and the c-function of the formula you
	 * need to add the parameters are for the initial map after choosing
	 * the formula.
	 */	 

	[self addToList: "Mandelbrot Set (exp)":	IterateExp:-2:6:-3:3:75];

	/* FORMAT: [self addToList:	<Name of Set (String)>:
	 *						<Iteration function>:
	 *						<start of real part (float)>:
	 *						<end of real part (float)>:
	 *						<start of imag part (float)>:
	 *						<end of imag part (float)>:
	 *						<iteration depth>];
	 */

	return list;
}

@end
