Page MenuHomePhabricator

Method ProjectPointOntoPlane() of class mitk::PlaneGeometry does not work correct.
Closed, ResolvedPublic

Description

I wrote a small test method, which shows a case when the method ProjectPointOntoPlane() gives a wrong result, which is attached to this text. I also attached a screenshot where you can see the wrong result.

Proposal for solving this bug:
The vtk method "vtkPlane::GeneralizedProjectPoint()" does also project a point onto a plane and works fine in my case. So you can use this method for a correct calculation of the projected point in the PlaneGeometry class.

#include <mitkPlaneGeometry.h>

static void projectPoint()
{

mitk::PlaneGeometry::Pointer myPlaneGeometry = mitk::PlaneGeometry::New();
mitk::Vector3D normal; normal[0] = 0; normal[1] = 0; normal[2] = 1; 
mitk::Point3D point; 
point[0] = -27.582859; 
point[1] = 50; 
point[2] = 200.27742;
myPlaneGeometry->InitializePlane(point,normal);

std::cout << std::endl << std::endl 
<< "Our normal is: " << normal << std::endl;
std::cout << "so ALL projected points should have exactly the 
same z-  value!" << std::endl;

mitk::Point3D myPoint1; 
myPoint1[0] = -27.582859; 
myPoint1[1] = 50.00;   
myPoint1[2] = 200.27742;

mitk::Point3D myPoint2; 
myPoint2[0] = -26.58662; 
myPoint2[1] = 50.00; 
myPoint2[2] = 200.19026;
      
std::cout << "Point1: " << myPoint1 << "=> ";
std::cout << "Projected Point1: " 
<< myPlaneGeometry->ProjectPointOntoPlane(myPoint1) << std::endl;

std::cout << "Point2: " << myPoint2 << "=> ";
std::cout << "Projected Point2: " 
<< myPlaneGeometry->ProjectPointOntoPlane(myPoint2) << std::endl;

}

Event Timeline

franza added a subscriber: franza.

Added output screenshot

output_screenshot.PNG (80×668 px, 4 KB)

@Alfred: thanks, could you please add your code to the PlaneGeometry test (commented) to show the problem.

Reassign to Mathias, original author of method

Yes, i can add this code to the test, but the test is in the core part of mitk. So core modification is needed to do this.

[SVN revision 21724]
ENH (#3409): Added test method to reproduce T3409. The part where the method is called is commended out at the moment. If you want to fix the bug you can remove the comment marks in line 201 of the code.

[SVN revision 21750]
FIX (#3409): Fixed calculation of point projection and extended test case with a few more points

THe methode ProjectPointOntoPlane() internally calculates the distance of a point to the plane. The signed distance is required here, but the unsigned distance was used. Changed this to use signed distance.

The previous test works with these changes. When adding more tests for new points, the test failed due to small numerical errors in point projectin calculation. The new test now checks if the z-coordinates of the plane origin and the projected points differ at most by the epsilon value mitk::sqrteps.

[SVN revision 21836]
ENH (#3409): Remove PointSetToSurfaceFilter because it cannot be implemented as easy as expected.