LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
GeoAlgo.h
Go to the documentation of this file.
1 
14 #ifndef BASICTOOL_GEOALGO_H
15 #define BASICTOOL_GEOALGO_H
16 
17 #include <algorithm> // used for std::find
18 #include "GeoLine.h"
19 #include "GeoHalfLine.h"
20 #include "GeoLineSegment.h"
21 #include "GeoTrajectory.h"
22 #include "GeoCone.h"
23 #include "GeoAABox.h"
24 #include "GeoSphere.h"
25 
26 namespace geoalgo {
27 
42  class GeoAlgo{
43 
44  public:
45 
47  GeoAlgo(){}
48 
50  virtual ~GeoAlgo(){}
51 
52  //
53  // Intersections
54  //
55 
57  std::vector<Point_t> Intersection(const AABox_t& box, const HalfLine_t& line, bool back=false) const;
59  std::vector<Point_t> Intersection(const HalfLine_t& line, const AABox_t& box, bool back=false) const
60  { return Intersection(box, line, back); }
61 
63  std::vector<Point_t> Intersection(const AABox_t& box, const LineSegment_t& l) const;
65  std::vector<Point_t> Intersection(const LineSegment_t& l, const AABox_t& box) const
66  { return Intersection(box,l); }
67 
69  std::vector<Point_t> Intersection(const AABox_t& box, const Trajectory_t& trj) const;
71  std::vector<Point_t> Intersection(const Trajectory_t& trj, const AABox_t& box) const
72  { return Intersection(box,trj); }
73 
75  LineSegment_t BoxOverlap(const AABox_t& box, const HalfLine_t& line) const;
77  LineSegment_t BoxOverlap(const HalfLine_t& line, const AABox_t& box) const
78  { return BoxOverlap(box, line); }
79 
80 
82  Trajectory_t BoxOverlap(const AABox_t& box, const Trajectory_t& trj) const;
84  Trajectory_t BoxOverlap(const Trajectory_t& trj, const AABox_t& box) const
85  { return BoxOverlap(box, trj); }
86 
87 
88  //************************************************
89  //CLOSEST APPROACH BETWEEN POINT AND INFINITE LINE
90  //************************************************
91  // min distance between point and infinite line
92  double SqDist(const Line_t& line, const Point_t& pt) const
93  { pt.compat(line.Pt1()); return _SqDist_(line,pt); }
94  // min distance between point and infinite line
95  double SqDist(const Point_t& pt, const Line_t& line) const
96  { return SqDist(line,pt); }
97  // closest point (on infinite line) from point
98  Point_t ClosestPt(const Line_t& line, const Point_t& pt) const
99  { pt.compat(line.Pt1()); return _ClosestPt_(pt,line); }
100  // closest point (on infinite line) from point
101  Point_t ClosestPt(const Point_t& pt, const Line_t& line) const
102  { return _ClosestPt_(pt,line); }
103 
104 
105  //*******************************************
106  //CLOSEST APPROACH BETWEEN TWO INFINITE LINES
107  //*******************************************
108  // Closest approach between two infinite line segments - keep track of closest approach points
109  double SqDist(const Line_t& l1, const Line_t& l2, Point_t& L1, Point_t& L2) const
110  { l1.Pt1().compat(l2.Pt1()); return _SqDist_(l1, l2, L1, L2); }
111  // Closest approach between two infinite line segments - don't keep track of closest approach points
112  double SqDist(const Line_t& l1, const Line_t& l2) const
113  { Point_t L1; Point_t L2; return SqDist(l1, l2, L1, L2); }
114 
115 
116  //************************************************
117  //CLOSEST APPROACH BETWEEN TWO HALF-INFINITE LINES
118  //************************************************
119  // Closest approach between two infinite line segments - keep track of closest approach points
120  double SqDist(const HalfLine_t& l1, const HalfLine_t& l2, Point_t& L1, Point_t& L2) const
121  { l1.Start().compat(l2.Start()); return _SqDist_(l1, l2, L1, L2); }
122  // Closest approach between two infinite line segments - don't keep track of closest approach points
123  double SqDist(const HalfLine_t& l1, const HalfLine_t& l2) const
124  { Point_t L1; Point_t L2; return SqDist(l1, l2, L1, L2); }
125 
126 
127  //******************************************
128  //CLOSEST APPROACH BETWEEN TWO LINE SEGMENTS
129  //******************************************
131  double SqDist(const LineSegment_t& seg1, const LineSegment_t& seg2, Point_t& c1, Point_t& c2) const
132  { seg1.Start().compat(seg2.Start()); return _SqDist_(seg1, seg2, c1, c2); }
134  double SqDist(const LineSegment_t& seg1, const LineSegment_t& seg2) const
135  { Point_t c1; Point_t c2; return SqDist(seg1, seg2, c1, c2); }
136 
137 
138  //******************************************
139  //CLOSEST APPROACH BETWEEN SEGMENT AND TRACK
140  //******************************************
142  double SqDist(const LineSegment_t& seg, const Trajectory_t& trj, Point_t& c1, Point_t& c2) const;
144  double SqDist(const Trajectory_t& trj, const LineSegment_t& seg, Point_t& c1, Point_t& c2) const
145  { return SqDist(seg, trj, c1, c2); }
147  double SqDist(const Trajectory_t& trj, const LineSegment_t& seg) const
148  { Point_t c1; Point_t c2; return SqDist(seg, trj, c1, c2); }
150  double SqDist(const LineSegment_t& seg, const Trajectory_t& trj) const
151  { Point_t c1; Point_t c2; return SqDist(seg, trj, c1, c2); }
152 
153 
154  //****************************************
155  //CLOSEST APPROACH BETWEEN TRACK AND TRACK
156  //****************************************
158  double SqDist(const Trajectory_t& trj1, const Trajectory_t& trj2, Point_t& c1, Point_t& c2) const;
160  double SqDist(const Trajectory_t& trj1, const Trajectory_t& trj2) const
161  { Point_t c1; Point_t c2; return SqDist(trj1, trj2, c1, c2); }
162 
163 
164  //*****************************************************
165  //CLOSEST APPROACH BETWEEN SEGMENT AND VECTOR OF TRACKS
166  //*****************************************************
168  double SqDist(const LineSegment_t& seg, const std::vector<geoalgo::Trajectory_t> &trj, Point_t& c1, Point_t& c2, int& trackIdx) const;
170  double SqDist(const std::vector<geoalgo::Trajectory_t> &trj, const LineSegment_t& seg, Point_t& c1, Point_t& c2, int& trackIdx) const
171  { return SqDist(seg, trj, c2, c1, trackIdx); }
173  double SqDist(const std::vector<geoalgo::Trajectory_t> &trj, const LineSegment_t& seg) const
174  { Point_t c1; Point_t c2; int trackIdx; return SqDist(seg, trj, c1, c2, trackIdx); }
176  double SqDist(const LineSegment_t& seg, const std::vector<geoalgo::Trajectory_t> &trj) const
177  { Point_t c1; Point_t c2; int trackIdx; return SqDist(seg, trj, c1, c2, trackIdx); }
178 
179 
180  //*******************************************
181  //CLOSEST APPROACH BETWEEN HALFLINE AND TRACK
182  //*******************************************
184  double SqDist(const HalfLine_t& hline, const Trajectory_t& trj, Point_t& c1, Point_t& c2) const;
186  double SqDist(const Trajectory_t& trj, const HalfLine_t& hline, Point_t& c1, Point_t& c2) const
187  { return SqDist(hline, trj, c2, c1); }
189  double SqDist(const Trajectory_t& trj, const HalfLine_t& hline) const
190  { Point_t c1; Point_t c2; return SqDist(hline, trj, c1, c2); }
192  double SqDist(const HalfLine_t& hline, const Trajectory_t& trj) const
193  { Point_t c1; Point_t c2; return SqDist(hline, trj, c1, c2); }
194 
195 
196  //****************************************
197  //CLOSEST APPROACH BETWEEN POINT AND TRACK
198  //****************************************
200  double SqDist(const Point_t& pt, const Trajectory_t& trj) const;
202  double SqDist(const Trajectory_t& trj, const Point_t& pt) const
203  { return SqDist(pt,trj); }
205  Point_t ClosestPt(const Point_t& pt, const Trajectory_t& trj) const
206  { int idx=0; return ClosestPt(pt,trj,idx); }
208  Point_t ClosestPt(const Trajectory_t& trj, const Point_t& pt) const
209  { int idx=0; return ClosestPt(pt,trj,idx); }
211  Point_t ClosestPt(const Point_t& pt, const Trajectory_t& trj, int& idx) const;
213  Point_t ClosestPt(const Trajectory_t& trj, const Point_t& pt, int& idx) const
214  { return ClosestPt(pt,trj,idx); }
215 
216 
217  //***************************************************
218  //CLOSEST APPROACH BETWEEN POINT AND VECTOR OF TRACKS
219  //***************************************************
221  double SqDist(const Point_t& pt, const std::vector<geoalgo::Trajectory_t> &trj, int& trackIdx) const;
223  double SqDist(const std::vector<geoalgo::Trajectory_t> &trj, const Point_t& pt, int& trackIdx) const
224  { return SqDist(pt,trj, trackIdx); }
226  double SqDist(const Point_t& pt, const std::vector<geoalgo::Trajectory_t> &trj) const
227  { int trackIdx; return SqDist(pt, trj, trackIdx); }
229  double SqDist(const std::vector<geoalgo::Trajectory_t> &trj, const Point_t& pt) const
230  { int trackIdx; return SqDist(pt, trj, trackIdx); }
232  Point_t ClosestPt(const Point_t& pt, const std::vector<geoalgo::Trajectory_t> &trj, int &trackIdx) const;
234  Point_t ClosestPt(const std::vector<geoalgo::Trajectory_t> &trj, const Point_t& pt, int &trackIdx) const
235  { return ClosestPt(pt, trj, trackIdx); }
237  Point_t ClosestPt(const Point_t& pt, const std::vector<geoalgo::Trajectory_t> &trj) const
238  { int trackIdx; return ClosestPt(pt, trj, trackIdx); }
240  Point_t ClosestPt(const std::vector<geoalgo::Trajectory_t> &trj, const Point_t& pt) const
241  { int trackIdx; return ClosestPt(pt, trj, trackIdx); }
242 
243 
244  //***********************************************
245  //CLOSEST APPROACH BETWEEN POINT AND LINE SEGMENT
246  //***********************************************
248  double SqDist(const Point_t& pt, const LineSegment_t& line) const
249  { pt.compat(line.Start()); return _SqDist_(pt,line); }
251  double SqDist(const LineSegment_t& line, const Point_t& pt) const
252  { return SqDist(pt,line); }
254  Point_t ClosestPt(const Point_t& pt, const LineSegment_t& line) const
255  { pt.compat(line.Start()); return _ClosestPt_(pt,line); }
257  Point_t ClosestPt(const LineSegment_t& line, const Point_t& pt) const
258  { return ClosestPt(pt,line); }
259 
260  //********************************************
261  //CLOSEST APPROACH BETWEEN POINT AND HALF LINE
262  //********************************************
264  double SqDist(const Point_t& pt, const HalfLine_t& line) const
265  { pt.compat(line.Start()); return _SqDist_(pt,line); }
267  double SqDist(const HalfLine_t& line, const Point_t& pt) const
268  { return SqDist(pt,line); }
270  Point_t ClosestPt(const Point_t& pt, const HalfLine_t& line) const
271  { pt.compat(line.Start()); return _ClosestPt_(pt,line); }
273  Point_t ClosestPt(const HalfLine_t& line, const Point_t& pt) const
274  { return ClosestPt(pt,line); }
275 
276 
277  //***************************************************
278  //CLOSEST APPROACH BETWEEN HALF LINE AND LINE SEGMENT
279  //***************************************************
280  // half-line and line-segment. keep track of closest approach points
281  double SqDist(const HalfLine_t& hline, const LineSegment_t& seg, Point_t& L1, Point_t& L2) const
282  { hline.Start().compat(seg.Start()); return _SqDist_(hline, seg, L1, L2); }
283  // half-line and line-segment. keep track of closest approach points
284  double SqDist(const LineSegment_t& seg, const HalfLine_t& hline, Point_t& L1, Point_t& L2) const
285  { return SqDist(hline,seg, L2, L1); }
286  // half-line and line-segment. Do not keep track of closest approach points
287  double SqDist(const HalfLine_t& hline, const LineSegment_t& seg) const
288  { Point_t L1; Point_t L2; return SqDist(hline, seg, L1, L2); }
289  // half-line and line-segment. Do not keep track of closest approach points
290  double SqDist(const LineSegment_t& seg, const HalfLine_t& hline) const
291  { return SqDist(hline,seg); }
292 
293  //***************************************************
294  //CLOSEST APPROACH BETWEEN POINT AND AXIS ALIGNED BOX
295  //***************************************************
297  double SqDist(const Point_t& pt, const AABox_t& box) const
298  { pt.compat(box.Min()); return _SqDist_(pt,box); }
300  double SqDist(const AABox_t& box, const Point_t& pt)
301  { return SqDist(pt,box); }
303  Point_t ClosestPt(const Point_t& pt, const AABox_t& box) const
304  { pt.compat(box.Min()); return _ClosestPt_(pt,box); }
306  Point_t ClosestPt(const AABox_t& box, const Point_t& pt) const
307  { return ClosestPt(pt,box); }
308 
309 
310  //***************************************************************************
311  //COMMON ORIGIN ALGORITHMS: DETERMINE IF TWO GEO-OBJECTS HAVE A COMMON ORIGIN
312  //***************************************************************************
314  double commonOrigin(const Line_t& lin1, const Line_t& lin2) const
315  { Point_t origin(lin1.Pt1().size()); return commonOrigin(lin1,lin2, origin); }
317  double commonOrigin(const Line_t& lin1, const Line_t& lin2, Point_t& origin) const
318  { lin1.Pt1().compat(lin2.Pt1()); return _commonOrigin_(lin1, lin2, origin); }
320  double commonOrigin(const LineSegment_t& seg1, const LineSegment_t& seg2, bool backwards=false) const
321  { Point_t origin(seg1.Start().size()); return commonOrigin(seg1,seg2, origin, backwards); }
323  double commonOrigin(const LineSegment_t& seg1, const LineSegment_t& seg2, Point_t& origin, bool backwards=false) const
324  { seg1.Start().compat(seg2.Start()); return _commonOrigin_(seg1, seg2, origin, backwards); }
326  double commonOrigin(const HalfLine_t& lin, const LineSegment_t& seg, bool backwards=false) const
327  { Point_t origin(lin.Start().size()); return commonOrigin(lin, seg, origin, backwards); }
329  double commonOrigin(const HalfLine_t& lin, const LineSegment_t& seg, Point_t& origin, bool backwards=false) const
330  { lin.Start().compat(seg.Start()); return _commonOrigin_(lin, seg, origin, backwards); }
332  double commonOrigin(const LineSegment_t& seg, const HalfLine_t& lin, bool backwards=false) const
333  { Point_t origin(lin.Start().size()); return commonOrigin(lin, seg, origin, backwards); }
335  double commonOrigin(const LineSegment_t& seg, const HalfLine_t& lin, Point_t& origin, bool backwards=false) const
336  { lin.Start().compat(seg.Start()); return _commonOrigin_(lin, seg, origin, backwards); }
338  double commonOrigin(const HalfLine_t& lin1, const HalfLine_t& lin2, bool backwards=false) const
339  { Point_t origin(lin1.Start().size()); return commonOrigin(lin1,lin2, origin, backwards); }
341  double commonOrigin(const HalfLine_t& lin1, const HalfLine_t& lin2, Point_t& origin, bool backwards=false) const
342  { lin1.Start().compat(lin2.Start()); return _commonOrigin_(lin1, lin2, origin, backwards); }
344  double commonOrigin(const Trajectory_t& trj1, const Trajectory_t& trj2, bool backwards=false) const
345  { Point_t origin(trj1.front().size()); return commonOrigin(trj1,trj2, origin, backwards); }
347  double commonOrigin(const Trajectory_t& trj1, const Trajectory_t& trj2, Point_t& origin, bool backwards=false) const
348  { trj1.front().compat(trj2.front()); return _commonOrigin_(trj1, trj2, origin, backwards); }
350  double commonOrigin(const Trajectory_t& trj, const HalfLine_t& lin, bool backwards=false) const
351  { Point_t origin(trj.front().size()); return commonOrigin(trj,lin, origin, backwards); }
353  double commonOrigin(const Trajectory_t& trj, const HalfLine_t& lin, Point_t& origin, bool backwards=false) const
354  { trj.front().compat(lin.Start()); return _commonOrigin_(trj, lin, origin, backwards); }
356  double commonOrigin(const HalfLine_t& lin, const Trajectory_t& trj, bool backwards=false) const
357  { Point_t origin(trj.front().size()); return commonOrigin(trj,lin, origin, backwards); }
359  double commonOrigin(const HalfLine_t& lin, const Trajectory_t& trj, Point_t& origin, bool backwards=false) const
360  { trj.front().compat(lin.Start()); return _commonOrigin_(trj, lin, origin, backwards); }
362  double commonOrigin(const Trajectory_t& trj, const LineSegment_t& seg, bool backwards=false) const
363  { Point_t origin(trj.front().size()); return commonOrigin(trj, seg, origin, backwards); }
365  double commonOrigin(const Trajectory_t& trj, const LineSegment_t& seg, Point_t& origin, bool backwards=false) const
366  { trj.front().compat(seg.Start()); return _commonOrigin_(trj, seg, origin, backwards); }
368  double commonOrigin(const LineSegment_t& seg, const Trajectory_t& trj, bool backwards=false) const
369  { Point_t origin(trj.front().size()); return commonOrigin(trj, seg, origin, backwards); }
371  double commonOrigin(const LineSegment_t& seg, const Trajectory_t& trj, Point_t& origin, bool backwards=false) const
372  { trj.front().compat(seg.Start()); return _commonOrigin_(trj, seg, origin, backwards); }
373 
374  //************************************************************************
375  //BOUNDING SPHERE ALGORITHM: RETURN SMALLEST SPHERE THAT BOUNDS ALL POINTS
376  //************************************************************************
377  // Bounding Sphere problem given a vector of 3D points
378  Sphere_t boundingSphere(const std::vector<Point_t>& pts) const
379  { for(auto &p : pts) { pts.front().compat(p); } return _boundingSphere_(pts); }
380 
381  protected:
382 
384  double _SqDist_(const Line_t& l1, const Line_t& l2, Point_t& L1, Point_t& L2) const;
385 
387  double _SqDist_(const HalfLine_t& l1, const HalfLine_t& l2, Point_t& L1, Point_t& L2) const;
388 
390  double _SqDist_(const Point_t& pt, const LineSegment_t& line) const
391  { return _SqDist_(pt,line.Start(),line.End()); }
392 
394  double _SqDist_(const Point_t& pt, const Point_t& line_s, const Point_t& line_e) const;
395 
397  double _SqDist_(const LineSegment_t& line, const Point_t&pt) const
398  { return _SqDist_(pt,line); }
399 
401  double _SqDist_(const HalfLine_t& hline, const LineSegment_t& seg, Point_t& L1, Point_t& L2) const;
402 
404  double _SqDist_(const LineSegment_t& seg1, const LineSegment_t& seg2, Point_t& c1, Point_t& c2) const;
405 
406  // Point & LineSegment closest point w/o dimensionality check
407  Point_t _ClosestPt_(const Point_t& pt, const LineSegment_t& line) const;
408  // Point & LineSegment closest point w/o dimensionality check
409  Point_t _ClosestPt_(const LineSegment_t& line, const Point_t& pt) const
410  { return _ClosestPt_(pt,line); }
411 
413  double _SqDist_(const Point_t& pt, const HalfLine_t& line) const;
415  double _SqDist_(const HalfLine_t& line, const Point_t& pt) const
416  { return _SqDist_(pt,line); }
417  // Point & HalfLine closest point w/o dimensionality check
418  Point_t _ClosestPt_(const Point_t& pt, const HalfLine_t& line) const;
419  // Point & HalfLine closest point w/o dimensionality check
420  Point_t _ClosestPt_(const HalfLine_t& line, const Point_t& pt) const
421  { return _ClosestPt_(pt,line); }
422 
423  // Point & InfLine closest point w/o dimensionality check
424  Point_t _ClosestPt_(const Line_t& line, const Point_t& pt) const;
425  // Point & InfLine closest point w/o dimensionality check
426  Point_t _ClosestPt_(const Point_t& pt, const Line_t& line) const
427  { return _ClosestPt_(line,pt); }
428  // Point & InfLine distance w/o dimensionality check
429  double _SqDist_(const Line_t& line, const Point_t& pt) const;
430  // Point & InfLine distance w/o dimensionality check
431  double _SqDist_(const Point_t& pt, const Line_t& line) const
432  { return _SqDist_(line,pt); }
433 
435  double _SqDist_(const Point_t& pt, const AABox_t& box) const;
437  double _SqDist_(const AABox_t& box, const Point_t& pt) const
438  { return _SqDist_(pt,box); }
439 
441  Point_t _ClosestPt_(const Point_t& pt, const AABox_t& box) const;
443  Point_t _ClosestPt_(const AABox_t& box, const Point_t& pt) const
444  { return _ClosestPt_(pt,box); }
445 
447  double _commonOrigin_(const Line_t& lin1, const Line_t& lin2, Point_t& origin) const;
449  double _commonOrigin_(const HalfLine_t& lin1, const HalfLine_t& lin2, Point_t& origin, bool backwards) const;
451  double _commonOrigin_(const HalfLine_t& lin, const LineSegment_t& seg, Point_t& origin, bool backwards) const;
453  double _commonOrigin_(const LineSegment_t& seg1, const LineSegment_t& seg2, Point_t& origin, bool backwards) const;
455  double _commonOrigin_(const Trajectory_t& trj1, const Trajectory_t& trj2, Point_t& origin, bool backwards) const;
457  double _commonOrigin_(const Trajectory_t& trj, const LineSegment_t& seg, Point_t& origin, bool backwards) const;
459  double _commonOrigin_(const Trajectory_t& trj, const HalfLine_t& lin, Point_t& origin, bool backwards) const;
460 
461 
462  // Bounding Sphere given a vector of points
463  Sphere_t _boundingSphere_(const std::vector<Point_t>& pts) const;
464  Sphere_t _RemainingPoints_(std::vector<Point_t>& remaining, const Sphere_t& thisSphere)const;
465  Sphere_t _WelzlSphere_(const std::vector<Point_t>& pts, int numPts, std::vector<Point_t> sosPts) const;
466 
468  double _Clamp_(const double n, const double min, const double max) const;
469 
471  inline void _Swap_(double& tmin, double& tmax) const
472  { if(tmin > tmax) std::swap(tmin,tmax); }
473 
474  };
475 }
476 
477 #endif
478  // end of doxygen group
479 
double commonOrigin(const LineSegment_t &seg, const Trajectory_t &trj, Point_t &origin, bool backwards=false) const
Common origin: Trajectory & Line Segment. Keep track of origin.
Definition: GeoAlgo.h:371
Point_t ClosestPt(const Point_t &pt, const Line_t &line) const
Definition: GeoAlgo.h:101
double commonOrigin(const Trajectory_t &trj, const LineSegment_t &seg, Point_t &origin, bool backwards=false) const
Common origin: Trajectory & Line Segment. Keep track of origin.
Definition: GeoAlgo.h:365
double SqDist(const std::vector< geoalgo::Trajectory_t > &trj, const LineSegment_t &seg, Point_t &c1, Point_t &c2, int &trackIdx) const
LineSegment & vector of Trajectories, keep track of points.
Definition: GeoAlgo.h:170
Point_t ClosestPt(const AABox_t &box, const Point_t &pt) const
Point & AABox closest point.
Definition: GeoAlgo.h:306
double SqDist(const HalfLine_t &line, const Point_t &pt) const
Point & HalfLine distance.
Definition: GeoAlgo.h:267
Point_t ClosestPt(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:98
double _SqDist_(const Line_t &l1, const Line_t &l2, Point_t &L1, Point_t &L2) const
Line & Line distance w/o dimensionality check.
Definition: GeoAlgo.cxx:192
double SqDist(const AABox_t &box, const Point_t &pt)
Point & AABox distance.
Definition: GeoAlgo.h:300
double SqDist(const Point_t &pt, const LineSegment_t &line) const
Point & LineSegment_t distance.
Definition: GeoAlgo.h:248
Algorithm to compute various geometrical relation among geometrical objects. In particular functions ...
Definition: GeoAlgo.h:42
const Point_t & Start() const
Start getter.
Definition: GeoHalfLine.cxx:27
Point_t ClosestPt(const Point_t &pt, const std::vector< geoalgo::Trajectory_t > &trj) const
Point_t & Trajectory_t closest point - don&#39;t keep track of which track is closest.
Definition: GeoAlgo.h:237
Point_t ClosestPt(const std::vector< geoalgo::Trajectory_t > &trj, const Point_t &pt) const
Point_t & Trajectory_t closest point - don&#39;t keep track of which track is closest.
Definition: GeoAlgo.h:240
double SqDist(const LineSegment_t &line, const Point_t &pt) const
Point & LineSegment distance.
Definition: GeoAlgo.h:251
double SqDist(const LineSegment_t &seg, const HalfLine_t &hline, Point_t &L1, Point_t &L2) const
Definition: GeoAlgo.h:284
double SqDist(const LineSegment_t &seg1, const LineSegment_t &seg2) const
LineSegment & LineSegment, don&#39;t keep track of points.
Definition: GeoAlgo.h:134
double _Clamp_(const double n, const double min, const double max) const
Clamp function: checks if value out of bounds.
Definition: GeoAlgo.cxx:844
Point_t ClosestPt(const Point_t &pt, const LineSegment_t &line) const
Point & LineSegment closest point.
Definition: GeoAlgo.h:254
double commonOrigin(const HalfLine_t &lin, const Trajectory_t &trj, bool backwards=false) const
Common origin: Trajectory & Half Line. Do not keep track of origin.
Definition: GeoAlgo.h:356
double SqDist(const LineSegment_t &seg, const std::vector< geoalgo::Trajectory_t > &trj) const
LineSegment & vector of Trajectories, don&#39;t keep track of points.
Definition: GeoAlgo.h:176
void compat(const Point_t &obj) const
Dimensionality check function w/ Trajectory.
Class def header for a class HalfLine.
void _Swap_(double &tmin, double &tmax) const
Swap two points if min & max are inverted.
Definition: GeoAlgo.h:471
Point_t ClosestPt(const Point_t &pt, const HalfLine_t &line) const
Point & HalfLine closest point.
Definition: GeoAlgo.h:270
double SqDist(const HalfLine_t &l1, const HalfLine_t &l2, Point_t &L1, Point_t &L2) const
Definition: GeoAlgo.h:120
Point_t _ClosestPt_(const LineSegment_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:409
double SqDist(const Trajectory_t &trj, const HalfLine_t &hline) const
HalfLine & Trajectory, don&#39;t keep track of points.
Definition: GeoAlgo.h:189
double SqDist(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:92
Representation of a simple 3D line segment Defines a finite 3D straight line by having the start and ...
double SqDist(const LineSegment_t &seg1, const LineSegment_t &seg2, Point_t &c1, Point_t &c2) const
LineSegment_t & LineSegment_t distance - keep track of points.
Definition: GeoAlgo.h:131
double SqDist(const Trajectory_t &trj, const LineSegment_t &seg, Point_t &c1, Point_t &c2) const
LineSegment & Trajectory, keep track of points.
Definition: GeoAlgo.h:144
Representation of a 3D rectangular box which sides are aligned w/ coordinate axis. A representation of an Axis-Aligned-Boundary-Box, a simple & popular representation of 3D boundary box for collision detection. The concept was taken from the reference, Real-Time-Collision-Detection (RTCD), and in particular Ch. 4.2 (page 77): .
Definition: GeoAABox.h:34
double commonOrigin(const HalfLine_t &lin, const LineSegment_t &seg, Point_t &origin, bool backwards=false) const
Common origin: Line Segment & Line Segment. Keep track of origin.
Definition: GeoAlgo.h:329
double SqDist(const Point_t &pt, const std::vector< geoalgo::Trajectory_t > &trj) const
Point_t & Trajectory_t distance - don&#39;t keep track.
Definition: GeoAlgo.h:226
Class def header for a class Line.
void compat(const Vector &obj) const
Dimensional check for a compatibility.
Definition: GeoVector.cxx:101
double _SqDist_(const HalfLine_t &line, const Point_t &pt) const
Point & HalfLine distance w/o dimensionality check.
Definition: GeoAlgo.h:415
double commonOrigin(const Trajectory_t &trj, const HalfLine_t &lin, bool backwards=false) const
Common origin: Trajectory & Half Line. Do not keep track of origin.
Definition: GeoAlgo.h:350
Class def header for a class HalfLine.
double commonOrigin(const LineSegment_t &seg, const HalfLine_t &lin, bool backwards=false) const
Common origin: Line Segment & Half Line. Do not keep track of origin.
Definition: GeoAlgo.h:332
double SqDist(const Line_t &l1, const Line_t &l2) const
Definition: GeoAlgo.h:112
double SqDist(const HalfLine_t &hline, const Trajectory_t &trj) const
HalfLine & Trajectory, don&#39;t keep track of points.
Definition: GeoAlgo.h:192
const Point_t & Min() const
Minimum point getter.
Definition: GeoAABox.cxx:27
Class def header for a class AABox.
Sphere_t boundingSphere(const std::vector< Point_t > &pts) const
Definition: GeoAlgo.h:378
Point_t _ClosestPt_(const Point_t &pt, const Line_t &line) const
Definition: GeoAlgo.h:426
Point_t ClosestPt(const HalfLine_t &line, const Point_t &pt) const
Point & HalfLine closest point.
Definition: GeoAlgo.h:273
double SqDist(const Point_t &pt, const AABox_t &box) const
Point & AABox distance.
Definition: GeoAlgo.h:297
Point_t ClosestPt(const Trajectory_t &trj, const Point_t &pt) const
Point_t & Trajectory_t closest point.
Definition: GeoAlgo.h:208
Int_t max
Definition: plot.C:27
TCanvas * c1
Definition: plotHisto.C:7
TCanvas * c2
Definition: plot_hist.C:75
double commonOrigin(const Line_t &lin1, const Line_t &lin2, Point_t &origin) const
Common origin: Line Segment & Line Segment. Keep track of origin.
Definition: GeoAlgo.h:317
double SqDist(const std::vector< geoalgo::Trajectory_t > &trj, const Point_t &pt, int &trackIdx) const
Point_t & Trajectory_t distance - keep track of which track.
Definition: GeoAlgo.h:223
double commonOrigin(const HalfLine_t &lin, const Trajectory_t &trj, Point_t &origin, bool backwards=false) const
Common origin: Trajectory & Half Line. Keep track of origin.
Definition: GeoAlgo.h:359
double commonOrigin(const LineSegment_t &seg, const Trajectory_t &trj, bool backwards=false) const
Common origin: Trajectory & Line Segment. Do not keep track of origin.
Definition: GeoAlgo.h:368
double SqDist(const Trajectory_t &trj, const LineSegment_t &seg) const
LineSegment & Trajectory, don&#39;t keep track of points.
Definition: GeoAlgo.h:147
Point_t ClosestPt(const std::vector< geoalgo::Trajectory_t > &trj, const Point_t &pt, int &trackIdx) const
Point_t & Trajectory_t closest point - keep track of which track is closest.
Definition: GeoAlgo.h:234
const Point_t & Pt1() const
Start getter.
Definition: GeoLine.cxx:24
const Point_t & End() const
End getter.
double commonOrigin(const Trajectory_t &trj1, const Trajectory_t &trj2, bool backwards=false) const
Common origin: Trajectory & Trajectory. Do not keep track of origin.
Definition: GeoAlgo.h:344
double SqDist(const Trajectory_t &trj, const Point_t &pt) const
Point_t & Trajectory_t distance.
Definition: GeoAlgo.h:202
Class def header for a class HalfLine.
TMarker * pt
Definition: egs.C:25
double commonOrigin(const Line_t &lin1, const Line_t &lin2) const
Common origin: Line Segment & Line Segment. Do not keep track of origin.
Definition: GeoAlgo.h:314
std::vector< Point_t > Intersection(const HalfLine_t &line, const AABox_t &box, bool back=false) const
Intersection between a HalfLine and an AABox.
Definition: GeoAlgo.h:59
Representation of a 3D infinite line. Defines an infinite 3D line by having 2 points which completely...
Definition: GeoLine.h:27
Point_t ClosestPt(const Point_t &pt, const AABox_t &box) const
Point & AABox closest point.
Definition: GeoAlgo.h:303
Point_t ClosestPt(const Point_t &pt, const Trajectory_t &trj) const
Point_t & Trajectory_t closest point.
Definition: GeoAlgo.h:205
Sphere_t _WelzlSphere_(const std::vector< Point_t > &pts, int numPts, std::vector< Point_t > sosPts) const
Definition: GeoAlgo.cxx:1095
double commonOrigin(const HalfLine_t &lin1, const HalfLine_t &lin2, Point_t &origin, bool backwards=false) const
Common origin: Half Line & Half Line. Keep track of origin.
Definition: GeoAlgo.h:341
double SqDist(const HalfLine_t &hline, const LineSegment_t &seg, Point_t &L1, Point_t &L2) const
Definition: GeoAlgo.h:281
double SqDist(const Line_t &l1, const Line_t &l2, Point_t &L1, Point_t &L2) const
Definition: GeoAlgo.h:109
double SqDist(const Point_t &pt, const Line_t &line) const
Definition: GeoAlgo.h:95
const Point_t & Start() const
Start getter.
GeoAlgo()
Default constructor.
Definition: GeoAlgo.h:47
Sphere_t _boundingSphere_(const std::vector< Point_t > &pts) const
Definition: GeoAlgo.cxx:1014
virtual ~GeoAlgo()
Default destructor.
Definition: GeoAlgo.h:50
double commonOrigin(const Trajectory_t &trj, const LineSegment_t &seg, bool backwards=false) const
Common origin: Trajectory & Line Segment. Do not keep track of origin.
Definition: GeoAlgo.h:362
double _SqDist_(const Point_t &pt, const LineSegment_t &line) const
Point & LineSegment distance w/o dimensionality check.
Definition: GeoAlgo.h:390
Point_t ClosestPt(const Trajectory_t &trj, const Point_t &pt, int &idx) const
Point_t & Trajectory_t closest point. Keep track of index of segment.
Definition: GeoAlgo.h:213
double _SqDist_(const AABox_t &box, const Point_t &pt) const
Point & AABox distance w/o dimensionality check.
Definition: GeoAlgo.h:437
double SqDist(const LineSegment_t &seg, const Trajectory_t &trj) const
LineSegment & Trajectory, don&#39;t keep track of points.
Definition: GeoAlgo.h:150
Point_t ClosestPt(const LineSegment_t &line, const Point_t &pt) const
Point & LineSegment closest point.
Definition: GeoAlgo.h:257
Representation of a 3D semi-infinite line. Defines a semi-infinite 3D line by having a start point (P...
Definition: GeoHalfLine.h:26
Sphere_t _RemainingPoints_(std::vector< Point_t > &remaining, const Sphere_t &thisSphere) const
Definition: GeoAlgo.cxx:1049
Int_t min
Definition: plot.C:26
double commonOrigin(const LineSegment_t &seg1, const LineSegment_t &seg2, bool backwards=false) const
Common origin: Line Segment & Line Segment. Do not keep track of origin.
Definition: GeoAlgo.h:320
std::vector< Point_t > Intersection(const LineSegment_t &l, const AABox_t &box) const
Intersection between LineSegment and an AABox.
Definition: GeoAlgo.h:65
Point_t _ClosestPt_(const HalfLine_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:420
double commonOrigin(const LineSegment_t &seg1, const LineSegment_t &seg2, Point_t &origin, bool backwards=false) const
Common origin: Line Segment & Line Segment. Keep track of origin.
Definition: GeoAlgo.h:323
double SqDist(const LineSegment_t &seg, const HalfLine_t &hline) const
Definition: GeoAlgo.h:290
Class def header for a class Trajectory.
Class def header for a class LineSegment.
double SqDist(const std::vector< geoalgo::Trajectory_t > &trj, const LineSegment_t &seg) const
LineSegment & vector of Trajectories, don&#39;t keep track of points.
Definition: GeoAlgo.h:173
void compat(const Point_t &p, const double r=0) const
3D point compatibility check
Definition: GeoSphere.cxx:363
double _SqDist_(const Point_t &pt, const Line_t &line) const
Definition: GeoAlgo.h:431
double SqDist(const HalfLine_t &l1, const HalfLine_t &l2) const
Definition: GeoAlgo.h:123
LineSegment_t BoxOverlap(const AABox_t &box, const HalfLine_t &line) const
LineSegment sub-segment of HalfLine inside an AABox.
Definition: GeoAlgo.cxx:166
Char_t n[5]
double SqDist(const std::vector< geoalgo::Trajectory_t > &trj, const Point_t &pt) const
Point_t & Trajectory_t distance - don&#39;t keep track.
Definition: GeoAlgo.h:229
double SqDist(const Trajectory_t &trj1, const Trajectory_t &trj2) const
Trajectory & Trajectory, don&#39;t keep track of points.
Definition: GeoAlgo.h:160
LineSegment_t BoxOverlap(const HalfLine_t &line, const AABox_t &box) const
LineSegment sub-segment of HalfLine inside an AABox.
Definition: GeoAlgo.h:77
double commonOrigin(const LineSegment_t &seg, const HalfLine_t &lin, Point_t &origin, bool backwards=false) const
Common origin: Line Segment & Line Segment. Keep track of origin.
Definition: GeoAlgo.h:335
Point_t _ClosestPt_(const AABox_t &box, const Point_t &pt) const
Point & AABox closest point w/o dimensionality check.
Definition: GeoAlgo.h:443
double SqDist(const Point_t &pt, const HalfLine_t &line) const
Point & HalfLine distance.
Definition: GeoAlgo.h:264
double commonOrigin(const HalfLine_t &lin, const LineSegment_t &seg, bool backwards=false) const
Common origin: Line Segment & Half Line. Do not keep track of origin.
Definition: GeoAlgo.h:326
double _SqDist_(const LineSegment_t &line, const Point_t &pt) const
Point & LineSegment distance w/o dimensionality check.
Definition: GeoAlgo.h:397
std::vector< Point_t > Intersection(const AABox_t &box, const HalfLine_t &line, bool back=false) const
Intersection between a HalfLine and an AABox.
Definition: GeoAlgo.cxx:10
double SqDist(const Trajectory_t &trj, const HalfLine_t &hline, Point_t &c1, Point_t &c2) const
HalfLine & Trajectory, keep track of points.
Definition: GeoAlgo.h:186
double SqDist(const HalfLine_t &hline, const LineSegment_t &seg) const
Definition: GeoAlgo.h:287
double commonOrigin(const Trajectory_t &trj, const HalfLine_t &lin, Point_t &origin, bool backwards=false) const
Common origin: Trajectory & Half Line. Keep track of origin.
Definition: GeoAlgo.h:353
std::vector< Point_t > Intersection(const Trajectory_t &trj, const AABox_t &box) const
Intersection between Trajectory and an AABox.
Definition: GeoAlgo.h:71
double _commonOrigin_(const Line_t &lin1, const Line_t &lin2, Point_t &origin) const
Common origin: Line & Line. Keep track of origin.
Definition: GeoAlgo.cxx:853
double commonOrigin(const Trajectory_t &trj1, const Trajectory_t &trj2, Point_t &origin, bool backwards=false) const
Common origin: Trajectory & Trajectory. Keep track of origin.
Definition: GeoAlgo.h:347
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:230
Trajectory_t BoxOverlap(const Trajectory_t &trj, const AABox_t &box) const
Get Trajectory inside box given some input trajectory -> now assumes trajectory cannot exit and re-en...
Definition: GeoAlgo.h:84
Point_t _ClosestPt_(const Point_t &pt, const LineSegment_t &line) const
Definition: GeoAlgo.cxx:387
double commonOrigin(const HalfLine_t &lin1, const HalfLine_t &lin2, bool backwards=false) const
Common origin: Half Line & Half Line. Do not keep track of origin.
Definition: GeoAlgo.h:338