-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Fix for possible normalization issue for line corner points #12255
Conversation
Thank you for the pull request, @p-skakun! ✅ We can confirm we have a CLA on file for you. |
Add reference to pull request into change.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the fix @p-skakun! The approach here all makes sense to me.
Could we please add a unit test for this case for both CorridorGeometryLibrary.computePositions
and PolylineVolumeGeometryLibrary.computePositions
? I know there are no existing tests, but adding even one to confirm this edge case would be a huge benefit.
If you are feeling generous, we would of course appreciate additional unit tests for those functions, but that is certainly not expected to get this PR merged. 😄
I added a few tests, but the |
Description
If points in PolylineVolume or Corridor are collinear, computation fails with error "Normalized result is not a number" in the line below, because sum of normalized forward and backward vectors is zero.
cesium/packages/engine/Source/Core/PolylineVolumeGeometryLibrary.js
Line 438 in 0e9a425
The
cornerDirection
variable is only used within thedoCorner === true
execution branch, so I moved it inside the branch for better scoping. From my understanding, the forward and backward projection checks within thedoCorner
condition exclude the computation of corners for collinear points. As a result, normalizingcornerDirection
in this execution branch should not cause any errors.Issue number and link
Fixes #12254
Testing plan
This issue is difficult to replicate. I encountered it by chance, with the data shown in Sandcastle example attached to related issue.
I haven't yet found a way to generate synthetic data to reproduce the issue, mainly due to the
scaleToSurface
call, which modifies coordinates based on a specific location.cesium/packages/engine/Source/Core/PolylineVolumeGeometryLibrary.js
Line 35 in 0e9a425
To test it, I followed this approach:
computePositions
that omits the scaleToSurface call and other irrelevant operations. This resulted in a "Normalized result is not a number" error when passing a simple collinear line like[[0,0,0], [1,1,1], [2,2,2], [3,3,3]]
as thepositions
input.Author checklist
CONTRIBUTORS.md
CHANGES.md
with a short summary of my change