POV-Ray : Newsgroups : povray.newusers : creating a surface from a matrix Server Time
23 Dec 2024 01:37:46 EST (-0500)
  creating a surface from a matrix (Message 1 to 6 of 6)  
From: Colaroid
Subject: creating a surface from a matrix
Date: 30 Sep 2010 10:15:00
Message: <web.4ca49a8afa16bf741f8f244b0@news.povray.org>
Hi all

Please could somebody help me.

I have a grid of data (in a 512 x 512 matrix) as an ascii file and would like to
create a surface from the data in POVRAY.

I would like the surface to be contoured according to the data in the grid.

Once done, the image will reflect the data, but will look great in POVRAY.

Has anybody any idea of how this can be done? Ideally, I would like to just
refer to the ascii file using "quote marks" and not have to type (or cut and
paste) the data into the POVRAY file.

Thanks


Post a reply to this message

From: Warp
Subject: Re: creating a surface from a matrix
Date: 30 Sep 2010 10:26:19
Message: <4ca49e0b@news.povray.org>
Colaroid <nomail@nomail> wrote:
> Has anybody any idea of how this can be done? Ideally, I would like to just
> refer to the ascii file using "quote marks" and not have to type (or cut and
> paste) the data into the POVRAY file.

  Are the values in the file single values, which would be interpreted as
heights? In that case it might be easier to create a 512x512-pixel grayscale
image from those values using an external program, and then in POV-Ray
creating a heightfield from the image.

  If the values are three-dimensional points, it would still be possible
to create a smooth surface from them, all from within POV-Ray itself, but
it would require a fair amount of SDL coding.

  The idea would be to create a bicubic patch for each set of 4 adjacent
points in the input data. The corners of the bicubic patch would, naturally,
be the points in the input data directly. The remaining 12 inner control
points of the bicubic patch can then be chosen such that the patch will
form a smooth surface with adjacent patches. This can be done by making
each patch edge control point form a straight line with the equivalent
edge control point of the adjacent patch. The direction of this line could
be parallel to the line that goes through the surrounding input data points.

  (I know this is a complicated thing to explain in words only, and would
require a visualization, but I'd go to further detail only if you or someone
else really needs the info.)

-- 
                                                          - Warp


Post a reply to this message

From: Colaroid
Subject: Re: creating a surface from a matrix
Date: 30 Sep 2010 11:25:00
Message: <web.4ca4aabd26aecd051f8f244b0@news.povray.org>
Wow, thanks very much for the rapid response.

I have a matrix XY grid and the data in each "square" describes a height, so
your first idea should work well.

However, my next issue is that I have 1000 of these matrices, so once I have
set-up the POVRAY file, I wanted to create a shell script that would read the
files (consecutively) in order to create 1000 individually images, which can be
strung together as an animation.

I'm not very good on POVRAY at the minute, but is this sort of thing possible,
particularly bearing in mind that I need to convert them to first as you
suggested????

Thanks again


Post a reply to this message

From: Christian Froeschlin
Subject: Re: creating a surface from a matrix
Date: 30 Sep 2010 18:27:53
Message: <4ca50ee9@news.povray.org>
Colaroid wrote:

> I'm not very good on POVRAY at the minute, but is this sort of thing possible,
> particularly bearing in mind that I need to convert them to first as you
> suggested????

Since you do not seem afraid of a little shell scripting, you
might try to transform your ASCII data into PGM format, see
http://netpbm.sourceforge.net/doc/pgm.html.

I never tried it but it's listed as a supported image
file format in POV-Ray and you should be able to create
a height_field from it.


Post a reply to this message

From: Alain
Subject: Re: creating a surface from a matrix
Date: 30 Sep 2010 22:43:29
Message: <4ca54ad1$1@news.povray.org>

> Wow, thanks very much for the rapid response.
>
> I have a matrix XY grid and the data in each "square" describes a height, so
> your first idea should work well.
>
> However, my next issue is that I have 1000 of these matrices, so once I have
> set-up the POVRAY file, I wanted to create a shell script that would read the
> files (consecutively) in order to create 1000 individually images, which can be
> strung together as an animation.
>
> I'm not very good on POVRAY at the minute, but is this sort of thing possible,
> particularly bearing in mind that I need to convert them to first as you
> suggested????
>
> Thanks again
>
>

You can name all the files containing those matrixes with the same base 
name plus an ordinal number: Name0001.dat or Name0001.bmp for example.

Unce it's done and you have your SDL working, you can use the animation 
feature and read the files in sequance. You only need to concatenate the 
frame_number to the file's name and you are good to go.
concat("Name", str(frame_number,-4,0)),".dat")

"Name" is the base file's name.
str() convert a number into a string of text.
frame_number in an internal fariable containing the number of the 
current frame in an animation. Contains zero if not in an animation, 1 
or more in an animation.
"-4" ask for 4 digits padding to the left with zeros.
"0" ask for no decimal and no decimal point.
Change ".dat" to the actual extention you use.



Alain


Post a reply to this message

From: Colaroid
Subject: Re: creating a surface from a matrix
Date: 5 Oct 2010 10:40:01
Message: <web.4cab37fd26aecd05c0abfa3e0@news.povray.org>
Thanks very much for all your help.

I will now attempt what you have suggested and let you know how it goes!

Cheers


Post a reply to this message

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