POV-Ray : Newsgroups : povray.programming : An inside/outside test for triangles mesh : Re: An inside/outside test for triangles mesh Server Time
29 Jul 2024 00:32:16 EDT (-0400)
  Re: An inside/outside test for triangles mesh  
From: Daniele Varrazzo
Date: 5 Mar 1999 05:32:51
Message: <36dfb2d3.0@news.povray.org>
>should be counted or not.  Nathan Kopp has added this sort of thing to his
>UV-mapping patch, available at http://nathan.kopp.com . It's a bit more
complex
>than just a "closed" keyword, though, IIRC.

Very nice :)

>A side note, and hopefully Nathan will see this too and make sure he's
dealing
>with it correctly: CSG requires more than just an insideness test.  It also
>requires that the All_Intersections method really return all intersections,
>because if the closest one fails it wants to find the next-closest.
Internally
>bounded meshes DO NOT do this by default, because of the optimization I
noted
>above.
OK. I didn't know this.
Now I say: "let's forget we have an internal structure: I consider my
triangle mesh just as a set of triangles, regardless their orientation". So:
- All_intersections is the union of all the triangle intersections, but
- when a point is shared by an even number of triangles, it is not an
intersection.

This leads to a pair of special cases:
- an edge intersection
- a vertex intersection
- an edge-vertex intersection

For the first case a could write a
Theorem: in a mesh representing a closed surface, each edge is shared by an
even number of triangles.
Proof: on a closed surface, you can walk forever, there aren't boundaries.
So, each time you meet an edge, you can be sure there is a triangle (and
only one) that leads you "on the other side". []
So, when a ray hits an edge, it hits n/2 times the surface.
I don't know what does "hitting an edge" really mean for the ray-tracer (I
still didn't have the time to read them carefully). I think it means
"getting closer than 10E-6 to a triangle". I think each time I get "close to
an edge", there could be a warning flag in a special version of the
ray-triangle intersection routine. How many triangles warned me? An even
number of them, I hope! so if (n/2) mod 2 gives 1, there is really an
intersection. Otherwise it's a point where the surface walks on itself, and
must not be taken into account.

Now, the vertex intersections. They are a mess: they could be the center of
a triangles star, but even the center (perfectly overlapping) of two stars
(not coplanar each other)... It's hard to say if it's a single or double or
triple surface point...
But how many points like that you will meet in a triangle mesh? I think a
few. And how many rays will hit it in a scene? I don't think more than one
(unless you don't write a disease-study mesh in an appropriate scene. And if
you move a bit your camera...). There could be an error, furthermore blurred
by antialias... So I think you could assert that
                   each "star point" is a single point.
It's untrue, I know, but I think it could work.

Edge-vertex intersections can be see as a vertex intersection (splitting the
triangle that gives the edge into twor triangles, in the intersection
point). So they fall in the previous case.

I Know it's less general than an usual surface intersection test, but I
think it would do his job.
And it could be easily extended do polygons mesh (somebody will write a
polygon mesh, one day...) and, with some work more, even to bicubic_patch
meshes (they don't have only one intersection for each ray)
:Daniele


Post a reply to this message

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