Menu

#27 findNearestPt() is incorrect for planes not going through the origin

0.1.x
open
nobody
None
5
2013-09-17
2013-09-17
Joe Lee
No

The plane operation findNearestPt() is incorrect for planes not going through the origin. There are test cases in the PlaneTest suite, but they are all for planes going through the origin.

The problem is that findNearestPt() needs a sign inversion from the Graphics Gems article on which it is based. Per the article:

dot(J_N, Q) + J_d = 0

where J_N is the normal, Q is the closest point on the plane, and J_d is an "offset". This implies dot(J_N, Q) = -J_d. However, the gmtl Plane constructor for a normal and a point on the plane assigns mOffset to the dot product between the normal and the point, which means J_d should be -mOffset, not mOffset.

A simple fix is to just flip the sign. However, it might be slightly cleaner to just reuse the distance-to-plane operation already present in PlaneOps. (see attached patch)

I could not find relevant information on the cited GG2 page... You may want to remove or amend the comment.

Also, the Plane test suite is not being run because it is not registered using the appropriate CppUnit macro. Other suites also appear to have this problem.

1 Attachments

Discussion


Log in to post a comment.