Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
srcs
larcorealg
larcorealg
GeoAlgo
larcorealg/larcorealg/GeoAlgo/GeoCylinder.cxx
Go to the documentation of this file.
1
#include "
larcorealg/GeoAlgo/GeoAlgoException.h
"
2
#include "
larcorealg/GeoAlgo/GeoCylinder.h
"
3
4
namespace
geoalgo {
5
6
Cylinder::Cylinder
()
7
:
Line
()
8
, _radius (0.)
9
{}
10
11
Cylinder::Cylinder
(
const
double
x_min,
const
double
y_min,
const
double
z_min,
12
const
double
x_max,
const
double
y_max,
const
double
z_max,
13
const
double
radius)
14
:
Line
(x_min, y_min, z_min, x_max, y_max, z_max)
15
, _radius ( radius )
16
{}
17
18
Cylinder::Cylinder
(
const
Point_t
& min,
const
Vector_t
& max,
const
double
radius)
19
:
Line
(min, max)
20
, _radius ( radius )
21
{
22
if
(min.size()!=3 || max.size()!=3)
23
throw
GeoAlgoException
(
"Cylinder ctor accepts only 3D Point!"
);
24
}
25
26
bool
Cylinder::Contain
(
const
Point_t
&pt)
const
{
27
28
// get a vector that defines the axis of the cylinder
29
Vector_t
axis =
_pt1
-
_pt2
;
30
Vector_t
dirpt = pt-
_pt2
;
31
32
// angle of point w.r.t. the axis
33
double
angleMin = axis.
Angle
(dirpt);
34
35
// if the angle is > 90 -> outside -> return
36
if
(angleMin > 0.5*3.14)
37
return
false
;
38
39
// revert the axis direction
40
axis = _pt2-
_pt1
;
41
dirpt = pt-
_pt1
;
42
angleMin = axis.
Angle
(dirpt);
43
44
// if the angle is > 90 -> outside -> return
45
if
(angleMin > 0.5*3.14)
46
return
false
;
47
48
// if still here, all that is left to verify is
49
// that the point isn't more than a radius
50
// away from the cylinder axis
51
// 1) make a line corresponding to the axis
52
// 2) get the distance between the point and the line
53
double
radial_dist_sq =
_geoAlgo
.
SqDist
(*
this
,pt);
54
55
if
(radial_dist_sq >
_radius
*
_radius
)
56
return
false
;
57
58
return
true
;
59
60
}
61
}
geoalgo::Cylinder::_geoAlgo
GeoAlgo _geoAlgo
Definition:
larcorealg/larcorealg/GeoAlgo/GeoCylinder.h:62
geoalgo::GeoAlgo::SqDist
double SqDist(const Line_t &line, const Point_t &pt) const
Definition:
larcorealg/larcorealg/GeoAlgo/GeoAlgo.h:87
GeoCylinder.h
geoalgo::Line::_pt1
Point_t _pt1
First point denoting infinite line.
Definition:
larcorealg/larcorealg/GeoAlgo/GeoLine.h:61
geoalgo::Cylinder::_radius
double _radius
Radius of the cylinder.
Definition:
larcorealg/larcorealg/GeoAlgo/GeoCylinder.h:59
geoalgo::Cylinder::Cylinder
Cylinder()
Default constructor.
Definition:
larcorealg/larcorealg/GeoAlgo/GeoCylinder.cxx:6
geoalgo::Line
Representation of a 3D infinite line. Defines an infinite 3D line by having 2 points which completely...
Definition:
larcorealg/larcorealg/GeoAlgo/GeoLine.h:27
GeoAlgoException.h
geoalgo::Cylinder::Contain
bool Contain(const Point_t &pt) const
Containment evaluation.
Definition:
larcorealg/larcorealg/GeoAlgo/GeoCylinder.cxx:26
geoalgo::Line::_pt2
Vector_t _pt2
Second point denoting infinite line.
Definition:
larcorealg/larcorealg/GeoAlgo/GeoLine.h:62
geoalgo::Vector
Definition:
larcorealg/larcorealg/GeoAlgo/GeoVector.h:33
geoalgo::GeoAlgoException
Definition:
larcorealg/larcorealg/GeoAlgo/GeoAlgoException.h:27
geoalgo::Vector::Angle
double Angle(const Vector &obj) const
Compute a cross product of two vectors.
Definition:
larcorealg/larcorealg/GeoAlgo/GeoVector.cxx:76
Generated by
1.8.5