POVray:如何可靠地创建仅接触表面的对象的良好合并?

发布于 2024-08-19 15:03:39 字数 935 浏览 2 评论 0原文

我正在做的事情是,

我有一个场景,通过算法绘制一个具有六边形横截面的棱镜和围绕中心棱镜的 n 层棱镜,以便所有棱镜一起形成更大的六边形形状。

现在,每一排棱镜与下一排的位移是 sqrt(3)/2 的倍数(因为一个棱镜的尺寸为 <1,sqrt(3)>,因为 sin(120/2°) = sqrt (3)/2)。

我想,与棱镜尺寸相关的结果位置的浮点值并不总是以在对象之间产生零间隙的方式完全一致。因此,当我将整个东西包裹在 merge 中并为其分配透明玻璃材质时,我不会得到平滑、均匀的形状。根据 n 的值,我会在合并对象内部的边缘或某些表面的阴影或两者兼而有之的地方感到紧张不安。

这是我的代码开头的注释块中的一个片段,它解释了 ASCII 艺术中的场景:

       __
    __/  \__
 __/  \ 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/

整个代码太长,无法粘贴到此处,但可以使用 此处。读起来可能也很痛苦,因为我是一个糟糕的编码员,而且 POVray 没有 #for 循环。

我的问题

  • 在合并仅接触表面但不重叠的数学定位对象时,如何解释浮点值的不可预测性和不精确性?
  • 这是否应该在 POVray 中按照我想要的方式工作?
  • 我在这里做了一些非常愚蠢的事情吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

女中豪杰 2024-08-26 15:03:39

我很确定标准方法是要么让你的形状重叠更多,要么根本不接触。对于您的具体情况,您可以将棱镜做得稍大或稍小。

Povray 还有一个“联合”操作,与“合并”非常相似,但看起来有点不同。您可能还想尝试一下,看看它是否会给您带来更好的结果。

在图形中,尝试几种方法来看看哪种方法看起来更好并不罕见。 :-)

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. :-)

两仪 2024-08-26 15:03:39

在我们公司,我们遇到了同样的问题,重合表面。我们对此的解决方案是一个,它将生成一个非常小的、正随机值。这保证了 (1) 曲面永远不会重合 (2) 即使您将这个小值添加到两个曲面。

In our company we ran into same problems with coincident surfaces. Our solution to this was a macro that would generate a very small, positive random value. That guarantees (1) the surfaces never coincide (2) even if you add that small value to both surfaces.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文