Geophysical Inversion and Modelling Library  v1.4.3
GIMLI::Line Class Reference

A line. More...

+ Collaboration diagram for GIMLI::Line:

Public Member Functions

 Line ()
 
 Line (const RVector3 &p0)
 
 Line (const RVector3 &p0, const RVector3 &p1)
 
 Line (const Line &line)
 
 ~Line ()
 
Lineoperator= (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 RVector3p0 () const
 
const RVector3p1 () 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_
 

Detailed Description

A line.

A straight line segment in the geometrically point of view.

Constructor & Destructor Documentation

◆ Line() [1/4]

GIMLI::Line::Line ( )

Default constructor. Constructs an invalid straight line.

References copy_().

◆ Line() [2/4]

GIMLI::Line::Line ( const RVector3 p0)

Constructor, construct a line between p0 and the orign [0.0, 0.0, 0.0 ].

◆ Line() [3/4]

GIMLI::Line::Line ( const RVector3 p0,
const RVector3 p1 
)

Constructor construct a line betweem p0, and p1.

◆ Line() [4/4]

GIMLI::Line::Line ( const Line line)

Copycontructor

◆ ~Line()

GIMLI::Line::~Line ( )

Default destructor. Destroys the object.

References GIMLI::Pos::distance().

Member Function Documentation

◆ at()

RVector3 GIMLI::Line::at ( double  t) const
inline

Apply the line as function. ret = _p0 + (_p1 - _p0) * t

◆ checkValidity()

bool GIMLI::Line::checkValidity ( double  tol = TOLERANCE)

Check validility of the straight line. False if [ p0-p1] < tol.

◆ compare()

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

◆ copy_()

void GIMLI::Line::copy_ ( const Line line)
protected

internal: copy content of line into this line

Referenced by Line().

◆ distance()

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().

◆ intersect() [1/2]

RVector3 GIMLI::Line::intersect ( const Line line,
double  tol = TOLERANCE 
) const

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.

◆ intersect() [2/2]

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.

◆ 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.

Referenced by GIMLI::EdgeShape::intersectRay(), and GIMLI::Shape::touch().

◆ length()

double GIMLI::Line::length ( ) const
inline

Return the length if the line.

◆ nearest()

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.

◆ operator!=()

bool GIMLI::Line::operator!= ( const Line line) const
inline

Not_equal_to operator

◆ operator()()

const RVector3 GIMLI::Line::operator() ( double  t) const
inline

Functor to the line function. ret = _p0 + (_p1 - _p0) * t;

◆ operator=()

Line & GIMLI::Line::operator= ( const Line line)

Assignment operator

◆ operator==()

bool GIMLI::Line::operator== ( const Line line) const
inline

Equal_to operator

◆ p0()

const RVector3& GIMLI::Line::p0 ( ) const
inline

Return const reference to ref. point p0

◆ p1()

const RVector3& GIMLI::Line::p1 ( ) const
inline

Return const reference to ref. point p1

◆ t()

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().

◆ touch()

bool GIMLI::Line::touch ( const RVector3 pos,
double  tol = TOLERANCE 
) const

Return true if pos touches the line.

◆ touch1()

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

◆ valid()

bool GIMLI::Line::valid ( ) const
inline

Return the validity of this line.