POV-Ray : Newsgroups : povray.advanced-users : Problem concerning the use of array indices inside functions : Re: Problem concerning the use of array indices inside functions Server Time
29 Jul 2024 00:32:43 EDT (-0400)
  Re: Problem concerning the use of array indices inside functions  
From: ABX
Date: 2 May 2003 08:43:09
Message: <v1p4bvcfgdeb7a2jvf79p7k1b2e9vkv9nr@4ax.com>
On Fri, 2 May 2003 14:15:13 +0200, "Jaap Frank" <jjf### [at] xs4allnl> wrote:
> I have a 3D-grid with density values in a 3D-array called
> Cube and must use this as density inside a media statement.

I assume using density file format is not possible in your case ?
Perhaps maps are the solution you are looking for. I mean array:

#local A=array[2][2];
#local A[0][0]=0;
#local A[0][1]=.1;
#local A[1][0]=.2;
#local A[1][1]=.3;

can be expressed as

#local C=array[2];
#local C[0]=pigment{
  gradient y
  pigment_map{
    [0 color rgb A[0][0]]
    [1 color rgb A[0][1]]
  }
}
#local C[1]=pigment{
  gradient y
  pigment_map{
    [0 color rgb A[1][0]]
    [1 color rgb A[1][1]]
  }
}
#local P=pigment{
  gradient x
  pigment_map{
    [0 C[0]]
    [1 C[0]]
  }
}

and then
A[0,0]=P(0,0,0)
A[0,1]=P(0,1,0)
A[1,0]=P(1,0,0)
A[1,1]=P(1,1,0)

Of course this can be easy extended into 3 dimensions and coded with smart loops
but I would leave it for you because you are using 'advanced' group for post :-)

AVX


Post a reply to this message

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