POV-Ray : Newsgroups : povray.general : comma separated value file for data input : Re: comma separated value file for data input Server Time
8 May 2024 17:12:20 EDT (-0400)
  Re: comma separated value file for data input  
From: Grassblade
Date: 10 Feb 2007 07:15:00
Message: <web.45cdb6a8d81812bfd2eafd5e0@news.povray.org>
"Tim Attwood" <tim### [at] comcastnet> wrote:

> Pov supports multi-dimensional arrays. (3.2.1.8  Array Identifiers)
> Also, there are dot operators for vectors in pov, so you might
> want to store your point data in an array of vectors?
> (3.2.1.4.3  Operators)
Right, but vectors in POV are at most 5-dimensional. That can be a little
constraining for statistics.
>
> In pov "matrix" is a keyword for matrix transforms.
Likewise, matrix is at most 5*5 (well, 5*4 counting the normalized column).
>
> Here's a simple example that reads a list of 10 vectors
> (as floats) from a .csv file and makes a graph.
>
> union{
> #declare point = array[10];
> #fopen handle "data.csv" read
> #declare c = 0;
> #while (c < 10)
>    #read (handle, t1, t2, t3)
>    #declare point[c] = <t1, t2, t3>;
>    sphere{point[c],0.02}
>    #declare c = c + 1;
> #end
> #fclose handle
> #declare c = 1;
> #while (c < 10)
>    cylinder{point[c-1],point[c],0.02}
>    #declare c = c + 1;
> #end
> pigment{rgb <1,0,0>}
> }
>
> //data.csv
> 0.0,0.0,0,
> 0.1,0.01,0,
> 0.2,0.1,0,
> 0.3,0.2,0,
> 0.4,0.25,0,
> 0.5,0.25,0,
> 0.6,0.2,0,
> 0.7,0.1,0,
> 0.8,0.01,0,
> 0.9,0.0,0

Nifty! But it seems you have to know beforehand the number of data to be
read, is there some way to have something similar to dimension_size?
And can I use your code in my matrices.inc?


Post a reply to this message

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