POV-Ray : Newsgroups : povray.general : Mesh rendering artifacts : Re: Mesh rendering artifacts Server Time
23 Apr 2024 08:50:22 EDT (-0400)
  Re: Mesh rendering artifacts  
From: Tor Olav Kristensen
Date: 1 Feb 2023 20:35:00
Message: <web.63db11c9249f0076383c879289db30a9@news.povray.org>
"yesbird" <nomail@nomail> wrote:
> > I would go one step further, and put them all into the same array, although
> > that's not strictly necessary.   I'm just thinking about juggling all of the
> > data in a macro, and having a single array name would make it easier, but not
> > really necessary.
>
> That's what I've done, thanks to your examples, result attached.

I'm sorry to say, but I don't think that this is a sound advise.

Have a look at these two ways of organizing, naming and declaring the data:

// ====================================================================

#declare V = array[4802][9] {
{<3.76, 7.35, 2.01>, <3.76, 7.67, 1.63>, <4.08, 7.67, 1.39>, <0.32, 0.64, 0.70>,
<0.36, 0.74, 0.56>, <0.40, 0.76, 0.52>, <0.38, 1.00, 0.00>, <0.48, 1.00, 0.00>,
<0.55, 1.00, 0.00>},
{<3.76, 7.35, 2.01>, <4.08, 7.35, 1.83>, <4.08, 7.67, 1.39>, <0.32, 0.64, 0.70>,
<0.38, 0.69, 0.62>, <0.40, 0.76, 0.52>, <0.38, 1.00, 0.00>, <0.43, 1.00, 0.00>,
<0.55, 1.00, 0.00>},
....
}

// ====================================================================

// 50x50 Vertices --> 2x49x49 triangles
#declare M = 2*(50 - 1)*(50 - 1);

// Triangle data
#declare VV = array[M][3]; // Vertices
#declare NN = array[M][3]; // Normals at the vertices
#declare Colors = array[M][3]; // Colors at the vertices

#declare VV =
    array[M][3] {
        { <3.76, 7.35, 2.01>, <3.76, 7.67, 1.63>, <4.08, 7.67, 1.39> },
        { <3.76, 7.35, 2.01>, <4.08, 7.35, 1.83>, <4.08, 7.67, 1.39> },
        ...
    }
;
#declare NN =
    array[M][3] {
        { <0.32, 0.64, 0.70>, <0.36, 0.74, 0.56>, <0.40, 0.76, 0.52> },
        { <0.32, 0.64, 0.70>, <0.38, 0.69, 0.62>, <0.40, 0.76, 0.52> },
        ...
    }
;
#declare Colors =
    array[M][3] {
        { <0.38, 1.00, 0.00>, <0.48, 1.00, 0.00>, <0.55, 1.00, 0.00> },
        { <0.38, 1.00, 0.00>, <0.43, 1.00, 0.00>, <0.55, 1.00, 0.00> },
        ...
    }
;

// ====================================================================

Which one do you think informs a new user best about what is going on ?

I don't think that it should be a goal in this case to write minimal
code and packing things as tightly together as possible.

Giving names to different sections of data should be part of the
documentation.

Magic numbers like 4802 is never a good thing. You should show the user
how you ended up with that number.

If everything is put into a single array, then if someone wants to
recalculate e.g. the normals, they may have to deal with the vertices
and the colors too.

I myself have been abusing Excel for many years to process data that
would have been much better dealt with in a high level programming
language. So I don't think that making it easier to import all the
data in one go into a spreadsheet justifies anonymising and obscuring
the data even more than they already are.

I apologize if this sounds a bit harsh, but I am writing this with my
best intentions.

--
Tor Olav
http://subcube.com
https://github.com/t-o-k


Post a reply to this message

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