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

Home » Public Forums » archive » Recursion 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
Recursion in IDL [message #881] Fri, 02 April 1993 06:57 Go to next message
sterner is currently offline  sterner
Messages: 106
Registered: February 1991
Senior Member
One of the least used features of IDL may be recursion. But it's
there and works very well. I suspect there are some rather impressive
graphics routines that could be written using recursion. Below is
a very basic routine to show how recursion may be used to easily make
elaborately detailed plots. It is intended to show the needed parts
of a recursive graphics routine, not to be an example of a spectacular
plot. Try it in a screen window.

Ray Sterner sterner@tesla.jhuapl.edu
Johns Hopkins University North latitude 39.16 degrees.
Applied Physics Laboratory West longitude 76.90 degrees.
Laurel, MD 20723-6099

;----------------------------------------------------------- ---------
; rec1.pro = recursion example 1.
; R. Sterner, 2 Apr, 1993
; Draw branches from center of a square out to corners, then
; recursively do the same for smaller squares centered at
; each corner.
; Syntax: rec1, x, y, s
; x,y = device coordinates of ceneter of a square,
; s = half size of square.
; Example call for a default screen window: rec1, 320, 256, 100
; Works in device coordinates so needs modified for PostScript.
;----------------------------------------------------------- ----------

pro rec1, x, y, s

;------- Recursion exit condition ---------
if s lt 1 then return ; Too small to continue.

;------- Find corners of square ------------
x1 = x+s & y1 = y+s ; Corner 1.
x2 = x-s & y2 = y+s ; Corner 2.
x3 = x-s & y3 = y-s ; Corner 3.
x4 = x+s & y4 = y-s ; Corner 4.
;------- Plot branches ---------------------
plots,/dev,[x,x1],[y,y1] ; Draw branch 1.
plots,/dev,[x,x2],[y,y2] ; Draw branch 2.
plots,/dev,[x,x3],[y,y3] ; Draw branch 3.
plots,/dev,[x,x4],[y,y4] ; Draw branch 4.
;--- Recursively work on each corner -------
rec1, x1, y1, .45*s
rec1, x2, y2, .45*s
rec1, x3, y3, .45*s
rec1, x4, y4, .45*s

return
end
Re: Recursion [message #12911 is a reply to message #881] Mon, 14 September 1998 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Martin Vissers (martin.vissers@users.whh.wau.nl) writes:

> Does anybody know how many times a procedure
> can be called recursively ??
>
> I have a small program which gives problems if its
> called more then 20 times

I think this could have been a problem with earlier versions
of IDL, but I believe recent removing of certain program
restrictions has eliminated most of these problems.

What sort of problems?

Cheers,

David
----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438, Toll-Free Book Orders: 1-888-461-0155
Coyote's Guide to IDL Programming: http://www.dfanning.com/
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: WIN NT/95 DEVICE, DECOMPOSED=0
Next Topic: Help with pick menu widget code

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

Current Time: Wed Oct 08 15:10:38 PDT 2025

Total time taken to generate the page: 0.00497 seconds