POV-Ray : Newsgroups : povray.programming : An inside/outside test for triangles mesh : An inside/outside test for triangles mesh Server Time
29 Jul 2024 00:24:03 EDT (-0400)
  An inside/outside test for triangles mesh  
From: Daniele Varrazzo
Date: 4 Mar 1999 10:58:34
Message: <36deadaa.0@news.povray.org>
Hi, everybody.
A triangle hasn't a well defined solid inside and an outside, that's
obvious. And so even a triangle mesh.
But if I know that my mesh represents a closed surface (or a set of closed
surfaces), there is an easy way to know if a point is inside or outside.
It is the Jordan's closed curve theorem, the same used with polygons:

   "if a line traced from the point to be tested to an external point touchs
the curve an odd nuber of times, then the point is inside the curve.
Otherwise it's outside"

Well, this works even in the space, where a "curve" is a "surface".
Furthermore, each triangle can have at least only one intersection with a
line, so the theorem could be read as:

   "if a line traced from the point to be tested to an external point touchs
an odd number of triangles, then the point is inside the mesh"

Well, of course this doesn't work with not perfectly closed meshes: the
results would be unpredictable.
So, what about a modifier: the keyword "closed". If I define a

triangle_mesh {
   closed
   triangle { ... }
   [...]
}

I am telling the tracer "trust me: this is a closed mesh". In this case, one
could use a closed triangle mesh in CSG...
I could have a closed triangle mesh representing an Easter Island Head, and
then subtract half of it from an iron box, and obtain the crusher of the
Easter Island Heads Factory (chains and steam here and there...)

I don't know the internal hierarchy of a mesh, but if the triangles were
sorted in some way, there could be many speedups.
With a normal camera, even the vista buffer could be used: if I trace the
line from the camera to a point to be tested, I must test only the triangles
whose vista box are hit.
I could put a special buffer (analogous to the light buffer) in the middle
of the mesh: this would minimize overlapping areas. And if the center of the
triangle buffer were inside the mesh? No problem: an odd number of
intersection would mean "the point is outside", an even one "the point is
inside"...
Bye!
:Daniele


Post a reply to this message

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