Mandelbrot Series Zoom
Author |
Message |
TDapplejuice
|
Posted: Fri Nov 04, 2011 8:00 pm Post subject: Mandelbrot Series Zoom |
|
|
What is it you are trying to achieve?
Be able to zoom more then once in Mandelbrot set
also anything that would make the Mandelbrot set more efficient
What is the problem you are having?
First zoom works great but then the second i just get the entire screen colored one color
Describe what you have tried to solve this problem
everything i can think of...nothing fixes just yields same result.
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Turing: |
%Assignment 3
type TComplexNumber :
record
a, b : real
end record
%%%%%%%%%%%%%%%%%%%%%%%PROCEDURES AND FUNCTION%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
procedure ChangePlaneRtoI (var Msex, Msey, Rightx, Topy : int, var c, t : TComplexNumber )
var oldca : real := c.a
var oldcb : real := c.b
c.a := Msex * ((t.a - c.a ) / (maxx + 1)) - t.a
c.b := Msey * ((t.b - c.b ) / (maxy + 1)) - t.b
t.a := Rightx * ((t.a - oldca ) / (maxx + 1)) - t.a
t.b := Topy * ((t.b - oldcb ) / (maxy + 1)) - t.b
end ChangePlaneRtoI
procedure DrawMandelbrot (var p, t : TComplexNumber )
%CONSTANSTS%
const NumIterations := 255
%VARIABLE DECLARATIONS%
var z : TComplexNumber
var SumZ : TComplexNumber
var ProductZ : TComplexNumber
var Oldza : real
var c : TComplexNumber
var Xscale : real := (t.a - p.a ) / (maxx + 1)
var Yscale : real := (t.b - p.b ) / (maxy + 1)
var TimeRunning : int := 0
%counter and color
var n : int := 0
var xi, yi : int
var OutputWindow : int
c := p
%Y hits max
for y : 0 .. maxy + 1
%X hits max
for x : 0 .. maxx + 1
%reset variables
z.a := 0
z.b := 0
n := 0
%iteration
loop
%z = z^2 + c
Oldza := z.a
z.a := ((z.a * z.a - z.b * z.b ) + c.a )
z.b := ((Oldza * z.b * 2) + c.b )
%color and iteration counter
n := n + 1
exit when (sqrt (z.a ** 2 + z.b ** 2)) >= 2 or n >= NumIterations
end loop
if n > 255 then
n := black
end if
%color each pixel
drawdot (x, y, n )
c.a + = Xscale
end for
%reset variables
c.a := p.a
c.b + = Yscale
end for
end DrawMandelbrot
%%%%%%%%%%%%%%%%%%%%%%%%%%MAIN PROGRAM%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
setscreen ("graphics:800,600")
var c : TComplexNumber
var Msex, Msey : int
var Topy, Rightx : int
var button : int
var t : TComplexNumber
var key : string (1)
const escape := chr (27)
Mouse.ButtonChoose ("singlebutton")
%Initilise Variables
c.a := - 2
c.b := - 1. 5
t.a := 2
t.b := 1. 5
DrawMandelbrot (c, t )
loop
%find mouse location and button status
Mouse.Where (Msex, Msey, button )
%if a button is pressed save x,y of cursor
if button = 1 then
Topy := Msey + round (maxy * 0. 05)
Rightx := Msex + round (maxx * 0. 05)
drawbox (Msex, Msey, Rightx, Topy, yellow)
% View.Update
%convert x,y coor to argan plane coor
ChangePlaneRtoI (Msex, Msey, Rightx, Topy, c, t )
DrawMandelbrot (c, t )
end if
%exit when escape pressed
if hasch then
getch (key )
if key = escape then
exit
end if
end if
end loop
|
Please specify what version of Turing you are using
Using verion 4.1 of Turing |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Raknarg
|
Posted: Sun Nov 06, 2011 4:15 pm Post subject: RE:Mandelbrot Series Zoom |
|
|
I cannot fix this, but I feel like I should tell you, I just had an epiphany looking at this program.
Because its awesome, I mean. |
|
|
|
|
|
TDapplejuice
|
Posted: Sun Nov 06, 2011 4:33 pm Post subject: Re: Mandelbrot Series Zoom |
|
|
Raknarg wrote:
I cannot fix this, but I feel like I should tell you, I just had an epiphany looking at this program.
Because its awesome, I mean.
haha thanks man...really annoying how i can only do one zoom. I think its just my logic is wrong really because if the mandelbrot has infinite depth then the values of c should not be getting closer and closer each time because wouldn't they meet at some point? |
|
|
|
|
|
Raknarg
|
Posted: Sun Nov 06, 2011 6:07 pm Post subject: RE:Mandelbrot Series Zoom |
|
|
You're writing a program that will draw a shape of infinite depth. Therefore, you must have a stating and ending point, otherwise it would never be drawn. |
|
|
|
|
|
Raknarg
|
Posted: Sun Nov 06, 2011 6:07 pm Post subject: RE:Mandelbrot Series Zoom |
|
|
Could you not change the value of c at some point or something? |
|
|
|
|
|
Beastinonyou
|
Posted: Sun Nov 06, 2011 6:18 pm Post subject: Re: Mandelbrot Series Zoom |
|
|
I know not of how to help you with your dilemma.
But serious *fistbump* Props for the most insane thing I've seen in a long while. Especially something this awesome in Turing.
I Google'd this, and there's so many cool things about it. Don't know how it works. Sure is awesome though. =P |
|
|
|
|
|
trishume
|
Posted: Sun Nov 06, 2011 10:45 pm Post subject: RE:Mandelbrot Series Zoom |
|
|
I don't have time to debug your code right now but I did notice 2 things. You forgot to use your iterations constant and just put 255 once.
Also, use the RGB module and HSL conversion (wiki it) to get better looking colours. Using turing colour numbers will give weird cyclings.
I suggest printing your variables each time you do a zoom to see if they change. |
|
|
|
|
|
|
|