Belle II Software
release-05-01-25
Area2D.cc
1
//-----------------------------------------------------------------------------
2
// $Id$
3
//-----------------------------------------------------------------------------
4
// Filename : TRGArea2D.h
5
// Section : TRG
6
// Owner : Yoshihito Iwasaki
7
// Email : yoshihito.iwasaki@kek.jp
8
//-----------------------------------------------------------------------------
9
// Description : A class to represent a 2D area.
10
//-----------------------------------------------------------------------------
11
// $Log$
12
//-----------------------------------------------------------------------------
13
14
#include "trg/trg/Area2D.h"
15
16
namespace
Belle2
{
22
TRGArea2D::TRGArea2D
(
const
TRGPoint2D
& leftBottom,
23
const
TRGPoint2D
& rightUpper)
24
{
25
_c
[0] = leftBottom;
26
_c
[1] = rightUpper;
27
}
28
29
TRGArea2D::~TRGArea2D
()
30
{
31
}
32
33
void
34
TRGArea2D::cross
(
const
TRGPoint2D
& x0,
35
const
TRGPoint2D
& x1,
36
unsigned
& nFound,
37
TRGPoint2D
crossPoint[2])
const
38
{
39
40
//...Parameters...
41
const
float
xDiff = x1.
x
() - x0.
x
();
42
const
float
yDiff = x1.
y
() - x0.
y
();
43
const
float
a = yDiff / xDiff;
44
const
float
b = x0.
x
() - a * x0.
x
();
45
46
//...Find cross-points...
47
nFound = 0;
48
for
(
unsigned
i = 0; i < 2; i++) {
49
50
TRGPoint2D
p(
_c
[i].x(), a *
_c
[i].x() + b);
51
if
(
inArea
(p))
52
crossPoint[nFound++] = p;
53
if
(nFound == 2)
return
;
54
55
TRGPoint2D
q((
_c
[i].y() - b) / a,
_c
[i].y());
56
if
(
inArea
(q))
57
crossPoint[nFound++] = q;
58
if
(nFound == 2)
return
;
59
}
60
}
61
63
}
// namespace Belle2
64
Belle2::TRGPoint2D
A class to represent a point in 2D.
Definition:
Point2D.h:32
Belle2::TRGPoint2D::y
double y(void) const
y of the point
Definition:
Point2D.h:103
Belle2::TRGPoint2D::x
double x(void) const
x of the point
Definition:
Point2D.h:96
Belle2
Abstract base class for different kinds of events.
Definition:
MillepedeAlgorithm.h:19
Belle2::TRGArea2D::_c
TRGPoint2D _c[2]
2D points
Definition:
Area2D.h:48
Belle2::TRGArea2D::~TRGArea2D
virtual ~TRGArea2D()
Destructor.
Definition:
Area2D.cc:29
Belle2::TRGArea2D::inArea
bool inArea(const TRGPoint2D &x) const
returns true if give point is in the area.
Definition:
Area2D.h:55
Belle2::TRGArea2D::cross
void cross(const TRGPoint2D &x0, const TRGPoint2D &x1, unsigned &nFound, TRGPoint2D crossPoint[2]) const
returns cross-points.
Definition:
Area2D.cc:34
Belle2::TRGArea2D::TRGArea2D
TRGArea2D(const TRGPoint2D &leftBottom, const TRGPoint2D &rightUpper)
Contructor.
Definition:
Area2D.cc:22
trg
trg
src
Area2D.cc
Generated on Fri Nov 5 2021 04:06:07 for Belle II Software by
1.8.17