Path: ns-mx!hobbes.physics.uiowa.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!ucbvax!GRIN1.BITNET!THROOP
From: THROOP@GRIN1.BITNET ("Throop,Henry B")
Newsgroups: comp.sys.apple2
Subject: Re: TML Pascal
Message-ID: <9110100600.AA12650@apple.com>
Date: 10 Oct 91 05:59:45 GMT
Sender: daemon@ucbvax.BERKELEY.EDU
Organization: The Internet
Lines: 61



> I appreciate your answer. Some of the thing I will try it out tonight.
> I have no intention at the moment to convert to integer for floating
> point calculation.

It's really easier than it sounds.  Just substitute this procedure for
the one you're using to calculate the level set.  It takes two reals, the x
and y coordinates (not screen coordinates) and returns the proper m-set
level.

Function DoCalc (origx, origy : extended) : integer;
var i : integer;
  xo, yo, xi, yi, temp : longint;
begin
  xo := round (origx*1024); xi := xo;
  yo := round (origy*1024); yi := yo;
  i := 0;
  while (((xi*xi+yi*yi)<2097152) and (i <= 50)) do
  begin
    temp := (xi*xi) div 1024 - (yi*yi) div 1024;
    yi := (2*yi*xi) div 1024;
    xi := temp;
    i := i + 1;
  end;
  DoCalc := i;
end;

(I just noticed that xi^2 and yi^2 are getting calculated twice; fix
this for a bit more speed.)

For others who are interested, to get a plot of the Mandelbrot set,
all you need to do is to plug x and y coordinates into this function, and
plot the color on the screen based on the value it returns.  For the full
m-set, set the x range to [-1.5, 0.5] and y to [-1.25, 1.25].  Figure out
some sort of mapping between the x and y real coords and the screen coords,
and then loop through every screen pixel.

> Strange, my TML Pascal and TML Pascal II NEVER gives me any problems,
> although I have designed a unfinished painting program, and some
> minor programs using them. Yes, TML Pascal II resource editor does
> crashes some time, but they are more stable under System 5.04 now.

Maybe you have a later version than me; mine acts like it's about
6 months pre-alpha.

> Where did you get the fomula for assigning colours? I normally either
> take the mod, or the range of the value.

Taking the mod works fine; I've experimented around with other arbitrary
functions of x, y, and iterations.  Almost anything gives good nice
results.

>        Lim Thye Chean: Lim is my surname. My name is Thye Chean.

Henry

--
Henry Throop
THROOP@GRIN1.BITNET
throoph@jacobs.cs.orst.edu
