Geophysical Inversion and Modelling Library
v1.4.3
|
A line. More...
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.
References copy_().
GIMLI::Line::Line | ( | const RVector3 & | p0 | ) |
Constructor, construct a line between p0 and the orign [0.0, 0.0, 0.0 ].
Constructor construct a line betweem p0, and p1.
GIMLI::Line::Line | ( | const Line & | line | ) |
Copycontructor
GIMLI::Line::~Line | ( | ) |
Default destructor. Destroys the object.
References GIMLI::Pos::distance().
|
inline |
Apply the line as function. ret = _p0 + (_p1 - _p0) * t
bool GIMLI::Line::checkValidity | ( | double | tol = TOLERANCE | ) |
Check validility of the straight line. False if [ p0-p1] < tol.
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
|
protected |
internal: copy content of line into this line
Referenced by Line().
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 |
Referenced by t().
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.
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.
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.
Referenced by GIMLI::EdgeShape::intersectRay(), and GIMLI::Shape::touch().
|
inline |
Return the length if the line.
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
|
inline |
Functor to the line function. ret = _p0 + (_p1 - _p0) * t;
|
inline |
Equal_to operator
|
inline |
Return const reference to ref. point p0
|
inline |
Return const reference to ref. point p1
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 distance().
Referenced by GIMLI::Shape::touch().
bool GIMLI::Line::touch | ( | const RVector3 & | pos, |
double | tol = TOLERANCE |
||
) | const |
Return true if pos touches the line.
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
|
inline |
Return the validity of this line.