|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
in array.inc
//--------------------------------------
#macro Reverse_Array(Array)
#local J = 0;
#local N = dimension_size(Array, 1);
#while(J < floor(N/2))
#local Temp = Array[J]
#local Array[J] = Array[N-J] //<-- subscipt out of range
#local Array[N-J] = Temp //<-- subscipt out of range
#local J = J + 1;
#end
#end
//-----REVISION--------------------------------
#macro Reverse_Array(Array)
#local J = 0;
#local N = dimension_size(Array, 1);
#while(J < floor(N/2))
#local Temp = Array[J]
#local Array[J] = Array[N-J-1] //<---Correction--
#local Array[N-J-1] = Temp //<-----Correction--
#local J = J + 1;
#end
#end
//--------------------------------------------------------
--
Martial
http://martial.rameaux.free.fr
http://www.cathemline.org
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On Sat, 29 Sep 2001 16:24:20 +0200, Martial wrote:
>in array.inc
>//--------------------------------------
>#macro Reverse_Array(Array)
> #local J = 0;
#local N = dimension_size(Array, 1) - 1; // <-- better correction
> #while(J < floor(N/2))
> #local Temp = Array[J]
> #local Array[J] = Array[N-J]
> #local Array[N-J] = Temp
> #local J = J + 1;
> #end
>#end
--
#macro R(L P)sphere{L F}cylinder{L P F}#end#macro P(V)merge{R(z+a z)R(-z a-z)R(a
-z-z-z a+z)torus{1F clipped_by{plane{a 0}}}translate V}#end#macro Z(a F T)merge{
P(z+a)P(z-a)R(-z-z-x a)pigment{rgbf 1}hollow interior{media{emission 3-T}}}#end
Z(-x-x.2x)camera{location z*-10rotate x*90normal{bumps.02scale.05}}
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Ron Parker" wrote:
> #local N = dimension_size(Array, 1) - 1; // <-- better correction
Nope, then you'd have to change this line too:
> > #while(J < floor(N/2))
To this:
> > #while(J < floor((N+1)/2))
Which doesn't seem any better to me.
Rune
--
3D images and anims, include files, tutorials and more:
Rune's World: http://rsj.mobilixnet.dk (updated June 26)
POV-Ray Users: http://rsj.mobilixnet.dk/povrayusers/
POV-Ray Webring: http://webring.povray.co.uk
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On Sun, 30 Sep 2001 10:21:38 +0200, Rune wrote:
>"Ron Parker" wrote:
>> #local N = dimension_size(Array, 1) - 1; // <-- better correction
>
>Nope, then you'd have to change this line too:
>
>> > #while(J < floor(N/2))
>
>To this:
#while (J <= floor(N/2))
seems better.
--
#macro R(L P)sphere{L __}cylinder{L P __}#end#macro P(_1)union{R(z+_ z)R(-z _-z)
R(_-z*3_+z)torus{1__ clipped_by{plane{_ 0}}}translate z+_1}#end#macro S(_)9-(_1-
_)*(_1-_)#end#macro Z(_1 _ __)union{P(_)P(-_)R(y-z-1_)translate.1*_1-y*8pigment{
rgb<S(7)S(5)S(3)>}}#if(_1)Z(_1-__,_,__)#end#end Z(10x*-2,.2)camera{rotate x*90}
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> #while (J <= floor(N/2))
Actually, I think
#while (J < N/2)
is sufficient and even cleaner. If N is even, then the array has an odd
number of elements, and we don't need to swap the middle (N/2) element with
itself.
#macro Reverse_Array(Array)
#local J = 0;
#local N = dimension_size(Array, 1) - 1;
#while(J < N/2)
#local Temp = Array[J]
#local Array[J] = Array[N-J]
#local Array[N-J] = Temp
#local J = J + 1;
#end
#end
Anders
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |