The LineSegment class is used by the LineMaterialSamplerBase class and for some ray tracing stuff. More...
#include <LineSegment.h>
Public Member Functions | |
LineSegment ()=default | |
LineSegment (const Point &p0, const Point &p1) | |
virtual | ~LineSegment ()=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 Plane &pl, Point &intersect_p) const |
bool | intersect (const LineSegment &l1, Point &intersect_p) const |
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... | |
Private Member Functions | |
bool | closest_point (const Point &p, bool clamp_to_segment, Point &closest_p) const |
Private Attributes | |
Point | _p0 |
Point | _p1 |
The LineSegment class is used by the LineMaterialSamplerBase class and for some ray tracing stuff.
Definition at line 29 of file LineSegment.h.
|
default |
LineSegment::LineSegment | ( | const Point & | p0, |
const Point & | p1 | ||
) |
Definition at line 17 of file LineSegment.C.
|
virtualdefault |
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 53 of file LineSegment.C.
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.
Definition at line 45 of file LineSegment.C.
Referenced by closest_normal_point(), and contains_point().
|
private |
Definition at line 20 of file LineSegment.C.
bool LineSegment::contains_point | ( | const Point & | p | ) | const |
Determines whether a point is in a line segment or not.
Definition at line 59 of file LineSegment.C.
Referenced by Moose::sideIntersectedByLine().
|
inline |
Ending of the line segment.
Definition at line 68 of file LineSegment.h.
Referenced by dataStore(), IntersectionPointsAlongLine::execute(), Moose::recursivelyFindElementsIntersectedByLine(), and to_json().
bool LineSegment::intersect | ( | const Plane & | pl, |
Point & | intersect_p | ||
) | const |
There are three cases in 3D for intersection of a line and a plane Case 1: The line is parallel to the plane - No intersection Numerator = non-zero Denominator = zero
Case 2: The line is within the plane - Inf intersection Numerator = zero Denominator = zero
Case 3: The line intersects the plane at a single point Denominator = non-zero
Definition at line 66 of file LineSegment.C.
Referenced by Moose::sideIntersectedByLine().
bool LineSegment::intersect | ( | const LineSegment & | l1, |
Point & | intersect_p | ||
) | const |
First check for concurance:
| x1 y1 z1 1 | | x2 y2 z2 1 | = (x3 - x1) * [(x2-x1) x (x4-x3)] = 0 | x3 y3 z3 1 | | x4 y4 z4 1 |
Solve: x = _p0 + (_p1 - _p0)*s x = l.p0 + (l._p1 - l.p0)*t
where a = _p1 - _p0 b = l._p1 - l._p0 c = l._p0 - _p0
s = (c x b) * (a x b) / | a x b |^2
Parameteric Equation of lines _p0 + t(v0) = l._p0 + u(v1) Case 1: Parallel Lines v0 x v1 == 0 Case 1a: Collinear Lines v0 x v1 == 0 (l._p0 - _p0) x (_p1 - _p0) == 0 Case 2: Intersecting Lines 0 <= t <= 1 0 <= u <= 1 Case 1: The lines do not intersect vleft cross vright = non-zero Case 2: The lines are co-linear vleft cross vright = zero vleft (Denominator) = zero Case 3: The line intersect at a single point vleft cross vright = zero vleft (Denominator) = non-zero
RealVectorValue v0 = _p1 - _p0; RealVectorValue v1 = l._p1 - l._p0; RealVectorValue v2 = l._p0 - _p0;
RealVectorValue vbot = v0.cross(v1); RealVectorValue vtop = v2.cross(v1);
RealVectorValue crossed = vleft.cross(vright);
Case 1: No intersection if (std::abs(vleft.cross(vright).size()) > 1.e-10) return false;
Case 2: Co-linear (just return one of the end points) if (std::abs(vleft.size()) < 1.e-10) { intersect_p = _p0; return true; }
Case 3:
TODO: We could detect whether the Line Segments actually overlap instead of whether the Lines are co-linear
Real a = vright.size()/vleft.size(); intersect_p = _p0 + a*v0; return true;
Definition at line 114 of file LineSegment.C.
|
inline |
void LineSegment::set | ( | const Point & | p0, |
const Point & | p1 | ||
) |
Sets the points on the line segment.
p0 | The start point of the line segment |
p1 | The end point of the line segment |
Definition at line 229 of file LineSegment.C.
Referenced by dataLoad().
|
inline |
|
inline |
Sets the beginning of the line segment.
Definition at line 73 of file LineSegment.h.
Referenced by set().
|
inline |
Beginning of the line segment.
Definition at line 63 of file LineSegment.h.
Referenced by dataStore(), and to_json().
|
private |
Definition at line 95 of file LineSegment.h.
Referenced by closest_point(), intersect(), length(), setStart(), and start().
|
private |
Definition at line 95 of file LineSegment.h.
Referenced by closest_point(), end(), intersect(), length(), and setEnd().