Fix float stability in orthogonal_vector #252
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #251
Switched the generic
orthogonal_vector
towhich is equivalent to the previous formula as the last two terms cancel. (Swapping the order of cross product inputs introduces a - which allows one term to cancel the other over the full summation.) (The summation skips the last iteration as q_i+1 - q_1 = q_1 - q_1 doesn't contribute.)
Also extended the types for the fast path so it's hit by default for triangle meshes again
All the failing triangles from #251 removed subtractions from the cross product. I added a few of these as tests, as well as one which doesn't remove subtractions. I also added another sanity check for faces with more than 4 vertices (verified on master) as I was getting confused about what length to expect.