Correct calculation in ProjectPointToPlane#702
Conversation
- Use unit normal for projection. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
if we scaled the unit cube in InterpolationPoint_TEST.cc to a larger or smaller size would that be enough to illustrate the bug? I'd like to capture this effect in our tests if possible |
Yes, that should capture it. Uniform scaling will change the magnitude of the normal but not the expected interpolated values. Edit Seems that we also need to add a gradient to the field to ensure that the normalisation is fully checked. Test updated in b6c56dc. It will fail before this change, pass after. |
- Resize the sample grid and add a gradient to the field to check projection normalisation. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
|
https://github.com/Mergifyio backport main |
✅ Backports have been createdDetails
|
Use unit normal for projection. Update InterpolatePointTest to capture projection edges cases - Resize the sample grid and add a gradient to the field to check projection normalisation. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> Co-authored-by: Addisu Z. Taddese <addisu@openrobotics.org> (cherry picked from commit 06d73ac)
Use unit normal for projection. Update InterpolatePointTest to capture projection edges cases - Resize the sample grid and add a gradient to the field to check projection normalisation. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> Co-authored-by: Addisu Z. Taddese <addisu@openrobotics.org> (cherry picked from commit 06d73ac)
|
https://github.com/Mergifyio backport gz-math8 gz-math7 |
✅ Backports have been createdDetails
|
Use unit normal for projection. Update InterpolatePointTest to capture projection edges cases - Resize the sample grid and add a gradient to the field to check projection normalisation. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> Co-authored-by: Addisu Z. Taddese <addisu@openrobotics.org> (cherry picked from commit 06d73ac)
Use unit normal for projection. Update InterpolatePointTest to capture projection edges cases - Resize the sample grid and add a gradient to the field to check projection normalisation. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> Co-authored-by: Addisu Z. Taddese <addisu@openrobotics.org> (cherry picked from commit 06d73ac)
Use unit normal for projection. Update InterpolatePointTest to capture projection edges cases - Resize the sample grid and add a gradient to the field to check projection normalisation. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> Co-authored-by: Addisu Z. Taddese <addisu@openrobotics.org> (cherry picked from commit 06d73ac)
Use unit normal for projection. Update InterpolatePointTest to capture projection edges cases - Resize the sample grid and add a gradient to the field to check projection normalisation. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> Co-authored-by: Addisu Z. Taddese <addisu@openrobotics.org> (cherry picked from commit 06d73ac)
Use unit normal for projection. Update InterpolatePointTest to capture projection edges cases - Resize the sample grid and add a gradient to the field to check projection normalisation. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> Co-authored-by: Addisu Z. Taddese <addisu@openrobotics.org> (cherry picked from commit 06d73ac)
🦟 Bug fix
Summary
Use unit normal for projection in
gz::math::ProjectPointToPlane.Before this change the function used the unnormalised normal to calculated the projection of the interpolation point onto one of the grid parallelpiped surfaces. This caused the
gz::math::TrilinearInterpolateto return an incorrect interpolated value. These functions are used in theTimeVaryingVolumetricGrid, which in turn is used by the Environment system. The upshot is that this system incorrectly interpolates data whenever the trilinear interpolant is used. It is apparent when examining volumetric data using the PointCloud GUI widget, as the ranges displayed in the widget do not correspond to the underlying data provided to the Environment preload system.After this change the PointCloud display is consistent with the input data.
The unit test
InterpolationPoint_TESTdoes not catch this case, because the data is provided for a unit cube, and the normals calculated for this cube all have unit length, so the effect of scaling the normal is not tested. This is also the case for the environmental system tests in gz-sim. It may be better to use non-unit grids for testing systems that involve geometric calculations involving vector operations that depend on normalisation.There is a work-in-progress example here (https://github.com/srmainwaring/gz-math/tree/prs/volumetric-grid-example) that highlights the issue for a 4 x 4 x 4 grid sampled from a wind field.
Checklist
codecheckpassed (See contributing)Generated-by: Remove this if GenAI was not used.
Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-byandGenerated-bymessages.