Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
wire-cell-build
util
test
test_point.cxx
Go to the documentation of this file.
1
#include "
WireCellUtil/Point.h
"
2
#include "
WireCellUtil/BoundingBox.h
"
3
#include "
WireCellUtil/Testing.h
"
4
#include "
WireCellUtil/Units.h
"
5
6
#include <iomanip>
7
#include <iostream>
8
using namespace
std
;
9
using namespace
WireCell
;
10
11
int
main
()
12
{
13
{
14
Point
pp1(1, -500, -495);
15
Point
pp2(1, 500, -495);
16
PointSet
results;
17
results.insert(pp1);
18
results.insert(pp2);
19
AssertMsg
(2==results.size(),
"failed to insert"
);
20
}
21
22
23
{
24
Point
origin
(0,0,0);
25
Vector
zdir(0,0,1);
26
Point
pt(0*
units::mm
, 3.92772*
units::mm
, 5.34001*
units::mm
);
27
double
dot
= zdir.dot(pt-origin);
28
cerr <<
"origin="
<< origin/
units::mm
<<
", zdir="
<< zdir <<
", pt="
<< pt/
units::mm
<<
" dot="
<< dot/
units::mm
<<
endl
;
29
}
30
31
Point
p1
(1,2,3);
32
Assert
(p1.x() == 1 && p1.y() == 2 && p1.z() == 3);
33
34
Point
p2
=
p1
;
35
36
Assert
(p1 == p2);
37
38
Point
p3(p1);
39
Assert
(p1 == p3);
40
41
PointF
pf(p1);
42
Assert
(
Point
(pf) == p1);
43
Assert
(pf ==
PointF
(p1));
44
45
Point
ps
= p1 +
p2
;
46
Assert
(ps.x() == 2);
47
48
Assert
(p1.norm().magnitude() == 1.0);
49
50
double
eps = (1-1
e
-11);
51
Point
peps = p1*eps;
52
cerr <<
"Epsilon="
<<
std::setprecision
(12) << eps
53
<<
" peps="
<< peps <<
endl
;
54
PointSet
pset;
55
pset.insert(p1);
56
pset.insert(p2);
57
pset.insert(p3);
58
pset.insert(ps);
59
pset.insert(peps);
60
for
(
auto
pit = pset.begin(); pit != pset.end(); ++pit) {
61
cerr << *pit <<
endl
;
62
}
63
AssertMsg
(pset.size() == 2,
"tolerance set broken"
);
64
65
Point
pdiff =
p1
;
66
pdiff.set(3,2,1);
67
AssertMsg
(p1 != pdiff,
"Copy on write failed."
);
68
69
Point
foo
;
70
/// temporarily make this a really big loop to test no memory leakage
71
for
(
int
ind =0; ind<1000; ++ind) {
72
foo =
p1
;
73
foo =
p2
;
74
foo = p3;
75
}
76
77
const
Ray
r1(
Point
(3.75, -323.316, -500),
Point
(3.75, 254.034, 500));
78
const
Ray
r2(
Point
(2.5, -254.034, 500),
Point
(2.5, 323.316, -500));
79
const
Ray
c12 =
ray_pitch
(r1, r2);
80
cerr <<
"r1="
<< r1 <<
"\n"
81
<<
"r2="
<< r2 <<
"\n"
82
<<
"rp="
<< c12 <<
"\n"
;
83
84
BoundingBox
bb(pset.begin(), pset.end());
85
bb.
inside
(
Point
());
86
87
{
88
Point
p
(1,2,3);
89
Assert
(p);
90
cerr <<
" valid: "
<< p <<
endl
;
91
p.invalidate();
92
Assert
(!p);
93
//cerr << "invalid: " << p << endl;
94
p.set();
95
Assert
(p);
96
cerr <<
"revalid: "
<< p <<
endl
;
97
}
98
99
}
WireCell::BoundingBox
Definition:
BoundingBox.h:11
WireCell::Ray
std::pair< Point, Point > Ray
A line segment running from a first (tail) to a second (head) point.
Definition:
Point.h:21
test_gen_rays_pdsp.p2
list p2
Definition:
test_gen_rays_pdsp.py:22
genie::units::ps
static const double ps
Definition:
Units.h:103
foo
char foo(size_t ind)
Definition:
test_indexedgraph.cxx:8
Point.h
std
STL namespace.
test_nxdot.dot
dot
Definition:
test_nxdot.py:12
setprecision
Q_EXPORT QTSManip setprecision(int p)
Definition:
qtextstream.h:343
WireCell::D3Vector
Definition:
D3Vector.h:23
main
int main()
Definition:
test_point.cxx:11
Assert
#define Assert
Definition:
Testing.h:7
test_gen_rays_pdsp.p1
list p1
Definition:
test_gen_rays_pdsp.py:21
e
const double e
Definition:
gUpMuFluxGen.cxx:165
dcel2d::Point
std::tuple< double, double, const reco::ClusterHit3D * > Point
Definitions used by the VoronoiDiagram algorithm.
Definition:
DCEL.h:34
WireCell::PointSet
std::set< Point, ComparePoints > PointSet
Definition:
Point.h:46
Testing.h
genie::units::mm
static const double mm
Definition:
Units.h:73
WireCell::BoundingBox::inside
bool inside(const Point &point) const
Return true if point is inside bounding box.
Definition:
BoundingBox.cxx:29
WireCell
Definition:
Main.h:22
test.p
p
Definition:
test.py:223
Vector
std::vector< float > Vector
Definition:
test_AdcSampleScaler.cxx:27
WireCell::ray_pitch
Ray ray_pitch(const Ray &ray1, const Ray &ray2)
Definition:
Point.cxx:76
AssertMsg
#define AssertMsg
Definition:
Testing.h:8
BoundingBox.h
WireCell::PointF
D3Vector< float > PointF
Definition:
Point.h:50
geo::origin
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition:
geo_vectors.h:227
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
Units.h
Generated by
1.8.11