PeriDEM 0.3.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
geom::anonymous_namespace{openRectChannel2D.cpp} Namespace Reference

Functions

void validateParams (double x0, double y0, double x1, double y1, double t)
 
double distPointToSegment2D (const util::Point &p, const util::Point &a, const util::Point &b)
 

Function Documentation

◆ distPointToSegment2D()

double geom::anonymous_namespace{openRectChannel2D.cpp}::distPointToSegment2D ( const util::Point p,
const util::Point a,
const util::Point b 
)

Definition at line 35 of file openRectChannel2D.cpp.

35 {
36 const util::Point ab = b - a;
37 const util::Point ap = p - a;
38 const double L2 = ab * ab;
39 if (L2 < 1.0e-30)
40 return ap.length();
41 double s = (ap * ab) / L2;
42 s = std::max(0., std::min(1., s));
43 const util::Point proj = a + s * ab;
44 return (p - proj).length();
45}
A structure to represent 3d vectors.
Definition point.h:30
double length() const
Computes the Euclidean length of the vector.
Definition point.h:124

References distPointToSegment2D(), and util::Point::length().

Referenced by distPointToSegment2D().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ validateParams()

void geom::anonymous_namespace{openRectChannel2D.cpp}::validateParams ( double  x0,
double  y0,
double  x1,
double  y1,
double  t 
)

Definition at line 25 of file openRectChannel2D.cpp.

25 {
26 constexpr double eps = 1.0e-12;
27 if (!(x1 > x0 + eps && y1 > y0 + eps && t > eps))
28 throw std::runtime_error(
29 "OpenRectChannel2D: require x0 < x1, y0 < y1, t > 0.");
30 if (!(x1 - x0 > 2. * t + eps && y1 - y0 > 2. * t + eps))
31 throw std::runtime_error(
32 "OpenRectChannel2D: require x1-x0 > 2t and y1-y0 > 2t so the U-channel exists.");
33}