Made triangle barycentric coordinates possible in 2D #1207
Made triangle barycentric coordinates possible in 2D #1207fsimonis merged 7 commits intoprecice:developfrom
Conversation
| uc = c - u; | ||
| ua = a - u; | ||
|
|
||
| scaleFactor = 1.0 / crossProduct2D(ab, ac); |
There was a problem hiding this comment.
This will crash for zero vectors among others. Can you assert this isn't 0?
There was a problem hiding this comment.
It wasn't checked in 3D either, so I just added assertions for both cases.
|
@fsimonis I just realized in (surface) NP there is a test case that uses a degenerate triangle, so my new assertion makes the test fail. precice/src/mapping/tests/NearestProjectionMappingTest.cpp Lines 343 to 349 in 5749690 Is that intended? |
|
The API currently allows such triangles, so we should we support them here as well. Maybe we could/should extend the checks of the input mesh. |
|
I don't get what you would do. Allow these triangles only when NP is not used? (Then the test case still divides by zero) |
|
Ok, supporting degenerate triangles is nonsense here. I propose to do the following in this PR:
In another PR:
|
|
I removed the degenerate test and all checks have passed :) |
|
Perfect. I'll merge this and prepare additional checks in the API. |
Main changes of this PR
precice::math::barycenter::calcBarycentricCoordsForTrianglenow works with triangles in a 2D mesh.dimensions == 3in the Triangle constructor.Motivation and additional information
Prerequisite to volume coupling.
Author's checklist
make changelogif there are user-observable changes since the last release.make formatto ensure everything is formatted correctly.Reviewers' checklist
@fsimonis is a changelog needed here? I guess not but I didn't check whether there's somewhere written that you can't add a triangle in 2D where it should be changed.
The algorithm for 3D seemed hard to adapt in 2D so I designed a new one with pen & paper. Not sure it is optimal but I think it is cheap enough.
However, I'm not sure whether an if-else in the function is a better design choice than two separate functions or not.