|
![](/i/fill.gif) |
High!
Meanwhile, I found out how to implement the Quicksort algorithm in
PoV-Ray... feel free to use it! I'm really surprised that
even arrays can be parameters for macros... as a casual C++ dabbler, I
ask myself, how is it handled internally, does
PoV-Ray in fact copy the whole array or just a pointer to the array?
Here is the animation script in which I used Quicksort... the "database"
with the coordinates of capitals is far from complete,
but this will change in the next days. I extracted the coordinates from
the German edition of the International Atlas by
*huge* ASCII text database from NIMA (US
military mapping service) containing millions of geographical names and
their coordinates at arcsecond accuracy level, but I
think I will not implement these data before December, the whole thing
is about 700 megs large...
Here is the Quicksort implementation:
#macro sort(field, l, r)
#local m=field[(l+r)/2][1];
#local i=l;
#local j=r;
#while(i<=j)
#while (field[i][1]<m) #local i=i+1; #end
#while (field[j][1]>m) #local j=j-1; #end
#if (i<=j)
#local buf=field[i][1];
#local buf2=field[i][0];
#declare field[i][1]=field[j][1];
#declare field[i][0]=field[j][0];
#declare field[j][1]=buf;
#declare field[j][0]=buf2;
#local i=i+1;
#local j=j-1;
#end
#end
#if (l<j) sort(Dists, l, j) #end
#if (i<r) sort(Dists, i, r) #end
#end
sort(Dists, 0, dimension_size(Dists, 1)-1)
See you in Khyberspace -
http://home.arcor.de/yadgar/khyberspace/index-e.html
Afghanistan Chronicle: http://home.arcor.de/yadgar/index-e.htm
Home-made electronic music: http://home.arcor.de/yadgar/music/
Yadgar ((:->
--
Pashto 2.0, a protocol language for the Advanced Fractal Geometric
Heightfield and Navigation Implementation-Sensitive Texture Analysis
Network
Post a reply to this message
|
![](/i/fill.gif) |