Mandelbrot approximation
12-22-2013, 09:29 PM (This post was last modified: 12-22-2013 10:49 PM by Tugdual.)
Post: #1
 Tugdual Senior Member Posts: 764 Joined: Dec 2013
Mandelbrot approximation
This is an approximation which uses the triangle_p function to display the Mandelbrot set. This is much faster about 20 secs) than iterating through all pixels but still fairly slow and the resulting image is blur (a bit like over compressed jpeg). It also consumes a fair amount of memory due to usage of very large matrices. In other words, this is not very nice nor practical, just experimental...

Possible improvements:
- is it possible to somehow use the ITERATE function and achieve faster results?
- would be nice to use cursor and zoom (may be with a box?)
- implement better palette

If anybody can think of possible optimizations, please do not hesitate to share ideas.

Code:
 grid, color; func(c); export Mandel() begin local cx:=-0.5, cy:=0, zoom:=80, N:=100; local minx,miny,dx,dy; minx:= cx-160/zoom; miny:=cy-119/zoom; dx:=320/N/zoom; dy:=240/N/zoom; // Create the grid grid:=makemat(((I-1)*320/N,(J-1)*240/N),N+1,N+1); color:=makemat(func((minx+I*dx,miny+J*dy)),N+1,N+1); triangle_p(G0,grid,color); wait(0); end; func(c) begin local idxcolor,i:=0, z:=0, max:=50; while i<max do    z:=z^2+c;    if abs(z)>=2 then        idxcolor:=2*pi*i/max;       return RGB(255*(1+sin(idxcolor))/2,0,255*(1+cos(idxcolor))/2);     end;    i:=i+1; end; return RGB(0,0,0); end;
10-23-2014, 07:35 AM
Post: #2
 ww63 Junior Member Posts: 43 Joined: Sep 2014
RE: Mandelbrot approximation
with FW 6031 (Emulator) this sample Fails with "invalid enty" at the triangle_p function call.
09-20-2015, 01:11 PM
Post: #3
 StephenG1CMZ Senior Member Posts: 1,042 Joined: May 2015
RE: Mandelbrot approximation
It also fails with an invalid entry in the triangle call in the Android emulator.

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)