Conversation
|
FYI not sure this is the way to go, check #7401 => IMO the projection should happen separately (see geom-projection-utils) |
Well, I have revered the projection and only adding the distance check. For sure it makes the function more expansive. |
Wow this topic is old. How on earth did this never get merged?! |
tests were failing, and I guess not enough interest to fix it 🤷 |
|
@sunethwarna In CoSimApp, the PointLocalCoordinates is used to project a faraway point on the truss elements for beam mapping cases. Adding a distance check kills this function completely. I can move the check distance to IsInside as it was originally. What do you think?
|
There was a problem hiding this comment.
Pull request overview
Fixes Line3D2::IsInside for 3D truss/line geometries by rejecting points that are within the parametric range but far away from the actual line segment (regression case in the PR description).
Changes:
- Add a perpendicular distance check to
Line3D2::IsInsideto avoid false positives for off-line points. - Add a regression test covering the reported corner case in
test_line_3d_2.cpp.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
kratos/geometries/line_3d_2.h |
Adds a distance-to-segment check in IsInside to prevent off-line points being classified as inside. |
kratos/tests/cpp_tests/geometries/test_line_3d_2.cpp |
Adds a new corner-case geometry + assertion to prevent regressions of the reported bug. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Check if point is too far away from the line, if so, return false | ||
| const double distance = this->CalculateDistance(rPoint, Tolerance); | ||
| const double length = Length(); | ||
| if (distance > std::max(Tolerance, 1e-6 * length)) { |
There was a problem hiding this comment.
Tolerance in IsInside is used as a local-space boundary tolerance (dimensionless), but here it is also compared directly against a global-space distance. This mixes units and can make the “allowed” perpendicular distance unexpectedly large/small depending on the caller-provided Tolerance. Consider using a distance tolerance expressed in length units (e.g., scale Tolerance by Length() or follow the existing Line2D2 approach using a relative 1e-6*Length() threshold) and avoid using the raw Tolerance value as a distance.
| if (distance > std::max(Tolerance, 1e-6 * length)) { | |
| const double distance_tolerance = std::max(Tolerance * length, 1e-6 * length); | |
| if (distance > distance_tolerance) { |

📝 Description
Fix the Point Projection onto the truss element in the 3D case by adding the distance check.
Corner Case:
Point (-16, 2.5, 0)
r_element : Element #21 :
Working space dimension : 3
Local space dimension : 1
rResult[0] : 0.886796
Expected to be False, Returns True.