Am 12.03.18 um 21:40 schrieb Nicolas Robert:
I'm sorry that the conversation went off the list, because I replied to
the email inadvertently:
>
> ok , Christian , I understand (I believe...)
> for me there is 4 steps :
>
> for each triangles :
> compute intersection ray with plane
> if intersection
> Check if point intersection is inside triangle
> incr number of intersection
> end
> loop
>
> If number of intersection is odd
> My point is Inside my Polyhedron
>
> Are you agree ?
>
Almost. You need to make sure for each intersection that it is an
intersection of the ray (one side from the starting point) with the
triangle, not the line (two sides). There are two ways:
1) If you have the normal vectors of the faces, and if they are correct:
Multiply (dot-product) the normal vector of the face with the ray unit
vector, only count if it is positive
- or -
2) Multiply the ray unit vector with (s - p), s is the intersection
point, p is the point where you want to know. Only count if positive.
Christian
>
>
>
>
>
> 2018-03-12 22:29 GMT+01:00 Christian Gollwitzer <
auri...@gmx.de>:
>
> Am 12.03.18 um 22:22 schrieb nicolas robert:
>
> Thanks Christian,
>
> My faces are triangles , and this why i do plane equation , my plane is defined by three points
> For each triangle
> I do plane equation
> I calculate intersection point
> ...
>
> Sorry , but i don't understand when you say ''count how many times it
> intersects a face''
>
> For an triangle (in my case) There is one intersection or not and not 2 or 3 or ...
>
>
> With any given face, there is one intersection or none (the point is outside the triangle). You intersect a ray from the point with all faces and count how many intersect with the ray. If it is odd, you are inside, if it is even, you are outside. For the ray you can simply take the x-axis starting from your point. Make sure you count only intersections with the ray, not the line. This you see by checking that the intersection point has a larger coordinate in the direction of the ray than the starting point.
>
> Christian
>
>