|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On Mon, 22 Oct 2001 20:05:24 +0200, "Rune" <run### [at] mobilixnetdk> wrote:
> Thank you! It's very appreciated.
this macro is not on the list but I think it could be usefull
(and that's why I talked so much about declaring arrays
and pointing to elements with loops - this macro could
be veeery short with it)
// Array - an array to be resized
// Dimension - number of dimension to be resized
// NewSize - new number of entries for Dimension of Array
#macro Resize_Multi_Array(Array, Dimension, NewSize)
#if((Dimension>0)&(dimensions(Array)>=Dimension)&(int(Dimension)=Dimension))
#if(dimensions(Array)!=1)
#switch(dimensions(Array))
#case(2)
#local NewArray=array
[(Dimension!=1?dimension_size(Array,1):NewSize)]
[(Dimension!=2?dimension_size(Array,2):NewSize)]
#local Max1 =
min(dimension_size(NewArray,1),dimension_size(Array,1));
#break
#case(3)
#local NewArray=array
[(Dimension!=1?dimension_size(Array,1):NewSize)]
[(Dimension!=2?dimension_size(Array,2):NewSize)]
[(Dimension!=3?dimension_size(Array,3):NewSize)]
#break
#case(4)
#local NewArray=array
[(Dimension!=1?dimension_size(Array,1):NewSize)]
[(Dimension!=2?dimension_size(Array,2):NewSize)]
[(Dimension!=3?dimension_size(Array,3):NewSize)]
[(Dimension!=4?dimension_size(Array,4):NewSize)]
#break
#case(5)
#local NewArray=array
[(Dimension!=1?dimension_size(Array,1):NewSize)]
[(Dimension!=2?dimension_size(Array,2):NewSize)]
[(Dimension!=3?dimension_size(Array,3):NewSize)]
[(Dimension!=4?dimension_size(Array,4):NewSize)]
[(Dimension!=5?dimension_size(Array,5):NewSize)]
#break
#else
#error "Wrong Dimension argument in Resize_Multi_Array macro"
#end
#local Max=array[dimensions(Array)]
#local C=0;
#while (C<dimensions(Array))
#local
Max[C]=min(dimension_size(NewArray,C+1),dimension_size(Array,C+1));
#local C=C+1;
#end
#local C=Max
#switch(dimensions(Array))
#case(2)
#local C[0]=0;
#while (C[0]<Max[0])
#local C[1]=0;
#while(C[1]<Max[1])
#ifdef(Array[C[0]][C[1]])
#local NewArray[C[0]][C[1]] = Array[C[0]][C[1]];
#end
#local C[1] = C[1] + 1;
#end
#local C[0] = C[0] + 1;
#end
#break
#case(3)
#local C[0]=0;
#while (C[0]<Max[0])
#local C[1]=0;
#while(C[1]<Max[1])
#local C[2]=0;
#while(C[2]<Max[2])
#ifdef(Array[C[0]][C[1]][C[2]])
#local NewArray[C[0]][C[1]][C[2]] =
Array[C[0]][C[1]][C[2]];
#end
#local C[2] = C[2] + 1;
#end
#local C[1] = C[1] + 1;
#end
#local C[0] = C[0] + 1;
#end
#break
#case(4)
#local C[0]=0;
#while (C[0]<Max[0])
#local C[1]=0;
#while(C[1]<Max[1])
#local C[2]=0;
#while(C[2]<Max[2])
#local C[3]=0;
#while(C[3]<Max[3])
#ifdef(Array[C[0]][C[1]][C[2]][C[3]])
#local NewArray[C[0]][C[1]][C[2]][C[3]] =
Array[C[0]][C[1]][C[2]][C[3]];
#end
#local C[3] = C[3] + 1;
#end
#local C[2] = C[2] + 1;
#end
#local C[1] = C[1] + 1;
#end
#local C[0] = C[0] + 1;
#end
#break
#case(5)
#local C[0]=0;
#while (C[0]<Max[0])
#local C[1]=0;
#while(C[1]<Max[1])
#local C[2]=0;
#while(C[2]<Max[2])
#local C[3]=0;
#while(C[3]<Max[3])
#local C[4]=0;
#while(C[4]<Max[4])
#ifdef(Array[C[0]][C[1]][C[2]][C[3]][C[4]])
#local
NewArray[C[0]][C[1]][C[2]][C[3]][C[4]] = Array[C[0]][C[1]][C[2]][C[3]][C[4]];
#end
#local C[4] = C[4] + 1;
#end
#local C[3] = C[3] + 1;
#end
#local C[2] = C[2] + 1;
#end
#local C[1] = C[1] + 1;
#end
#local C[0] = C[0] + 1;
#end
#break
#else
#error "Wrong Dimension argument in Resize_Multi_Array macro"
#end
#declare Array = NewArray
#else
Resize_Array(Array,NewSize)
#end
#else
#error "Wrong Dimension argument in Resize_Multi_Array macro"
#end
#end
ABX
--
#declare _=function(a,b,x){((a^2)+(b^2))^.5-x}#default {pigment{color rgb 1}}
union{plane{y,-3}plane{-x,-3}finish{reflection 1 ambient 0}}isosurface{ //ABX
function{_(x-2,y,1)|_((x+y)*.7,z,.1)|_((x+y+2)*.7,z,.1)|_(x/2+y*.8+1.5,z,.1)}
contained_by{box{<0,-3,-.1>,<3,0,.1>}}translate z*15finish{ambient 1}}//POV35
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> this macro is not on the list but I think it could be usefull
Hmm, I don't know, so I'd like to hear the opinions of others. Is this macro
useful enough for inclusion?
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Why don't you allow the array to be one-dimensional? I know that there are
other macros for one-dimensional arrays, but it's trivial to add and it
would make this macro truly general-purpose.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Rune wrote:
>
>>this macro is not on the list but I think it could be usefull
>>
>
> Hmm, I don't know, so I'd like to hear the opinions of others. Is this macro
> useful enough for inclusion?
Yes imho
Philippe
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On Mon, 29 Oct 2001 18:19:33 +0100, "Rune"
<run### [at] mobilixnetdk> wrote:
> "W?odzimierz ABX Skiba" wrote:
> > this macro is not on the list but I think it could be usefull
>
> Hmm, I don't know, so I'd like to hear the opinions of others. Is this macro
> useful enough for inclusion?
I've designed this macro becouse I planned to write Append_To_Array
and Append_Array_To_Array macros working multidimensional.
ABX
--
#declare _=function(a,b,x){((a^2)+(b^2))^.5-x}#default {pigment{color rgb 1}}
union{plane{y,-3}plane{-x,-3}finish{reflection 1 ambient 0}}isosurface{ //ABX
function{_(x-2,y,1)|_((x+y)*.7,z,.1)|_((x+y+2)*.7,z,.1)|_(x/2+y*.8+1.5,z,.1)}
contained_by{box{<0,-3,-.1>,<3,0,.1>}}translate z*15finish{ambient 1}}//POV35
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On Mon, 29 Oct 2001 13:12:59 -0500, "Anders K." <and### [at] f2scom>
wrote:
> Why don't you allow the array to be one-dimensional? I know that there are
> other macros for one-dimensional arrays, but it's trivial to add and it
> would make this macro truly general-purpose.
perhaps you missed this but I don't allow, I just call ready macro to
not duplicate code within one inc file.
ABX
--
#declare _=function(a,b,x){((a^2)+(b^2))^.5-x}#default {pigment{color rgb 1}}
union{plane{y,-3}plane{-x,-3}finish{reflection 1 ambient 0}}isosurface{ //ABX
function{_(x-2,y,1)|_((x+y)*.7,z,.1)|_((x+y+2)*.7,z,.1)|_(x/2+y*.8+1.5,z,.1)}
contained_by{box{<0,-3,-.1>,<3,0,.1>}}translate z*15finish{ambient 1}}//POV35
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> perhaps you missed this but I don't allow, I just call ready macro to
> not duplicate code within one inc file.
You're right, I did miss this.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On Mon, 29 Oct 2001 18:19:33 +0100, "Rune" <run### [at] mobilixnetdk> wrote:
> > this macro is not on the list but I think it could be usefull
>
> Hmm, I don't know, so I'd like to hear the opinions of others. Is this macro
> useful enough for inclusion?
I still wait for the answer becouse I don't get strategy for rest of macros.
ABX
--
#declare _=function(a,b,x){((a^2)+(b^2))^.5-x}#default {pigment{color rgb 1}}
union{plane{y,-3}plane{-x,-3}finish{reflection 1 ambient 0}}isosurface{ //ABX
function{_(x-2,y,1)|_((x+y)*.7,z,.1)|_((x+y+2)*.7,z,.1)|_(x/2+y*.8+1.5,z,.1)}
contained_by{box{<0,-3,-.1>,<3,0,.1>}}translate z*15finish{ambient 1}}//POV35
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> I still wait for the answer becouse I don't
> get strategy for rest of macros.
I haven't got many opinions from others but ok, I'll include it.
Can anybody make it more effecient? ~130 lines is quite a lot for such a
macro.
Rune
--
3D images and anims, include files, tutorials and more:
Rune's World: http://rsj.mobilixnet.dk (updated Nov 5)
POV-Ray Users: http://rsj.mobilixnet.dk/povrayusers/
POV-Ray Webring: http://webring.povray.co.uk
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On Sat, 10 Nov 2001 17:04:55 +0100, "Rune" <run### [at] mobilixnetdk> wrote:
> Can anybody make it more effecient? ~130 lines is quite a lot for such a
> macro.
It could be much shorten but as I showed in another thread some constructions
not work (http://news.povray.org/0qjittsg3bmv8422pj5egqvo8p4sg9p36h@4ax.com)
ABX
--
#declare _=function(a,b,x){((a^2)+(b^2))^.5-x}#default {pigment{color rgb 1}}
union{plane{y,-3}plane{-x,-3}finish{reflection 1 ambient 0}}isosurface{ //ABX
function{_(x-2,y,1)|_((x+y)*.7,z,.1)|_((x+y+2)*.7,z,.1)|_(x/2+y*.8+1.5,z,.1)}
contained_by{box{<0,-3,-.1>,<3,0,.1>}}translate z*15finish{ambient 1}}//POV35
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|