On Jun 17, 9:45 am, Junum <junshi...@gmail.com> wrote:
> On Jun 17, 6:43 am, Wox <s...@nomail.com> wrote:
>
>> On Fri, 17 Jun 2011 11:21:15 +0200, Wox <s...@nomail.com> wrote:
>>> ; Close tetrahedron
>>> v=v[*,[0,1,2,3,1,2,3]]
>
>> Sorry, this part should be deleted. I was checking whether it could
>> have something to do with "closing the tetrahedron" (rotate the object
>> and notice that the bottom triangle is not filled).
>
> Thanks Wox.
> It seems that IDLanROI works for 2D polygons only.
> In case of 3D object, region of interest (i.e., object) is not defined
> properly.
> I think points should be in a same plane.
I'm not sure you'd want to draw a tet with an ROI. A tet can be drawn
with a grPolygon. You would supply the 4 verts and then the
connectivity list which would be something like:
[3,0,1,2, 3,1,0,3, 3,2,1,3, 3,0,2,3]
The order is important to make all the faces facing "out". If any of
these are wrong, reverse the order. E.g., if the last tri is facing
the wrong way, change 3,0,2,3 to 3,3,2,0.
One way to determine if a point is in the tet, or any closed object
created out of triangles, would be to define a line between the point
in question and any arbitrary point outside of the bounding box of the
object. For each triangle in the object, determine if this line
intersects the triangle. If the number of total intersections is odd,
then the point is in the object. Note that this works for non-convex
objects as well, as long as they are closed. You'll have to be
careful about intersecting the object on a boundary between two or
more triangles.
There may be a better way, but this is the basic brute-force approach.
If your object is just a tet, you can leverage that for a simpler
solution. If the point is on the same inward-facing side of EVERY tri
in the tet, then it is in the tet. Put another way, if the point is
in the same inward-facing half-space of each triangle, it is inside.
Think of the interior of the tet as the intersection of these half-
spaces. I think that http://steve.hollasch.net/cgindex/geometry/ptintet.html
describes the same idea mathematically.
Karl
|