Geophysical Inversion and Modelling Library v1.5.4
Loading...
Searching...
No Matches
line.h
1/******************************************************************************
2 * Copyright (C) 2006-2024 by the GIMLi development team *
3 * Carsten Rücker carsten@resistivity.net *
4 * *
5 * Licensed under the Apache License, Version 2.0 (the "License"); *
6 * you may not use this file except in compliance with the License. *
7 * You may obtain a copy of the License at *
8 * *
9 * http://www.apache.org/licenses/LICENSE-2.0 *
10 * *
11 * Unless required by applicable law or agreed to in writing, software *
12 * distributed under the License is distributed on an "AS IS" BASIS, *
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
14 * See the License for the specific language governing permissions and *
15 * limitations under the License. *
16 * *
17 ******************************************************************************/
18
19#ifndef GIMLI_LINE__H
20#define GIMLI_LINE__H
21
22#include "gimli.h"
23#include "pos.h"
24
25namespace GIMLI{
26
28
29
30class DLLEXPORT Line {
31public:
33 Line();
34
36 Line(const RVector3 & p0);
37
39 Line(const RVector3 & p0, const RVector3 & p1);
40
42 Line(const Line & line);
43
45 ~Line();
46
48 Line & operator = (const Line & line);
49
51 inline const RVector3 operator()(double t) const { return this->at(t); }
52
54 inline bool operator == (const Line & line) const { return this->compare(line); }
55
57 inline bool operator != (const Line & line) const { return !(*this == line); }
58
60 bool checkValidity(double tol=TOLERANCE);
61
63 inline bool valid() const { return valid_; }
64
67 bool compare(const Line & line, double tol=TOLERANCE) const;
68
70 const RVector3 & p0() const { return _p0; }
71
73 const RVector3 & p1() const { return _p1; }
74
79 bool intersectRay(const RVector3 & start, const RVector3 & dir,
80 RVector3 & pos, double tol=TOLERANCE) const;
81
84 RVector3 intersect(const RVector3 & start, const RVector3 & dir, double tol=TOLERANCE) const;
85
90 RVector3 intersect(const Line & line, double tol=TOLERANCE) const;
91
94 double nearest(const RVector3 & p) const;
95
97 inline RVector3 at(double t) const { return _p0 + (_p1 - _p0) * t; }
98
102 double distance(const RVector3 & pos) const;
103
108 double t(const RVector3 & pos, double tol=TOLERANCE) const ;
109
117 bool touch1(const RVector3 & pos, int & pFunIdx, double tol=TOLERANCE) const ;
118
120 bool touch(const RVector3 & pos, double tol=TOLERANCE) const ;
121
123 double length() const { return _p0.dist(_p1); }
124
125protected:
126
128 void copy_(const Line & line);
129
130 RVector3 _p0;
131 RVector3 _p1;
132 bool valid_;
133};
134
135std::ostream & operator << (std::ostream & str, const Line & l);
136
137} // namespace GIMLI;
138
139#endif // GIMLI_LINE__H
A line.
Definition line.h:30
bool compare(const Line &line, double tol=TOLERANCE) const
Definition line.cpp:73
double t(const RVector3 &pos, double tol=TOLERANCE) const
Definition line.cpp:227
const RVector3 & p1() const
Definition line.h:73
bool valid() const
Definition line.h:63
Line()
Definition line.cpp:32
const RVector3 operator()(double t) const
Definition line.h:51
const RVector3 & p0() const
Definition line.h:70
double length() const
Definition line.h:123
RVector3 at(double t) const
Definition line.h:97
GIMLi main namespace for the Geophyiscal Inversion and Modelling Library.
Definition baseentity.h:24