intersectsWherePlane problem (strange behavior)

Please find below some basic source code/log for a computation which is giving wrong results.

Basically, I have a plane and two points, one on positive side, one on negative.

I want to find the unique intersection of the plane and the line connecting the two points.

Code below implements this, casting one ray from point0 to point1, and one ray from point1 to point0.

The intersection point I get with intersectsWherePlane is the same in both cases, but wrong: it does NOT lay on the intersection plane. To verify it, I compute the plane constant as Normal dot (x,y,z) = Constant as specified at http://www.jmonkeyengine.com/doc/com/jme/math/Plane.html.

The constant computed for the intersection points is exactly the opposite of that of the intersecting plane.

Where is my mistake?


        Plane plane = new Plane(new Vector3f(0.8682431f, 0.0f, -0.49613893f), 18.60521f);
        Vector3f point0 = new Vector3f(0.0f, 0.0f, 100.0f);
        Vector3f point1 = new Vector3f(0.0f, 0.0f, -100.0f);

        System.out.println("side of point 0:  " + plane.whichSide(point0));
        System.out.println("side of point 1:  " + plane.whichSide(point1));

        System.out.println("original c:  " + plane.getConstant());

        // From point0 to point1
        Vector3f intersection01 = new Vector3f();
        Ray ray01 = new Ray(point0, point1.subtract(point0).normalize());
        Boolean intersected01 = ray01.intersectsWherePlane(plane, intersection01);
        System.out.println("intersected01: " + intersected01);
        System.out.println("computed c: " + plane.getNormal().dot(intersection01));

        // From point1 to point0
        Vector3f intersection10 = new Vector3f();
        Ray ray10 = new Ray(point1, point0.subtract(point1).normalize());
        Boolean intersected10 = ray10.intersectsWherePlane(plane, intersection10);
        System.out.println("intersected10: " + intersected10);
        System.out.println("computed c: " + plane.getNormal().dot(intersection10));




side 0:  2
side 1:  1
original c:  18.60521
intersected01: true
computed c: -18.60521
intersected10: true
computed c: -18.60521

Beats me…  ://

I suppose that in english this means that you don't know why :slight_smile:

Can this be a bug?

I have the same behaviour.

Can this be a bug?



Eduard