Skip to content
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

[Geometry] Add methods getBarycentricCoordinates and isPointInTriangle in Triangle class #4053

Merged
merged 13 commits into from
Sep 7, 2023

Conversation

epernod
Copy link
Contributor

@epernod epernod commented Jul 19, 2023

Add method:

  • pointBaryCoefs to Compute the barycentric coefficients of input point in the current Triangle
  • method isPointInTriangle using the barycentric coefficients
  • Add unit tests with positive and negative cases

By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).


Reviewers will merge this pull-request only if

  • it builds with SUCCESS for all platforms on the CI.
  • it does not generate new warnings.
  • it does not generate new unit test failures.
  • it does not generate new scene test failures.
  • it does not break API compatibility.
  • it is more than 1 week old (or has fast-merge label).

@epernod epernod added pr: status to review To notify reviewers to review this pull-request pr: new feature Implement a new feature labels Jul 19, 2023
@alxbilger
Copy link
Contributor

[ci-build][with-all-tests]

@epernod epernod added pr: status wip Development in the pull-request is still in progress and removed pr: status to review To notify reviewers to review this pull-request labels Aug 6, 2023
@epernod epernod added pr: status to review To notify reviewers to review this pull-request and removed pr: status wip Development in the pull-request is still in progress labels Aug 28, 2023
@fredroy fredroy added pr: status wip Development in the pull-request is still in progress and removed pr: status to review To notify reviewers to review this pull-request labels Aug 30, 2023
@hugtalbot
Copy link
Contributor

Do you know why the function is not removed in the other code?
We maybe should create an issue not to forget to clean the GeometryAlgorithms

@epernod epernod added pr: status to review To notify reviewers to review this pull-request and removed pr: status wip Development in the pull-request is still in progress labels Sep 4, 2023
@epernod epernod marked this pull request as draft September 4, 2023 08:41
@epernod
Copy link
Contributor Author

epernod commented Sep 4, 2023

Do you know why the function is not removed in the other code? We maybe should create an issue not to forget to clean the GeometryAlgorithms

For the moment, the old method is not removed because it was not well handling all cases. Therefor the new method has a slightly different (better) behavior. Switching to the new one might cause some scene regressions to fail. I prefer to do that in a next PR.

For the TriangleSetGeometryAlgorithm clean, you can create an issue if you want but it is already a wip on my dev branch: See https://github.com/epernod/sofa/pull/10/files#diff-e1443ad8032ebc3d01202980477d0fd24cf3c4db16a90452dd51f780bffe2e3f
I will push the changes progressively

@epernod epernod marked this pull request as ready for review September 4, 2023 23:11
typename T = std::decay_t<decltype(*std::begin(std::declval<Node>()))>,
typename = std::enable_if_t<std::is_scalar_v<T>>
>
static constexpr auto pointBaryCoefs(const Node& p0, const Node& n0, const Node& n1, const Node& n2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pointBaryCoefs, the name looks... not really informative and uses abbreviations.
Maybe something like getBarycentricCoefficients() or even getBarycentricCoordinates() which seems more in par with the maths

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done and add more description on the method (based from wikipedia)

@epernod epernod changed the title [Geometry] Add methods pointBaryCoefs and isPointInTriangle in Triangle class [Geometry] Add methods getBarycentricCoordinates and isPointInTriangle in Triangle class Sep 6, 2023
@fredroy fredroy added pr: status ready Approved a pull-request, ready to be squashed and removed pr: status to review To notify reviewers to review this pull-request labels Sep 7, 2023
@fredroy fredroy merged commit f0666f5 into sofa-framework:master Sep 7, 2023
5 checks passed
@epernod epernod deleted the inf_2023_09_isPointInTriangle branch September 7, 2023 08:24
epernod added a commit to epernod/sofa that referenced this pull request Sep 8, 2023
@hugtalbot hugtalbot added this to the v23.12 milestone Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: new feature Implement a new feature pr: status ready Approved a pull-request, ready to be squashed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants