views:

30

answers:

1

What I'm doing

I have a scene which algorithmically draws a prism with a hexagonal cross-section and n layers of such prisms surrounding the center one, such that all the prisms together make a larger hexagon shape.

Now, each row of prisms is displaced from the next by a multiple of sqrt(3)/2 (because the dimensions of one prism are <1,sqrt(3)>, because sin(120/2°) = sqrt(3)/2).

I imagine that the float values of the resulting positions in relation to the dimensions of the prisms do not always exactly coincide in a way that produces zero gap between the objects. Hence, I don't get a smooth, uniform shape when I wrap the whole thing up in a merge and assign it a transparent glassy material. Depending on the value of n, I get jittery weirdness at the edges inside the merge object, or shadows of some surfaces, or both.

This is a snippet from the comment block at the beginning of my code which explains the scene in ASCII art:

       __
    __/  \__
 __/  \ 1/  \__
/  \13/  \ 6/  \
\17/  \ 2/  \10/
/  \14/  \ 7/  \      #3 is at <0,0,0>
\18/  \ 3/  \11/
/  \15/  \ 8/  \
\19/  \ 4/  \12/
   \16/  \ 9/
      \ 5/

The entire code is too long to paste here, but it's available here. It is probably also very painful to read, because I am a bad coder and because POVray doesn't have #for loops.

My question(s)

  • How do I account for the unpredictability and imprecision of float values in making merges of mathematically positioned objects which only touch on the surface but do not overlap?
  • Is this even supposed to work the way I want it to in POVray?
  • Am I doing something very stupid here?
A: 

I'm pretty sure the standard approach is to either make your shapes overlap more, or not touch at all. For your specific case you could either make your prisms very slightly larger or very slightly smaller.

Povray also has a "union" operation which is very similar to "merge" but looks a bit different. You may also want to try it to see if it gives you better results.

In graphics, it isn't uncommon to try a few approaches to see what looks better. :-)

Laurence Gonsalves
The difference between union and merge is that merge removes all internal surfaces, while union does not. Thus merge is the only option of the two suitable for transparency.
Zet