POV-Ray : Newsgroups : povray.newusers : help about matrices in Povray Server Time
28 Jul 2024 18:12:33 EDT (-0400)
  help about matrices in Povray (Message 1 to 8 of 8)  
From: Katherina
Subject: help about matrices in Povray
Date: 5 Aug 2007 13:20:00
Message: <web.46b6069c778719b8d7b596fc0@news.povray.org>
I'm very new at Povray.

I have the matrices whose rows constitute normal vectors, and coefficients
of quadratics, isn't there anything in Povray so that when I define my
matrices, I can access elements say matrix is M, then M(i,j) is (i,j) th
element.

If there is no such thing, how to read data from a text file (I will put my
matrices in a text file)?


Post a reply to this message

From: Warp
Subject: Re: help about matrices in Povray
Date: 5 Aug 2007 13:45:56
Message: <46b60cd4@news.povray.org>
Katherina <nomail@nomail> wrote:
> I have the matrices whose rows constitute normal vectors, and coefficients
> of quadratics, isn't there anything in Povray so that when I define my
> matrices, I can access elements say matrix is M, then M(i,j) is (i,j) th
> element.

  If all you want to do is to be able to "easily" handle a set of values
as if they were a matrix, you could create a 2-dimensional array from them:

http://povray.org/documentation/view/3.6.1/233/

  Note, however, that POV-Ray offers no native matrix operations (such
as addition, multiplication, etc) doable to such "matrix" arrays, so if
you need those operations you'll have to implement them yourself. This
should be more or less trivial to do using #macros.

-- 
                                                          - Warp


Post a reply to this message

From: Katherina
Subject: Re: help about matrices in Povray
Date: 5 Aug 2007 14:30:00
Message: <web.46b616b3ce12c1a4d7b596fc0@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
> Katherina <nomail@nomail> wrote:
> > I have the matrices whose rows constitute normal vectors, and coefficients
> > of quadratics, isn't there anything in Povray so that when I define my
> > matrices, I can access elements say matrix is M, then M(i,j) is (i,j) th
> > element.
>
>   If all you want to do is to be able to "easily" handle a set of values
> as if they were a matrix, you could create a 2-dimensional array from them:
>
> http://povray.org/documentation/view/3.6.1/233/
>
>   Note, however, that POV-Ray offers no native matrix operations (such
> as addition, multiplication, etc) doable to such "matrix" arrays, so if
> you need those operations you'll have to implement them yourself. This
> should be more or less trivial to do using #macros.
>
> --
>                                                           - Warp

Thanks a lot, I do not need matrix operations.


I looked at the link that you sent to me, but my problem is that I have a
huge data and there are no commas between elements and also between rows as
in the Povray definition below:

#declare Digits =
 array[4][10]
 {
  {7,6,7,0,2,1,6,5,5,0},
  {1,2,3,4,5,6,7,8,9,0},
  {0,9,8,7,6,5,4,3,2,1},
  {1,1,2,2,3,3,4,4,5,5}
 }


Since it is not possible to put commas and also brcakets with to huge data
(if there is a way to do this not by hand please let me know) what can I
do?


Post a reply to this message

From: Charles C
Subject: Re: help about matrices in Povray
Date: 5 Aug 2007 15:05:00
Message: <web.46b61f02ce12c1a4c667cf480@news.povray.org>
"Katherina" <nomail@nomail> wrote:
> Since it is not possible to put commas and also brcakets with to huge data
> (if there is a way to do this not by hand please let me know) what can I
> do?

What are you using to edit text and how consistant is the formmating of your
data, and just how huge?  There's a good chance your text editor could help
automate the addition of commas.  For example, if there's one space between
each number, then you could do a simple text replacement of all instances of
a " " with a ", ".  Text (brackets/commas) at the beginning and end of the
line could be added with an editor-macro.
Charles


Post a reply to this message

From: Warp
Subject: Re: help about matrices in Povray
Date: 5 Aug 2007 16:32:29
Message: <46b633dd@news.povray.org>
Katherina <nomail@nomail> wrote:
> I looked at the link that you sent to me, but my problem is that I have a
> huge data and there are no commas between elements and also between rows as
> in the Povray definition below:

  If there are no negative numbers then it's actually possible to read them
as if they were separated by commas (by using #fopen and then a #while loop
with a #read inside it to read the values from the file and assign them to
the array). If there are negative values, however, then it's not possible
(because povray will interpret it as a substraction of two numbers).

  Depending on how the file is formatted it may be easy to search&replace
whitespace with commas with almost any text editor.

-- 
                                                          - Warp


Post a reply to this message

From: Chris B
Subject: Re: help about matrices in Povray
Date: 5 Aug 2007 17:03:40
Message: <46b63b2c$1@news.povray.org>
"Charles C" <nomail@nomail> wrote in message 
news:web.46b61f02ce12c1a4c667cf480@news.povray.org...
> "Katherina" <nomail@nomail> wrote:
>> Since it is not possible to put commas and also brcakets with to huge 
>> data
>> (if there is a way to do this not by hand please let me know) what can I
>> do?
>
> What are you using to edit text and how consistant is the formmating of 
> your
> data, and just how huge?  There's a good chance your text editor could 
> help
> automate the addition of commas.  For example, if there's one space 
> between
> each number, then you could do a simple text replacement of all instances 
> of
> a " " with a ", ".  Text (brackets/commas) at the beginning and end of the
> line could be added with an editor-macro.
> Charles
>

Many text editors also allow you to edit in a columnar way, so you don't 
necessarily need a macro.
For example, the editor in the Windows version of POV-Ray allows you to 
Ctrl-Click to select a column of text.
If you click at the start of the first line, then scroll down to the bottom 
and Shift-Ctrl-Click at the start of the last line, you get a cursor that 
runs down in front of the first column and you can type a '{' symbol in 
front of each line. You can do the same on the far left of the file.

Regards,
Chris B.


Post a reply to this message

From: Charles C
Subject: Re: help about matrices in Povray
Date: 5 Aug 2007 20:05:00
Message: <web.46b6651ace12c1a4b160ffde0@news.povray.org>
"Chris B" <c_b### [at] btconnectcomnospam> wrote:
> If you click at the start of the first line, then scroll down to the bottom
> and Shift-Ctrl-Click at the start of the last line, you get a cursor that

Neat/thanks.  I frequently use shift and ctrl clicking separately, but
somehow it never occurred to me to use both at once.  :)
Charles


Post a reply to this message

From: Katherina
Subject: Re: help about matrices in Povray
Date: 8 Aug 2007 04:55:00
Message: <web.46b983edce12c1a4d7b596fc0@news.povray.org>
"Charles C" <nomail@nomail> wrote:
> "Chris B" <c_b### [at] btconnectcomnospam> wrote:
> > If you click at the start of the first line, then scroll down to the bottom
> > and Shift-Ctrl-Click at the start of the last line, you get a cursor that
>
> Neat/thanks.  I frequently use shift and ctrl clicking separately, but
> somehow it never occurred to me to use both at once.  :)
> Charles

Thanks a lot! It really helped me! :)


Post a reply to this message

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