POV-Ray : Newsgroups : povray.general : Solid meshes in CSG : Re: Solid meshes in CSG Server Time
30 Jul 2024 14:19:59 EDT (-0400)
  Re: Solid meshes in CSG  
From: clipka
Date: 11 Dec 2008 11:25:00
Message: <web.49413dc57b08f33bf708085d0@news.povray.org>
"SharkD" <nomail@nomail> wrote:
> Since we're discussing it further, I'm curious what the rationale is behind
> having an inside *vector* for a closed surface. To me, it seems that a vector
> by itself wouldn't be sufficient to contain all the information necessary to
> define what lies inside and outside of the surface. Could you explain how it
> works?

As mentioned in the documentation, for a perfectly closed mesh the vector should
actually not be needed at all - theoretically.

To test whether some point is inside a certain closed object, all you have to do
is shoot a test ray from that point in an *arbitrary* direction and count the
number of times it intersects with the object's surface before hitting infinity
(ignoring any other shapes that may be in the scene as well).

If the test ray does not hit the suface at all, it obviously means that the
point is outside the object (unless it is inverted).

If the test ray hits the surface once before hitting infinity, it means that the
ray has to penetrate the surface to get outside, i.e. the point is obviously
inside.

If the test ray hits the surface multiple times, going in and out (or vice
versa) repeatedly, an even number of hits means that the point is outside the
object, and the ray went in-out-in-...-out, while an odd number of hits means
the point is inside, and the ray went out-in-...-out.

As mentioned, for a perfectly closed mesh it doesn't matter in which direction
you shoot the ray - *theoretically*. In practice, intersection tests *may*
occasionally give wrong results because of numerical precision issues. In that
case, manually choosing an "easier" direction for the test ray will help solve
such issues.

If the mesh is *not* perfectly closed however, the direction of the test ray
*does* have a significant impact on the results, as any point from which the
test ray hits (or rather, doesn't hit) a "gap" in the surface will have its
inside/outside status inverted; so changing the test ray's direction will
change the areas affected by this.


Post a reply to this message

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