POV-Ray : Newsgroups : povray.binaries.scene-files : Heuraka! It works!!! Server Time
2 Sep 2024 00:15:39 EDT (-0400)
  Heuraka! It works!!! (Message 1 to 2 of 2)  
From: Jörg 'Yadgar' Bleimann
Subject: Heuraka! It works!!!
Date: 21 Nov 2003 12:54:33
Message: <3FBE5FE6.4E77F13B@gmx.de>
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

From: Alf Peake
Subject: Re: Heuraka! It works!!!
Date: 21 Nov 2003 15:05:13
Message: <3fbe6ff9@news.povray.org>

news:3FBE5FE6.4E77F13B@gmx.de...
> High!

Hi

> Here is the Quicksort implementation:

Thankyou. Another file for my utils folder :)

> Pashto 2.0, a protocol language for the Advanced Fractal Geometric
> Heightfield and Navigation Implementation-Sensitive Texture Analysis
> Network

Neat. I'm always amazed at how well non-english posters use the
english language.

Alf


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.