-
Notifications
You must be signed in to change notification settings - Fork 421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revert bug introduced in cylinder/half-space intersection. #267
Revert bug introduced in cylinder/half-space intersection. #267
Conversation
@SeanCurtis-TRI for feature review please. (Apparently I don't have the bits in this repo to assign you) |
Oops Reviewed 1 of 1 files at r1. include/fcl/narrowphase/detail/primitive_shape_algorithm/halfspace-inl.h, line 394 at r1 (raw file):
FYI Oops. My bad. That said, the intent is still good and the cheaper test would still be:
The previous incarnation of the test was still quite painful. However, in the name of getting things through, I would accept the revert and if I feel strongly about this, I'll PR it myself later. Comments from Reviewable |
Review status: all files reviewed at latest revision, 1 unresolved discussion. Comments from Reviewable |
I'm happy with the revert until we have a unit test to cover this! Reviewed 1 of 1 files at r1. Comments from Reviewable |
I believe CI barks at us for the same Mac build error we've seen before. If that's the case, this is ready to merge @sherm1 |
I'm keeping an eye on CI. I'd rather let it finish and then examine the results rather than pushing assuming things are good. The travis ci failures are due to issues unrelated to this PR
Waiting on windows to finish, and then the merge should be good. Review status: all files reviewed at latest revision, 1 unresolved discussion, some commit checks failed. Comments from Reviewable |
Sorry, I thought it had finished |
You're good. @sherm1 please merge. Review status: all files reviewed at latest revision, 1 unresolved discussion, some commit checks failed. Comments from Reviewable |
Although this might not be relevant here, for numerical stability reasons, it may be better to use |
@jmirabel |
As Then, I know that |
Moreover, the |
I think there are several separate issues in this test:
The suggestion of using So, the question is this: does the slop in deciding they are "parallel enough" dwarf the loss of precision due to use of However, referring to @jmirabel's concern about eps relative to 1, it is critical to make sure that eps is appropriately sized for "unit-length" calculations. It seems that some minor up-scaling of C++'s epsilon would be appropriate for that. So, in my mind, I'd recommend:
Thoughts? |
I agree 2 and 3 are not related. I assumed the vectors were unit-length and something could be done to make sure they are. I think 1 and 3 are not related in theory but they are related on a computer. Also, to check for how parallel they are, you do not really need the L2-norm but you need the cross product. Just to be sure I was understood. My main concern was on the numerical precision of |
Random thought (haven't looked closely though): sine and cosine are very flat near 1 -- they actually return 1 for an unpleasantly large range of angles there. Both are extremely well behaved near 0. So rather than checking for cos near 1, which is numerically bad, checking for sin near 0 would be well conditioned. (That's why atan2 is so much better than acos or asin.) Not sure if that makes sense here. |
Ahhh...I'd missed your concern. Yes, we definitely don't want it to be true that Now, for the sake of my own sense of clarity, I'd like to touch on something else you said. I can't see how you can avoid the L2-norm. The |
@sherm1 Yes, that is why I proposed to use @SeanCurtis-TRI You can use a L1-norm instead of the L2-norm. L1-norm looses the angle interpretation of the test but is faster to compute. |
@sherm1 You articulated my item 2 wonderfully well -- it's what I mean to suggest, but did it far too indirectly. @jmirabel I see what you're doing with the L1-norm. And the ratio of L2 and L1 norms is bounded by a constant. But, it becomes an approximation of the sine that is difficult to reason about. It becomes almost impossible to describe what epsilon would mean in that case. In my mind, it all comes down to what "parallel enough" is. Is it the intent that it means "strictly parallel" while accounting for finite precision? (In that case, the probability of two vectors being exactly parallel to infinite precision is essentially zero.) Or do we mean that, geometrically, there is a cone of deviation that should be considered parallel? If the latter, then we need a basis for defining the cone angle and that angle can inform us if using the cosine is insufficient for our purposes. EDIT: I just looked it up, epsilon, in this case, is 1e-7. |
We introduced a new bug in #255 when "simplifying" an
if
statement. A separate unit test should've been introduced in that PR for that change but we didn't and therefore we introduced a bug.This change is