POV-Ray : Newsgroups : povray.newusers : Conversion of coordinates to heightfield Server Time
31 Oct 2024 10:24:02 EDT (-0400)
  Conversion of coordinates to heightfield (Message 1 to 7 of 7)  
From: Grobi
Subject: Conversion of coordinates to heightfield
Date: 29 Jan 2009 01:40:00
Message: <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


Post a reply to this message

From: Chris B
Subject: Re: Conversion of coordinates to heightfield
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

From: Alain
Subject: Re: Conversion of coordinates to heightfield
Date: 29 Jan 2009 17:55:31
Message: <498233e3@news.povray.org>
Grobi nous illumina en ce 2009-01-29 01:38 -->
> 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
> 
> 
> 

To use it with POV-Ray, you need to replace the "{" with "<" and the "}" with ">".
Once it's done, it can be made into a mesh object.



-- 
Alain
-------------------------------------------------
Database administrators do it with their relations


Post a reply to this message

From: Grobi
Subject: Re: Conversion of coordinates to heightfield
Date: 30 Jan 2009 04:00:00
Message: <web.4982c17ba614deff9eb381d30@news.povray.org>
Hi there,

thanks for your answers.

I have something like 50-100 thousand coordinates, only the x-value is
incremented in a regular fashion, y and z are a bit random.

I currently have a sphere at every coordinate, which looks nice and is the
closest to the actual measument.

But how exactly do i convert those coordinates to a mesh (triangles)?

thanks

 Andreas


Post a reply to this message

From: Chris B
Subject: Re: Conversion of coordinates to heightfield
Date: 30 Jan 2009 06:08:21
Message: <4982dfa5$1@news.povray.org>
"Grobi" <and### [at] boesmanncom> wrote in message 
news:web.4982c17ba614deff9eb381d30@news.povray.org...
> Hi there,
>
> thanks for your answers.
>
> I have something like 50-100 thousand coordinates, only the x-value is
> incremented in a regular fashion, y and z are a bit random.
>
> I currently have a sphere at every coordinate, which looks nice and is the
> closest to the actual measument.
>
> But how exactly do i convert those coordinates to a mesh (triangles)?
>
> thanks
>
> Andreas
>

You could do that by generating a mesh or a mesh2 object. The mesh2 object 
would probably be a little easier, because the syntax allows you to specify 
a list of vertex_vectors in the same basic format as for the array of 
coordinates. You would then need to specify a list of face_indices, which is 
like specifying how to join the dots using triangular faces.

This is where it starts to get tricky.  If the points followed a sort of 2D 
grid pattern then it's pretty easy to work out a way to join up the dots and 
get a continuous surface where the vertices are at the height given by the 
3rd dimension of your coordinates. Indeed I think that there are various 
macros about that would be able to help you do that for well-defined grid 
patterns.

However, if it is only the x-value that is incremental (and that goes up in 
fairly chunky steps), then working out a meaningful way to join the dots 
becomes quite awkward.  One approach would be to take all the <y,z> values 
for a particular value of x and sort them on their y value. It would be 
possible then to run along the first set of points using a triangle to 
connect each point to the next and back to the y-axis. You could process the 
second set connecting them back to the nearest vertex on the first set etc. 
I suspect this would be quite challenging though, particularly if you're new 
to POV-Ray and/or programming in general.

Plan B.
-------
A simpler alternative that sidesteps these problems entirely is to consider 
using prism objects instead of meshes. It's a bit of a cheat, but with this 
number of points it could give you something that looks fairly similar. This 
idea is to basically draw a series of pyramids with their apexes at the 
required coordinates. It may therefore trick the viewer, giving the illusion 
of forming a coherent mesh-like surface.

The example below uses the original 9 points you posted, but transposes the 
y and z coordinates because the section of the prism object needs to be 
defined in the x-z plane.

If this doesn't give you what you want, it may be worth posting the image 
you made using spheres onto povray.binaries.images. This should at least 
give an impression of the sort of point distribution you're working with, 
which may inspire other ideas. You might also wish to provide a URL to an 
image on the Internet that shows the sort of representation you'd like to 
achieve.

Regards,
Chris B.

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

#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>,

};

#declare MyPrism = prism {
  linear_spline conic_sweep
  -1, 0, 5,
  <-0.8, -0.8>,
  <+0.8, -0.8>,
  <+0.8, +0.8>,
  <-0.8, +0.8>,
  <-0.8, -0.8>
  translate y
}

#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}}
  object {
    MyPrism
    pigment {rgb OneValue/10}
    translate <OneValue.x,0,OneValue.y>
    scale <1,OneValue.z/5,1>
  }
  #local I=I+1;
#end

plane {y,0 pigment {rgb <1,1,0>}}


Post a reply to this message

From: clipka
Subject: Re: Conversion of coordinates to heightfield
Date: 30 Jan 2009 12:00:00
Message: <web.498330fca614deffbdc576310@news.povray.org>
"Chris B" <nom### [at] nomailcom> wrote:
> A simpler alternative that sidesteps these problems entirely is to consider
> using prism objects instead of meshes. It's a bit of a cheat, but with this
> number of points it could give you something that looks fairly similar. This
> idea is to basically draw a series of pyramids with their apexes at the
> required coordinates. It may therefore trick the viewer, giving the illusion
> of forming a coherent mesh-like surface.

If the density of points is quite uniform despite all randomness, using blobs
instead of spheres might give good results, too, I'd guess.


Post a reply to this message

From: Reinhard
Subject: Re: Conversion of coordinates to heightfield
Date: 3 Feb 2009 03:11:12
Message: <4987fc20$1@news.povray.org>
Grobi wrote:
> 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
> 
> 
> 

An other option could be to write a Perl script which convert the data 
to a mesh or what ever you want.

regards,
Reinhard


Post a reply to this message

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