14 #include "libmesh/plane.h" 15 #include "libmesh/vector_value.h" 29 Real perp = p0_p(0) * p0_p1(0) + p0_p(1) * p0_p1(1) + p0_p(2) * p0_p1(2);
30 Real t = perp / p0_p1_2;
31 bool on_segment =
true;
33 if (t < 0.0 || t > 1.0)
44 closest_p =
_p0 + p0_p1 * t;
91 Real denominator = I *
N;
106 Real d = numerator / denominator;
109 if (d + libMesh::TOLERANCE < 0 || d - libMesh::TOLERANCE > (
_p1 -
_p0).norm())
112 intersect_p = d * I +
_p0;
147 const auto tol = 1.e-10;
153 if (c.
cross(a).norm() >= tol)
188 if (s >= 0 && s <= 1 && t >= 0 && t <= 1)
190 intersect_p =
_p0 + s * a;
293 const auto tangent =
_p1 -
_p0;
296 Point n(-tangent(1), tangent(0), 0.0);
void setEnd(const Point &p1)
Sets the end of the line segment.
const Point & end() const
Ending of the line segment.
MetaPhysicL::DualNumber< V, D, asd > abs(const MetaPhysicL::DualNumber< V, D, asd > &a)
Ball primitive: a circle in 2D or a sphere in 3D.
void to_json(nlohmann::json &json, const LineSegment &l)
VectorValue< Real > RealVectorValue
The LineSegment class is used by the LineMaterialSamplerBase class and for some ray tracing stuff...
Point closest_point(const Point &p) const
Returns the closest point on the LineSegment to the passed in point.
const Point & get_planar_point() const
void dataStore(std::ostream &stream, LineSegment &l, void *context)
Point normal() const
normal vector of the line segment
void setStart(const Point &p0)
Sets the beginning of the line segment.
void set(const Point &p0, const Point &p1)
Sets the points on the line segment.
bool intersect(const libMesh::Plane &pl, Point &intersect_p) const
Check if a line segment intersects a plane, and if so, return the intersection point.
bool closest_normal_point(const Point &p, Point &closest_p) const
Finds the closest point on the Line determined by the Line Segments.
Ball computeBoundingBall() const override
Compute a bounding ball for this line segment.
const Point & start() const
Beginning of the line segment.
TypeVector< typename CompareTypes< Real, T2 >::supertype > cross(const TypeVector< T2 > &v) const
bool contains_point(const Point &p) const
Determines whether a point is in a line segment or not.
bool absolute_fuzzy_equals(const TypeVector< Real > &rhs, Real tol=TOLERANCE) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual Point unit_normal(const Point &p) const override
void dataLoad(std::istream &stream, LineSegment &l, void *context)