POV-Ray : Newsgroups : povray.newusers : Conversion of coordinates to heightfield : Re: Conversion of coordinates to heightfield Server Time
28 Jul 2024 14:29:46 EDT (-0400)
  Re: Conversion of coordinates to heightfield  
From: Chris B
Date: 29 Jan 2009 05:08:35
Message: <49818023$1@news.povray.org>
"Grobi" <and### [at] boesmanncom> wrote in message 
news:web.49814ed57858db39eb381d30@news.povray.org...
> Hello,
>
> I would like to convert x,y,z-coordinates to either a heightfield a mesh 
> or a
> solid object.
>
> The coordinates come in a format like this, with or without brackets:
> {20,11.6751,0.071}
> {20,11.6408,0.07}
> {20,11.6066,0.0698}
> {21,11.5724,0.0709}
> {21,11.5382,0.0704}
> {21,11.5039,0.0709}
> {22,11.4697,0.0711}
> {22,11.4355,0.0713}
> {22,11.4012,0.0712}
>
> (its NMR-cryoporometry data, for those interested ...)
>
> I tried RapidDXF, 3DWin and several other programs without success.
>
>
> Any suggestions ?
>
> thanks
>
> Andreas

There are lots of alternative possibilities, so it largely depends on how 
you need to represent the data. This small data sample shows a step-wise 
increasing first value and a steadily decreasing second value, with the 
third, presumably being the measured value corresponding to the first two 
settings? I was sort of expecting some sort of regular grid-like scan, which 
could be then plotted as a 3D graph?

It's pretty easy to get such data into a POV-Ray array, you just need to 
replace the first bracket with a left chevron '<' the second with a right 
chevron and a comma '>,' and top and tail it with an array declaration, as 
in the example below.
Even for a very large file you should be able to do this in seconds using a 
global replace function in a text editor (e.g. POV-Ray's integrated editor 
on Windows). You'll need to get an accurate line count to be able to specify 
the array size.

Then you can use it to create more or less any objects, colors etc. you 
require. The very simple example below illustrates how you can loop through 
the data using it to position and color some cylinders. It repositions and 
scales the values to bring them close to the origin and into a similar order 
of magnitude. It then uses the values as x,y,z coordinates to position 
cylinders and also as RGB values to color them.

Regards,
Chris B.


camera {location <-1,3,-3> look_at <0.5,2,0> }
light_source {<-10,20,-50>, rgb 1}

#declare Data = array [9] {

<20,11.6751,0.071>,
<20,11.6408,0.07>,
<20,11.6066,0.0698>,
<21,11.5724,0.0709>,
<21,11.5382,0.0704>,
<21,11.5039,0.0709>,
<22,11.4697,0.0711>,
<22,11.4355,0.0713>,
<22,11.4012,0.0712>,

};

#local I=0;
#while (I<9)
  #declare OneValue = (Data[I]-<20,11.4,0.069>)*<1,10,1000>;
  cylinder {OneValue,OneValue+z,0.1 pigment {rgb OneValue/10}}
  #local I=I+1;
#end

plane {-z,-3 pigment {rgb <1,1,0>}}


Post a reply to this message

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