|
![](/i/fill.gif) |
I'm working on matrix transformations using arrays, but nothing goes quite
as planned. The simplest example is transposing a 2d array:
////////////////////////////////////////////////////////////
#macro transp(array1)
#local a1=dimension_size(array1,1);
#local a2=dimension_size(array1,2);
#local i=0;
#local j=0;
#declare temp1= array[a2][a1];
#while (i<=a2-1)
#while (j<=a1-1)
#declare temp1[i][j]=array1[j][i];
#local j=j+1;
#end
#local i=i+1;
#end
#end
camera {location -8*z look_at 0}
light_source{<0,10,-10> rgb 1}
#declare ar1=array[3][2] {{1,0},{1,-1},{0,5}};
transp(ar1)
/////////////////////////////////////////////////////////////////
All good till now, I think, but when I try to visualise the result with the
following routine, I only get the first row. If I change the #while's in
the macro, so that i and j start from their highest values and go to 0,
only the last row is rendered. If I add a third dimension in the array,
only the values on a single spine are rendered. Any ideas on what I'm doing
wrong? I have
searched the newsgroup but I haven't seen many examples of nested #while
with arrays, so I'm inclined to think it's something to do with that. Pov
version is 3.61c for Windows.
///////////////////////////////////////////////////////////
#declare i1=0;
#declare j1=0;
union{
#while (i1<=dimension_size(temp1,1)-1)
#while (j1<=dimension_size(temp1,2)-1)
text{ttf "timrom.ttf"
str(temp1[i1][j1],1,0) 0.1,0 pigment {rgb 1}
translate <(j1-1)*2,1-(i1-1),0>
}
#declare j1=j1+1;
#end
#declare i1=i1+1;
#end
}
//////////////////////////////////////////////////////////
Post a reply to this message
|
![](/i/fill.gif) |