POV-Ray : Newsgroups : povray.binaries.images : Example images for the related post: "Rendering an electromagnetic field an= : Re: Example images for the related post: "Rendering an electromagnetic fiel= Server Time
14 May 2024 16:46:41 EDT (-0400)
  Re: Example images for the related post: "Rendering an electromagnetic fiel=  
From: cbpypov
Date: 26 Oct 2017 18:30:01
Message: <web.59f26158231a9fe3bb23337d0@news.povray.org>
"cbpypov" <nomail@nomail> wrote:
> What I forgot: I turned on radiosity as yoou mentioned but without a light
> source the image was black, except for the emitters (if using a black
> background). Why is that?
>
> I think I now got what most of you meant. In my words ... suppose I have the
> field data (say intensity) in a CSV file. Let's say I read that file in and
> generate an array from it:
>
> #declare N_points_in_file = 1000;
> #declare Field_values = array[N_points_in_file];
> #declare Index = 0;
> #fopen MyFile "field_filename.csv" read
> #while (defined(MyFile))
>     #read (MyFile, X, Y, Z, Field_intensity)
>     #declare Field_values[Index] = <X, Y, Z, Intensity>;
>     #declare Index = Index + 1;
> #end
>
> Now the array `Field_values` holds all the points and the respective
> intensities. Next, I would define an object of the size of my volume, i.e.
> a union of the cylinder filling up the hole and another hexahedron above the
> structure. Suppose this object is defined as `Field_volume`, I than would have
> to set the interior like this
>
>         interior
>         { media
>             { emission Intensity
>               density {
>                 function { ... Field_value_interpolated(x,y,z) ... }
>                 color_map {
>                     ... "My color map definition" ...
>                 }
>               }
>
>             }
>         }
>
> here, `Field_value_interpolated` has to be a function that connects the x,y,z
> coordinate to the `Field_intensity` in the `Field_values` array given above.
> But for this I would have to find the closest coordinate in the array, right?
> Or even use an interpolator?
>
> Moreover, what are the x,y,z that the density function passes?


So I finally arrived at the point discussed above. See the file attached which
includes a very coarse field for testing. It contains 5 columns, say: index, x,
y, z, intensity. The x,y,z coordinates are in nm, i.e. must be divided by a_real
in my code. Moreover, I did not manage yet to export the field in _only_ the
volume where I want to show it. The z-coordinate must therefore be shifted by
-250. to align the field with the pov coordinates. I normalized the intensity
column to range from 0. to 1.

I am reading the file as follows, which seems to work out fine:

// Reading the field distribution file
//--------------------------------------------------------------------------
#declare N_points_in_file = 4608;
#declare Field_values = array[N_points_in_file];
#declare Index = 0;
#fopen MyFile "field_coarse_correct.csv" read
#while (defined(MyFile))
    #read (MyFile, FIndex, X, Y, Z, Field_intensity)
    #declare Field_values[Index] = <X/a_real, Y/a_real, (Z-250.)/a_real,
Field_intensity>;
    #declare Index = Index + 1;
#end

Now I thought I could just define the density mapping using this array!?
However, the docs

http://www.povray.org/documentation/3.7.0/r3_4.html#r3_4_8_4_3

say something abount density lists, but more or less only this rather cryptic
sentence:

"You may declare and use density map identifiers but the only way to declare a
density block pattern list is to declare a density identifier for the entire
density."

I appreciate any code examples on how to get beyond the point I am at now :)


Post a reply to this message


Attachments:
Download 'field_coarse_correct.csv.txt' (221 KB)

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