[ https://issues.apache.org/jira/browse/MATH1211?page=com.atlassian.jira.plugin.system.issuetabpanels:commenttabpanel&focusedCommentId=14484606#comment14484606
]
Mike Zimmerman commented on MATH1211:

It might be enough to incorporate a direction check just after line 365 in the recurseFirstIntersection
method of PolyhedronsSet, something like:
final Vector3D hit3D = plane.intersection(line);
if (hit3D != null && hit3D.subtract(point).dotProduct(line.getDirection()>0) {
...
}
The problem is that the Plane.intersection method does not check for directionality of the
line, thus the PolyhedronsSet.firstIntersection method simply returns the first face that
intersects the "whole" line rather than the first face intersecting the semiinfinite "front"
of the line.
> PolyhedronsSet.firstIntersection(Vector3D point, Line line) sometimes reports intersections
on wrong end of line
> 
>
> Key: MATH1211
> URL: https://issues.apache.org/jira/browse/MATH1211
> Project: Commons Math
> Issue Type: Bug
> Reporter: Mike Zimmerman
>
> I constructed a PolyhedronsSet from a list of triangular faces representing an icosphere
(using the instructions found at https://mailarchives.apache.org/mod_mbox/commonsuser/201208.mbox/<5039FE35.2090307@free.fr>).
This seems to produce correct INSIDE/OUTSIDE results for randomly chosen points. I think
my mesh triangles are defined appropriately.
> However, using PolyhedronsSet.firstIntersection(Vector3D point, Line line) to shoot randomly
oriented rays from the origin sometimes gives a wrong mesh intersection point "behind" the
origin. The intersection algorithm is sometimes picking up faces of the sphereshaped mesh
on the wrong semiinfinite portion of the line, i.e. meshIntersectionPoint.subtract(point).dotProduct(line.getDirection())<0
where point is the Vector3D at center of the sphere and line extends outward through the mesh.
> I think the dot product above should always be positive. If multiple intersections exist
along a "whole" line then the first one in "front" of the line's origin should be returned.
This makes ray tracing with a PolyhedronsSet possible.

This message was sent by Atlassian JIRA
(v6.3.4#6332)
