https://mooseframework.inl.gov
Public Member Functions | Private Member Functions | Private Attributes | List of all members
LineSegment Class Reference

The LineSegment class is used by the LineMaterialSamplerBase class and for some ray tracing stuff. More...

#include <LineSegment.h>

Inheritance diagram for LineSegment:
[legend]

Public Member Functions

 LineSegment ()=default
 
 LineSegment (const Point &p0, const Point &p1)
 
 ~LineSegment () override=default
 
Point closest_point (const Point &p) const
 Returns the closest point on the LineSegment to the passed in point. More...
 
bool closest_normal_point (const Point &p, Point &closest_p) const
 Finds the closest point on the Line determined by the Line Segments. More...
 
bool contains_point (const Point &p) const
 Determines whether a point is in a line segment or not. More...
 
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. More...
 
bool intersect (const LineSegment &l1, Point &intersect_p) const
 Check if a line segment intersects another line segment, and if so, return the intersection point. More...
 
bool intersect (const LineSegment &line_segment) const override
 Check if a line segment intersects another line segment, without returning the intersection point. More...
 
Ball computeBoundingBall () const override
 Compute a bounding ball for this line segment. More...
 
const Point & start () const
 Beginning of the line segment. More...
 
const Point & end () const
 Ending of the line segment. More...
 
void setStart (const Point &p0)
 Sets the beginning of the line segment. More...
 
void setEnd (const Point &p1)
 Sets the end of the line segment. More...
 
void set (const Point &p0, const Point &p1)
 Sets the points on the line segment. More...
 
Real length () const
 Length of segment. More...
 
Point normal () const
 normal vector of the line segment More...
 

Private Member Functions

bool closest_point (const Point &p, bool clamp_to_segment, Point &closest_p) const
 

Private Attributes

Point _p0
 
Point _p1
 

Detailed Description

The LineSegment class is used by the LineMaterialSamplerBase class and for some ray tracing stuff.

Definition at line 30 of file LineSegment.h.

Constructor & Destructor Documentation

◆ LineSegment() [1/2]

LineSegment::LineSegment ( )
default

◆ LineSegment() [2/2]

LineSegment::LineSegment ( const Point &  p0,
const Point &  p1 
)

◆ ~LineSegment()

LineSegment::~LineSegment ( )
overridedefault

Member Function Documentation

◆ closest_normal_point()

bool LineSegment::closest_normal_point ( const Point p,
Point closest_p 
) const

Finds the closest point on the Line determined by the Line Segments.

Returns a boolean indicating whether that normal point is within the LineSegment or not

Definition at line 57 of file LineSegment.C.

58 {
59  return closest_point(p, false, closest_p);
60 }
Point closest_point(const Point &p) const
Returns the closest point on the LineSegment to the passed in point.

◆ closest_point() [1/2]

Point LineSegment::closest_point ( const Point &  p) const

Returns the closest point on the LineSegment to the passed in point.

Note that the closest point may be one of the ends of the LineSegment.

Referenced by closest_normal_point(), and contains_point().

◆ closest_point() [2/2]

bool LineSegment::closest_point ( const Point &  p,
bool  clamp_to_segment,
Point &  closest_p 
) const
private

◆ computeBoundingBall()

Ball LineSegment::computeBoundingBall ( ) const
overridevirtual

Compute a bounding ball for this line segment.

The ball is defined by the midpoint of the segment and a radius equal to half the segment length.

Implements GeometryBase.

Definition at line 303 of file LineSegment.C.

304 {
305  const Point center = 0.5 * (_p0 + _p1);
306  const Real radius = 0.5 * (_p1 - _p0).norm();
307  return Ball(center, radius);
308 }
Ball primitive: a circle in 2D or a sphere in 3D.
Definition: Ball.h:34
const Real radius
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
auto norm(const T &a)

◆ contains_point()

bool LineSegment::contains_point ( const Point p) const

Determines whether a point is in a line segment or not.

Definition at line 63 of file LineSegment.C.

Referenced by Moose::sideIntersectedByLine().

64 {
65  Point closest_p;
66  return closest_point(p, false, closest_p) && closest_p.absolute_fuzzy_equals(p);
67 }
Point closest_point(const Point &p) const
Returns the closest point on the LineSegment to the passed in point.
bool absolute_fuzzy_equals(const TypeVector< Real > &rhs, Real tol=TOLERANCE) const

◆ end()

const Point& LineSegment::end ( ) const
inline

◆ intersect() [1/3]

bool LineSegment::intersect ( const libMesh::Plane pl,
Point &  intersect_p 
) const

Check if a line segment intersects a plane, and if so, return the intersection point.

Referenced by intersect(), and Moose::sideIntersectedByLine().

◆ intersect() [2/3]

bool LineSegment::intersect ( const LineSegment l1,
Point &  intersect_p 
) const

Check if a line segment intersects another line segment, and if so, return the intersection point.

◆ intersect() [3/3]

bool LineSegment::intersect ( const LineSegment line_segment) const
overridevirtual

Check if a line segment intersects another line segment, without returning the intersection point.

Implements GeometryBase.

Definition at line 253 of file LineSegment.C.

254 {
255  Point p;
256  return intersect(line_segment, p);
257 }
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.

◆ length()

Real LineSegment::length ( ) const
inline

Length of segment.

Definition at line 112 of file LineSegment.h.

112 { return (_p0 - _p1).norm(); }

◆ normal()

Point LineSegment::normal ( ) const

normal vector of the line segment

Definition at line 291 of file LineSegment.C.

292 {
293  const auto tangent = _p1 - _p0;
294 
295  // Rotate 90 degrees counter-clockwise (2D)
296  Point n(-tangent(1), tangent(0), 0.0);
297  n /= n.norm();
298 
299  return n;
300 }

◆ set()

void LineSegment::set ( const Point p0,
const Point p1 
)

Sets the points on the line segment.

Parameters
p0The start point of the line segment
p1The end point of the line segment

Definition at line 260 of file LineSegment.C.

Referenced by dataLoad().

261 {
262  setStart(p0);
263  setEnd(p1);
264 }
void setEnd(const Point &p1)
Sets the end of the line segment.
Definition: LineSegment.h:100
void setStart(const Point &p0)
Sets the beginning of the line segment.
Definition: LineSegment.h:95

◆ setEnd()

void LineSegment::setEnd ( const Point &  p1)
inline

Sets the end of the line segment.

Definition at line 100 of file LineSegment.h.

Referenced by set().

100 { _p1 = p1; }

◆ setStart()

void LineSegment::setStart ( const Point &  p0)
inline

Sets the beginning of the line segment.

Definition at line 95 of file LineSegment.h.

Referenced by set().

95 { _p0 = p0; }

◆ start()

const Point& LineSegment::start ( ) const
inline

Beginning of the line segment.

Definition at line 85 of file LineSegment.h.

Referenced by dataStore(), Triangle::intersect(), Ball::intersect(), and to_json().

85 { return _p0; }

Member Data Documentation

◆ _p0

Point LineSegment::_p0
private

Definition at line 122 of file LineSegment.h.

Referenced by computeBoundingBall(), length(), normal(), setStart(), and start().

◆ _p1

Point LineSegment::_p1
private

Definition at line 122 of file LineSegment.h.

Referenced by computeBoundingBall(), end(), length(), normal(), and setEnd().


The documentation for this class was generated from the following files: