Geophysical Inversion and Modelling Library v1.5.4
|
A line. More...
#include <line.h>
Public Member Functions | |
Line () | |
Line (const RVector3 &p0) | |
Line (const RVector3 &p0, const RVector3 &p1) | |
Line (const Line &line) | |
~Line () | |
Line & | operator= (const Line &line) |
const RVector3 | operator() (double t) const |
bool | operator== (const Line &line) const |
bool | operator!= (const Line &line) const |
bool | checkValidity (double tol=TOLERANCE) |
bool | valid () const |
bool | compare (const Line &line, double tol=TOLERANCE) const |
const RVector3 & | p0 () const |
const RVector3 & | p1 () const |
bool | intersectRay (const RVector3 &start, const RVector3 &dir, RVector3 &pos, double tol=TOLERANCE) const |
RVector3 | intersect (const RVector3 &start, const RVector3 &dir, double tol=TOLERANCE) const |
RVector3 | intersect (const Line &line, double tol=TOLERANCE) const |
double | nearest (const RVector3 &p) const |
RVector3 | at (double t) const |
double | distance (const RVector3 &pos) const |
double | t (const RVector3 &pos, double tol=TOLERANCE) const |
bool | touch1 (const RVector3 &pos, int &pFunIdx, double tol=TOLERANCE) const |
bool | touch (const RVector3 &pos, double tol=TOLERANCE) const |
double | length () const |
Protected Member Functions | |
void | copy_ (const Line &line) |
Protected Attributes | |
RVector3 | _p0 |
RVector3 | _p1 |
bool | valid_ |
A line.
A straight line segment in the geometrically point of view.
GIMLI::Line::Line | ( | ) |
Default constructor. Constructs an invalid straight line.
Referenced by compare(), copy_(), intersect(), Line(), operator!=(), operator=(), and operator==().
GIMLI::Line::Line | ( | const RVector3 & | p0 | ) |
Constructor, construct a line between p0 and the orign [0.0, 0.0, 0.0 ].
References checkValidity().
Constructor construct a line betweem p0, and p1.
References checkValidity(), p0(), and p1().
GIMLI::Line::~Line | ( | ) |
Default destructor. Destroys the object.
|
inline |
Apply the line as function. ret = _p0 + (_p1 - _p0) * t
References t().
Referenced by intersectRay(), and operator()().
bool GIMLI::Line::checkValidity | ( | double | tol = TOLERANCE | ) |
bool GIMLI::Line::compare | ( | const Line & | line, |
double | tol = TOLERANCE ) const |
Compare two lines with a given tolerance. Check if both ref points from line touch this line.. distance(this, line.p1)< tol && distance(this, line.p2)< tol
References Line(), p0(), p1(), and touch().
Referenced by operator==().
|
protected |
double GIMLI::Line::distance | ( | const RVector3 & | pos | ) | const |
Return the distance between this line and pos, https://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html; | x2-x1 cross x1-x0 | / | x2 -x1 |
Returns the intersection point between line and this line. Returns an invalid RVector3 of both do not touch, are equal or parallel. Return is invalid if they don't intersect.
References Line().
RVector3 GIMLI::Line::intersect | ( | const RVector3 & | start, |
const RVector3 & | dir, | ||
double | tol = TOLERANCE ) const |
Return insection position of this line segment with a the ray given by start and direction dir. Pos is invalid for no intersection.
References intersectRay().
bool GIMLI::Line::intersectRay | ( | const RVector3 & | start, |
const RVector3 & | dir, | ||
RVector3 & | pos, | ||
double | tol = TOLERANCE ) const |
Return true if this line segment intersect with a the ray given by start and direction dir. Fill pos with the intersection position. Returns also true if the ray is parallel and the distance between Line and ray is smaller than the tolerance but pos is not valid.
References at(), and GIMLI::Pos::length().
Referenced by intersect(), GIMLI::EdgeShape::intersectRay(), and GIMLI::Shape::touch().
|
inline |
Return the length if the line.
Referenced by touch1().
double GIMLI::Line::nearest | ( | const RVector3 & | p | ) | const |
Returns line parameter t that represents the nearest position to the line for the given point p. Feed it to at() and you get the nearest point.
|
inline |
Not_equal_to operator
References Line().
|
inline |
|
inline |
|
inline |
Return const reference to ref. point p0
Referenced by compare(), copy_(), GIMLI::Plane::intersect(), and Line().
|
inline |
Return const reference to ref. point p1
Referenced by compare(), copy_(), GIMLI::Plane::intersect(), and Line().
double GIMLI::Line::t | ( | const RVector3 & | pos, |
double | tol = TOLERANCE ) const |
Return position at line. solves: pos = _p0 + (_p1 - _p0) * ret. ret = (pos - _p0) / (_p1 - _p0) Throws an exception if pos is not on Line.
References t().
Referenced by at(), operator()(), t(), GIMLI::Shape::touch(), and touch1().
bool GIMLI::Line::touch | ( | const RVector3 & | pos, |
double | tol = TOLERANCE ) const |
Return true if pos touches the line.
References distance().
Referenced by compare(), and GIMLI::EdgeShape::touch().
bool GIMLI::Line::touch1 | ( | const RVector3 & | pos, |
int & | pFunIdx, | ||
double | tol = TOLERANCE ) const |
Return true if pos touches the line. pFunIdx gives an identifier which shows the dependency between this Line and the RVector3 pos. Possible return values are:
-1 – this straight line don't touch the Position pos
1 – this straight line touch the Position pos and pos lies before _p0
2 – this straight line touch the Position pos and pos lies at the same position like pos _p0
3 – this straight line touch the Position pos and pos lies within the definition positions _p0 and _p1
4 – this straight line touch the Position pos and pos lies at the same position like pos _p1
5 – this straight line touch the Position pos and pos lies behind _p1
References distance(), length(), and t().
Referenced by GIMLI::Mesh::createNodeWithCheck(), and GIMLI::PolygonFace::insertNode().
|
inline |
Return the validity of this line.
Referenced by copy_(), and GIMLI::Plane::intersect().