comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Fractal in IDL!
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Fractal in IDL! [message #68371] Thu, 29 October 2009 11:32
rtk is currently offline  rtk
Messages: 22
Registered: September 2008
Junior Member
On Oct 28, 9:15 pm, sathya <sathya.s...@gmail.com> wrote:
> Hi,
>
> I am trying to create a fractal set in IDL. 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 anyother fractal
> or Koch snowflake. If I am not wrong, does it follow the given
> function?
>
> a =( 1/2 )+ ( i/SQRT(12) )
>
> Thanks,
> Sathya!

Perhaps the easiest way to draw fractals of various kinds is to use
the IFS ('Iterated Function System') approach. Email me if you want
IDL code that can do that.

Also, the Sierpinski triangle is perhaps the simplest of all fractals
to generate. Here's BASIC code from the 80s to do it. I leave
translation to IDL as an exercise for the reader :)

10 HOME:HGR2:HCOLOR=3: REM This just turns on the graphics and sets
the color
20 X(1)=0:Y(1)=191:X(2)=140:Y(2)=0:X(3)=278:Y(3)=191: REM Triangle
corners
30 X=X(1):Y=Y(1): REM A starting point
40 N = INT(3*RND(1))+1: X=INT(0.5*(X+X(N))): Y=INT(0.5*(Y+Y(N))): REM
The magic is here
50 HPLOT X,Y:GOTO 40: REM Plot the new point and continue

Have fun!

Ron
Re: Fractal in IDL! [message #68377 is a reply to message #68371] Thu, 29 October 2009 07:01 Go to previous message
pgrigis is currently offline  pgrigis
Messages: 436
Registered: September 2007
Senior Member
On Oct 29, 10:00 am, Paolo <pgri...@gmail.com> wrote:
> On Oct 28, 11:15 pm, sathya <sathya.s...@gmail.com> wrote:
>
>> Hi,
>
>> I am trying to create a fractal set in IDL. 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 anyother fractal
>> or Koch snowflake. If I am not wrong, does it follow the given
>> function?
>
>> a =( 1/2 )+ ( i/SQRT(12) )
>
> That doesn't make any sense.
>
> To draw the snowflake, draw a triangle first.
>
> Then on all sides "_____" of the triangle, replace the straight
> line by a line with a triangle that sticks out in the

Line break should be here: middle "__/\__" .

> Iterate ad infinitum.
>
> Ciao,
> Paolo
>
>
>
>> Thanks,
>> Sathya!
>
>
Re: Fractal in IDL! [message #68378 is a reply to message #68377] Thu, 29 October 2009 07:00 Go to previous message
pgrigis is currently offline  pgrigis
Messages: 436
Registered: September 2007
Senior Member
On Oct 28, 11:15 pm, sathya <sathya.s...@gmail.com> wrote:
> Hi,
>
> I am trying to create a fractal set in IDL. 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 anyother fractal
> or Koch snowflake. If I am not wrong, does it follow the given
> function?
>
> a =( 1/2 )+ ( i/SQRT(12) )

That doesn't make any sense.

To draw the snowflake, draw a triangle first.

Then on all sides "_____" of the triangle, replace the straight
line by a line with a triangle that sticks out in the middle "__/
\__" .
Iterate ad infinitum.

Ciao,
Paolo


>
> Thanks,
> Sathya!
Re: Fractal in IDL! [message #68380 is a reply to message #68378] Thu, 29 October 2009 02:58 Go to previous message
sathya is currently offline  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!
Re: Fractal in IDL! [message #68382 is a reply to message #68380] Thu, 29 October 2009 02:39 Go to previous message
d.poreh is currently offline  d.poreh
Messages: 406
Registered: October 2007
Senior Member
On 28 Okt., 19:15, sathya <sathya.s...@gmail.com> wrote:
> Hi,
>
> I am trying to create a fractal set in IDL. 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 anyother fractal
> 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 in IDL for first function (x^2-c).
and show how we could do that?
Cheers
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Fractal in IDL!
Next Topic: TLB_Frame_Attr weirdness/compile issue?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:21:14 PDT 2025

Total time taken to generate the page: 0.00666 seconds