86 template<
class TPo
intType,
class TGeometryType>
88 const TPointType& rPoint,
89 const TGeometryType& rLine
96 if(rLine.IsInside(result.
Coordinates(), projected_local))
99 const double distance1 =
norm_2(rLine[0] - result);
100 const double distance2 =
norm_2(rLine[1] - result);
102 result = (distance1 < distance2) ? rLine[0] : rLine[1];
133 template<
class TPo
intType,
class TGeometryType>
135 const TPointType& rPoint,
136 const TGeometryType& rTriangle
139 constexpr
double Tolerance = 1
e-12;
142 const Point center = rTriangle.Center();
144 double distance = 0.0;
146 rTriangle.PointLocalCoordinates(local_coordinates, point_projected);
149 if(local_coordinates[0] < -Tolerance) {
150 if(local_coordinates[1] < -Tolerance) {
151 result = rTriangle[0];
152 }
else if ((local_coordinates[0] + local_coordinates[1]) > (1.0+Tolerance)) {
153 result = rTriangle[2];
157 }
else if(local_coordinates[1] < -Tolerance) {
158 if ((local_coordinates[0] + local_coordinates[1]) > (1.0+Tolerance)) {
159 result = rTriangle[1];
163 }
else if ((local_coordinates[0] + local_coordinates[1]) > (1.0+Tolerance)) {
166 result = point_projected;
static TPointClass3 FastProject(const TPointClass1 &rPointOrigin, const TPointClass2 &rPointToProject, const array_1d< double, 3 > &rNormal, double &rDistance)
Project a point over a plane (avoiding some steps)
Definition: geometrical_projection_utilities.h:135
static double FastProjectOnLine(const TGeometryType &rGeometry, const PointType &rPointToProject, PointType &rPointProjected)
Project a point over a line (2D or 3D)
Definition: geometrical_projection_utilities.h:192
An two node 3D line geometry with linear shape functions.
Definition: line_3d_2.h:64
Tools to calculate the nearest point in different geometries.
Definition: nearest_point_utilities.h:47
NearestPointUtilities & operator=(NearestPointUtilities const &rOther)=delete
Assignment operator.
static Point TriangleNearestPoint(const TPointType &rPoint, const TGeometryType &rTriangle)
Finds the nearest point to the given point on a trianlge.
Definition: nearest_point_utilities.h:134
NearestPointUtilities(NearestPointUtilities const &rOther)=delete
Copy constructor.
static Point LineNearestPoint(const TPointType &rPoint, const TGeometryType &rLine)
Finds the nearest point to the given point on a line segment.
Definition: nearest_point_utilities.h:87
NearestPointUtilities()=delete
Default constructor.
KRATOS_CLASS_POINTER_DEFINITION(NearestPointUtilities)
Pointer definition of NearestPointUtilities.
Point class.
Definition: point.h:59
CoordinatesArrayType const & Coordinates() const
Definition: point.h:215
#define KRATOS_DEBUG_ERROR_IF_NOT(conditional)
Definition: exception.h:172
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
TExpressionType::data_type norm_2(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression)
Definition: amatrix_interface.h:625
e
Definition: run_cpp_mpi_tests.py:31
Configure::PointType PointType
Definition: transfer_utility.h:245