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:23:36 EDT (-0400)
  Re: Problem concerning the use of array indices inside functions  
From: Jaap Frank
Date: 2 May 2003 13:38:20
Message: <3eb2ad0c$1@news.povray.org>
"ABX" <abx### [at] abxartpl> wrote in message
news:v1p4bvcfgdeb7a2jvf79p7k1b2e9vkv9nr@4ax.com...
> 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 :-)

I always have some difficulty with understanding someone elses code, but I
think this is a way to interpolate between the grid points.
If this is what you mean with this code, then that is not my problem, because I
have a solution for that already.
Your code gives a linear interpolation, but I need a interpolation using
A0 + A1*x + A2*x^2 + A3*x^3 + A4*x^4 + ... = y
for the densities in the array vary a lot because these are the electron
densities around tens of atoms inside a molecule. (The density values vary
from 1.0*10^-20 to 1 within a few grid points)
I've developed functions that uses matrix calculation in order to solve
a N unknowns in N equations problem for me and they work fine.
You can choose the power of the polynomal as high as you wish ( or
as much patient as you have, because the parse time of the functions
grow with N-factorial, but power N=4 needs about a second).
My problem is that only during the rendering the indices for the various
grid points are known and POV-ray don't accept that.

Further the dimensions of the arrays (I've about ten different molecules)
are in the order of  40 by 40 by 40 grid points.
If you mean that it is possible to expend your solution to 40 points inside
these maps, then I've to accept a linear interpolation, for my solution
obviously can't be used. I will try this.

Thanks for your reaction,

Jaap Frank


Post a reply to this message

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