[ 
https://issues.apache.org/jira/browse/GEOMETRY-59?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16889799#comment-16889799
 ] 

Matt Juntunen commented on GEOMETRY-59:
---------------------------------------

Hi, [~bonastos]! I also took a stab at this by making an overload of the 
Plane.fromPoints method that accepts a collection of points instead of just 
three (see 
https://github.com/darkma773r/commons-geometry/blob/geometry-32-working/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Plane.java#L631).
 This is the approach I took:

1. Go through each vertex triplet in the given point path. (p0, p1, p2)
2. Compute the cross product of the vectors p1-p0 and p2-p0. If the cross 
product has zero length, then the vectors are collinear and we should skip this 
triplet. Otherwise, continue with the steps below.
3. If this is the first non-zero cross product we've found, then normalize it 
and save it as our baseline plane normal.
4. Compute the dot product of the cross product and the baseline plane normal. 
This will give us a scalar representing the signed volume of the two vectors 
(p1-p0 and p2-p0). Positive values will be in the same direction as the 
baseline normal and negative ones will be in the opposite direction.
5. Add up these signed volumes for all of the vertex triplets in the path.
6. If the signed volume sum is non-negative, then the path is mostly oriented 
in the direction of the baseline normal. If not, then flip the baseline normal 
to point in the opposite direction.
7. Create the plane object using the computed normal and vector from the first 
two points.

I don't have a mathematical proof that this does what we want, but it seems to 
work with the unit tests I've written. It solved the main issue with the test 
case you attached, although the test still failed due to what I think are some 
issues with my in-progress SubPlane and ConvexSubPlane implementations. I'm 
wondering if my approach and the one you described above might be similar 
mathematically. What do you think?


> unexpected output from PolyhedronsSet::checkPoint
> -------------------------------------------------
>
>                 Key: GEOMETRY-59
>                 URL: https://issues.apache.org/jira/browse/GEOMETRY-59
>             Project: Apache Commons Geometry
>          Issue Type: Bug
>          Components: Euclidean 3D
>            Reporter: Dirk Bonekämper
>            Priority: Major
>              Labels: pull-request-available
>         Attachments: InsideProblemTest.java
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> In my project I'm working with 3D Regions modeled as prisms. The base 
> polygons are mostly concave. I got wrong results and boiled it down to the 
> attached unit test. It creates a prism with a concave base. A point that is 
> above the prism gets classified as INSIDE.



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

Reply via email to