|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
High everybody!
As a development of my "From Pole to Pole" animations, I began with
customizable general inter-continental flight/orbital
animations, where not only the current geographical coordinates, the
total distance travelled and the time elapsed since start
are displayed, but also the six or eight nearest of all capitals of the
world.
It's obvious that I have to sort the distances of the capitals once
again in the calculation of each frame, so I looked up the
Quicksort algorithm in my C tutorial. But there, Quicksort is
implemented as a recursive function (which returns no value),
now my question: is #macro equivalent to "non-returning" functions? Or
do I have to do it all as a series of nested loops?
Here is what I programmed up to now:
#declare buf;
#declare left=0;
#declare right=dimension_size(Dists, 1);
#declare m=Dists[(left+right)/2][1];
#declare i=left;
#declare j=right;
#while (left<j | i<right)
#if (links<j) // uncompleted!
#while(i>=j)
#while (Dists[i][1]<m) #declare i=i+1; #end
#while (Dists[j][1]>m) #declare j=j-1; #end
#if (i>=j)
#declare buf=Dists[i][1];
#declare Dists[i][1]=Dists[j][1];
#declare Dists[j][1]=buf;
#declare i=i+1;
#declare j=j-1;
#end
#end
#end
See you in Khyberspace!
Yadgar
Now playing: Curious Electric (Jon and Vangelis)
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
In article <3FBC6A11.C6E5111B@gmx.de>,
> It's obvious that I have to sort the distances of the capitals once
> again in the calculation of each frame, so I looked up the
> Quicksort algorithm in my C tutorial.
You might want to have a look at arrays.inc as well...
> But there, Quicksort is
> implemented as a recursive function (which returns no value),
> now my question: is #macro equivalent to "non-returning" functions? Or
> do I have to do it all as a series of nested loops?
I'm not sure what you mean by macros being equivalent to non-returning
functions. There is no requirement that a macro return a value...and
recursion with macros does work.
--
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
High!
Christopher James Huff schrieb:
> You might want to have a look at arrays.inc as well...
>
> > But there, Quicksort is
> > implemented as a recursive function (which returns no value),
> > now my question: is #macro equivalent to "non-returning" functions? Or
> > do I have to do it all as a series of nested loops?
>
> I'm not sure what you mean by macros being equivalent to non-returning
> functions. There is no requirement that a macro return a value...and
> recursion with macros does work.
Thank you for your suggestions... but meanwhile, I found it out on my own,
see "Heuraka! It works!".
I just translated the code from my C tutorial to PoV-Ray, and it works
perfectly!
See you in Khyberspace!
Yadgar
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|