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;
88 RealVectorValue I = (
_p1 -
_p0).unit();
90 Real numerator = (pl0 -
_p0) * N;
91 Real denominator = I * N;
94 if (std::abs(denominator) < 1.e-10)
97 if (std::abs(numerator) < 1.e-10)
106 Real d = numerator / denominator;
109 if (d + libMesh::TOLERANCE < 0 || d - libMesh::TOLERANCE > (
_p1 -
_p0).norm())
112 intersect_p = d * I +
_p0;
141 RealVectorValue a =
_p1 -
_p0;
142 RealVectorValue b = l.
_p1 - l.
_p0;
143 RealVectorValue c = l.
_p0 -
_p0;
145 RealVectorValue v = a.
cross(b);
147 const auto tol = 1.e-10;
153 if (c.cross(a).norm() >= tol)
177 Real concur = c * (a.cross(b));
178 if (std::abs(concur) > 1.e-10)
181 Real s = (c.cross(b) * v) / (v * v);
182 Real t = (c.cross(a) * v) / (v * v);
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 dataLoad(std::istream &stream, LineSegment &l, void *context)
void to_json(nlohmann::json &json, const LineSegment &l)
void dataStore(std::ostream &stream, LineSegment &l, void *context)
Ball primitive: a circle in 2D or a sphere in 3D.
The LineSegment class is used by the LineMaterialSamplerBase class and for some ray tracing stuff.
Ball computeBoundingBall() const override
Compute a bounding ball for this 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.
bool contains_point(const Point &p) const
Determines whether a point is in a line segment or not.
const Point & end() const
Ending of the line segment.
void set(const Point &p0, const Point &p1)
Sets the points on the line segment.
void setStart(const Point &p0)
Sets the beginning of the line segment.
Point normal() const
normal vector of the line segment
void setEnd(const Point &p1)
Sets the end of the line segment.
const Point & start() const
Beginning of the line segment.
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
virtual Point unit_normal(const Point &p) const override
bool absolute_fuzzy_equals(const TypeVector< Real > &rhs, Real tol=TOLERANCE) const
TypeVector< typename CompareTypes< T, T2 >::supertype > cross(const TypeVector< T2 > &v) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real