Functions
test_point.cxx File Reference
#include "WireCellUtil/Point.h"
#include "WireCellUtil/BoundingBox.h"
#include "WireCellUtil/Testing.h"
#include "WireCellUtil/Units.h"
#include <iomanip>
#include <iostream>

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

int main ( void  )

temporarily make this a really big loop to test no memory leakage

Definition at line 11 of file test_point.cxx.

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-1e-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 }
std::pair< Point, Point > Ray
A line segment running from a first (tail) to a second (head) point.
Definition: Point.h:21
static const double ps
Definition: Units.h:103
char foo(size_t ind)
Q_EXPORT QTSManip setprecision(int p)
Definition: qtextstream.h:343
#define Assert
Definition: Testing.h:7
const double e
std::tuple< double, double, const reco::ClusterHit3D * > Point
Definitions used by the VoronoiDiagram algorithm.
Definition: DCEL.h:34
std::set< Point, ComparePoints > PointSet
Definition: Point.h:46
static const double mm
Definition: Units.h:73
bool inside(const Point &point) const
Return true if point is inside bounding box.
Definition: BoundingBox.cxx:29
p
Definition: test.py:223
std::vector< float > Vector
Ray ray_pitch(const Ray &ray1, const Ray &ray2)
Definition: Point.cxx:76
#define AssertMsg
Definition: Testing.h:8
D3Vector< float > PointF
Definition: Point.h:50
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:227
QTextStream & endl(QTextStream &s)