| Re: Fractal in IDL! [message #68380 is a reply to message #68378] |
Thu, 29 October 2009 02:58   |
sathya
Messages: 2 Registered: October 2009
|
Junior Member |
|
|
On Oct 29, 5:39 am, Dav_Poreh <d.po...@gmail.com> wrote:
> On 28 Okt., 19:15, sathya <sathya.s...@gmail.com> wrote:
>
>
>
>> Hi,
>
>> I am trying to create afractalset inIDL. I know that a Mandelbrot
>> set follows the below mentioned function,i.e.
>
>> f(x) = x^2 - c
>
>> where, x - is a complex number, c - constant
>> and the range for x-axis is [-1.5, 1.5].
>
>> In a similar way, can anyone gime me the function for anyotherfractal
>> or Koch snowflake. If I am not wrong, does it follow the given
>> function?
>
>> a =( 1/2 )+ ( i/SQRT(12) )
>
>> Thanks,
>> Sathya!
>
> Hi Sathya!
> Could you please give us the code inIDLfor first function (x^2-c).
> and show how we could do that?
> Cheers
Hi
here is the code!
pro frac,xRange,yRange,RESULT=res
;device,PSEUDO_COLOR=8,DECOMPOSED=0
if n_elements( xRange) eq 0 then xRange = [ -1.0, 2.3]
if n_elements( yRange) eq 0 then yRange = [ -1.3, 1.3]
iter = 255
xS = 640
yS = 512
xD = float(xRange[1]-xRange[0])
yD = float(yRange[1]-yRange[0])
xStep = xD / xS
yStep = yD / yS
xStartVec = lindgen( xS) * xStep + xRange[0]
yStartVec = lindgen( yS) * yStep + yRange[0]
constArr = complex( rebin( xStartVec, xS, yS),$
rebin( transpose(yStartVec), xS, yS))
valArr = complexarr( xS, yS)
res = intarr( xS, yS)
oriIndex = lindgen( long(xS) * yS)
for i = 0, iter-1 do begin
valArr = valArr^2 - constArr
whereIn = where( abs( valArr) le 4.0d, COMPLEMENT=whereOut)
if whereIn[0] eq -1 then break
valArr = valArr[ whereIn]
constArr = constArr[ whereIn]
if whereOut[0] ne -1 then begin
res[ oriIndex[ whereOut]] = i+1
oriIndex = oriIndex[ whereIn]
endif
endfor
loadct,15
tv,res
end
here, is the code which uses the function I mentioned above!
|
|
|
|