LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
GeoAlgo.h
Go to the documentation of this file.
1 
14 #ifndef BASICTOOL_GEOALGO_H
15 #define BASICTOOL_GEOALGO_H
16 
24 
25 #include <vector>
26 
27 namespace geoalgo {
28 
43  class GeoAlgo {
44 
45  public:
46  //
47  // Intersections
48  //
49 
51  std::vector<Point_t> Intersection(AABox_t const& box,
52  HalfLine_t const& line,
53  bool back = false) const;
55  std::vector<Point_t> Intersection(HalfLine_t const& line,
56  AABox_t const& box,
57  bool back = false) const
58  {
59  return Intersection(box, line, back);
60  }
61 
63  std::vector<Point_t> Intersection(AABox_t const& box, LineSegment_t const& l) const;
65  std::vector<Point_t> Intersection(LineSegment_t const& l, AABox_t const& box) const
66  {
67  return Intersection(box, l);
68  }
69 
71  std::vector<Point_t> Intersection(AABox_t const& box, Trajectory_t const& trj) const;
73  std::vector<Point_t> Intersection(Trajectory_t const& trj, AABox_t const& box) const
74  {
75  return Intersection(box, trj);
76  }
77 
79  LineSegment_t BoxOverlap(AABox_t const& box, HalfLine_t const& line) const;
81  LineSegment_t BoxOverlap(HalfLine_t const& line, AABox_t const& box) const
82  {
83  return BoxOverlap(box, line);
84  }
85 
87  Trajectory_t BoxOverlap(AABox_t const& box, Trajectory_t const& trj) const;
89  Trajectory_t BoxOverlap(Trajectory_t const& trj, AABox_t const& box) const
90  {
91  return BoxOverlap(box, trj);
92  }
93 
94  //************************************************
95  //CLOSEST APPROACH BETWEEN POINT AND INFINITE LINE
96  //************************************************
97  // min distance between point and infinite line
98  double SqDist(Line_t const& line, Point_t const& pt) const
99  {
100  pt.compat(line.Pt1());
101  return _SqDist_(line, pt);
102  }
103  // min distance between point and infinite line
104  double SqDist(Point_t const& pt, Line_t const& line) const { return SqDist(line, pt); }
105  // closest point (on infinite line) from point
106  Point_t ClosestPt(Line_t const& line, Point_t const& pt) const
107  {
108  pt.compat(line.Pt1());
109  return _ClosestPt_(pt, line);
110  }
111  // closest point (on infinite line) from point
112  Point_t ClosestPt(Point_t const& pt, Line_t const& line) const { return _ClosestPt_(pt, line); }
113 
114  //*******************************************
115  //CLOSEST APPROACH BETWEEN TWO INFINITE LINES
116  //*******************************************
117  // Closest approach between two infinite line segments - keep track of closest approach points
118  double SqDist(Line_t const& l1, Line_t const& l2, Point_t& L1, Point_t& L2) const
119  {
120  l1.Pt1().compat(l2.Pt1());
121  return _SqDist_(l1, l2, L1, L2);
122  }
123  // Closest approach between two infinite line segments - don't keep track of closest approach points
124  double SqDist(Line_t const& l1, Line_t const& l2) const
125  {
126  Point_t L1;
127  Point_t L2;
128  return SqDist(l1, l2, L1, L2);
129  }
130 
131  //************************************************
132  //CLOSEST APPROACH BETWEEN TWO HALF-INFINITE LINES
133  //************************************************
134  // Closest approach between two infinite line segments - keep track of closest approach points
135  double SqDist(HalfLine_t const& l1, HalfLine_t const& l2, Point_t& L1, Point_t& L2) const
136  {
137  l1.Start().compat(l2.Start());
138  return _SqDist_(l1, l2, L1, L2);
139  }
140  // Closest approach between two infinite line segments - don't keep track of closest approach points
141  double SqDist(HalfLine_t const& l1, HalfLine_t const& l2) const
142  {
143  Point_t L1;
144  Point_t L2;
145  return SqDist(l1, l2, L1, L2);
146  }
147 
148  //******************************************
149  //CLOSEST APPROACH BETWEEN TWO LINE SEGMENTS
150  //******************************************
152  double SqDist(LineSegment_t const& seg1,
153  LineSegment_t const& seg2,
154  Point_t& c1,
155  Point_t& c2) const
156  {
157  seg1.Start().compat(seg2.Start());
158  return _SqDist_(seg1, seg2, c1, c2);
159  }
161  double SqDist(LineSegment_t const& seg1, LineSegment_t const& seg2) const
162  {
163  Point_t c1;
164  Point_t c2;
165  return SqDist(seg1, seg2, c1, c2);
166  }
167 
168  //******************************************
169  //CLOSEST APPROACH BETWEEN SEGMENT AND TRACK
170  //******************************************
172  double SqDist(LineSegment_t const& seg,
173  Trajectory_t const& trj,
174  Point_t& c1,
175  Point_t& c2) const;
177  double SqDist(Trajectory_t const& trj, LineSegment_t const& seg, Point_t& c1, Point_t& c2) const
178  {
179  return SqDist(seg, trj, c1, c2);
180  }
182  double SqDist(Trajectory_t const& trj, LineSegment_t const& seg) const
183  {
184  Point_t c1;
185  Point_t c2;
186  return SqDist(seg, trj, c1, c2);
187  }
189  double SqDist(LineSegment_t const& seg, Trajectory_t const& trj) const
190  {
191  Point_t c1;
192  Point_t c2;
193  return SqDist(seg, trj, c1, c2);
194  }
195 
196  //****************************************
197  //CLOSEST APPROACH BETWEEN TRACK AND TRACK
198  //****************************************
200  double SqDist(Trajectory_t const& trj1,
201  Trajectory_t const& trj2,
202  Point_t& c1,
203  Point_t& c2) const;
205  double SqDist(Trajectory_t const& trj1, Trajectory_t const& trj2) const
206  {
207  Point_t c1;
208  Point_t c2;
209  return SqDist(trj1, trj2, c1, c2);
210  }
211 
212  //*****************************************************
213  //CLOSEST APPROACH BETWEEN SEGMENT AND VECTOR OF TRACKS
214  //*****************************************************
216  double SqDist(LineSegment_t const& seg,
217  const std::vector<geoalgo::Trajectory_t>& trj,
218  Point_t& c1,
219  Point_t& c2,
220  int& trackIdx) const;
222  double SqDist(const std::vector<geoalgo::Trajectory_t>& trj,
223  LineSegment_t const& seg,
224  Point_t& c1,
225  Point_t& c2,
226  int& trackIdx) const
227  {
228  return SqDist(seg, trj, c2, c1, trackIdx);
229  }
231  double SqDist(const std::vector<geoalgo::Trajectory_t>& trj, LineSegment_t const& seg) const
232  {
233  Point_t c1;
234  Point_t c2;
235  int trackIdx;
236  return SqDist(seg, trj, c1, c2, trackIdx);
237  }
239  double SqDist(LineSegment_t const& seg, const std::vector<geoalgo::Trajectory_t>& trj) const
240  {
241  Point_t c1;
242  Point_t c2;
243  int trackIdx;
244  return SqDist(seg, trj, c1, c2, trackIdx);
245  }
246 
247  //*******************************************
248  //CLOSEST APPROACH BETWEEN HALFLINE AND TRACK
249  //*******************************************
251  double SqDist(HalfLine_t const& hline, Trajectory_t const& trj, Point_t& c1, Point_t& c2) const;
253  double SqDist(Trajectory_t const& trj, HalfLine_t const& hline, Point_t& c1, Point_t& c2) const
254  {
255  return SqDist(hline, trj, c2, c1);
256  }
258  double SqDist(Trajectory_t const& trj, HalfLine_t const& hline) const
259  {
260  Point_t c1;
261  Point_t c2;
262  return SqDist(hline, trj, c1, c2);
263  }
265  double SqDist(HalfLine_t const& hline, Trajectory_t const& trj) const
266  {
267  Point_t c1;
268  Point_t c2;
269  return SqDist(hline, trj, c1, c2);
270  }
271 
272  //****************************************
273  //CLOSEST APPROACH BETWEEN POINT AND TRACK
274  //****************************************
276  double SqDist(Point_t const& pt, Trajectory_t const& trj) const;
278  double SqDist(Trajectory_t const& trj, Point_t const& pt) const { return SqDist(pt, trj); }
280  Point_t ClosestPt(Point_t const& pt, Trajectory_t const& trj) const
281  {
282  int idx = 0;
283  return ClosestPt(pt, trj, idx);
284  }
286  Point_t ClosestPt(Trajectory_t const& trj, Point_t const& pt) const
287  {
288  int idx = 0;
289  return ClosestPt(pt, trj, idx);
290  }
292  Point_t ClosestPt(Point_t const& pt, Trajectory_t const& trj, int& idx) const;
294  Point_t ClosestPt(Trajectory_t const& trj, Point_t const& pt, int& idx) const
295  {
296  return ClosestPt(pt, trj, idx);
297  }
298 
299  //***************************************************
300  //CLOSEST APPROACH BETWEEN POINT AND VECTOR OF TRACKS
301  //***************************************************
303  double SqDist(Point_t const& pt,
304  const std::vector<geoalgo::Trajectory_t>& trj,
305  int& trackIdx) const;
307  double SqDist(const std::vector<geoalgo::Trajectory_t>& trj,
308  Point_t const& pt,
309  int& trackIdx) const
310  {
311  return SqDist(pt, trj, trackIdx);
312  }
314  double SqDist(Point_t const& pt, const std::vector<geoalgo::Trajectory_t>& trj) const
315  {
316  int trackIdx;
317  return SqDist(pt, trj, trackIdx);
318  }
320  double SqDist(const std::vector<geoalgo::Trajectory_t>& trj, Point_t const& pt) const
321  {
322  int trackIdx;
323  return SqDist(pt, trj, trackIdx);
324  }
326  Point_t ClosestPt(Point_t const& pt,
327  const std::vector<geoalgo::Trajectory_t>& trj,
328  int& trackIdx) const;
330  Point_t ClosestPt(const std::vector<geoalgo::Trajectory_t>& trj,
331  Point_t const& pt,
332  int& trackIdx) const
333  {
334  return ClosestPt(pt, trj, trackIdx);
335  }
337  Point_t ClosestPt(Point_t const& pt, const std::vector<geoalgo::Trajectory_t>& trj) const
338  {
339  int trackIdx;
340  return ClosestPt(pt, trj, trackIdx);
341  }
343  Point_t ClosestPt(const std::vector<geoalgo::Trajectory_t>& trj, Point_t const& pt) const
344  {
345  int trackIdx;
346  return ClosestPt(pt, trj, trackIdx);
347  }
348 
349  //***********************************************
350  //CLOSEST APPROACH BETWEEN POINT AND LINE SEGMENT
351  //***********************************************
353  double SqDist(Point_t const& pt, LineSegment_t const& line) const
354  {
355  pt.compat(line.Start());
356  return _SqDist_(pt, line);
357  }
359  double SqDist(LineSegment_t const& line, Point_t const& pt) const { return SqDist(pt, line); }
361  Point_t ClosestPt(Point_t const& pt, LineSegment_t const& line) const
362  {
363  pt.compat(line.Start());
364  return _ClosestPt_(pt, line);
365  }
367  Point_t ClosestPt(LineSegment_t const& line, Point_t const& pt) const
368  {
369  return ClosestPt(pt, line);
370  }
371 
372  //********************************************
373  //CLOSEST APPROACH BETWEEN POINT AND HALF LINE
374  //********************************************
376  double SqDist(Point_t const& pt, HalfLine_t const& line) const
377  {
378  pt.compat(line.Start());
379  return _SqDist_(pt, line);
380  }
382  double SqDist(HalfLine_t const& line, Point_t const& pt) const { return SqDist(pt, line); }
384  Point_t ClosestPt(Point_t const& pt, HalfLine_t const& line) const
385  {
386  pt.compat(line.Start());
387  return _ClosestPt_(pt, line);
388  }
390  Point_t ClosestPt(HalfLine_t const& line, Point_t const& pt) const
391  {
392  return ClosestPt(pt, line);
393  }
394 
395  //***************************************************
396  //CLOSEST APPROACH BETWEEN HALF LINE AND LINE SEGMENT
397  //***************************************************
398  // half-line and line-segment. keep track of closest approach points
399  double SqDist(HalfLine_t const& hline, LineSegment_t const& seg, Point_t& L1, Point_t& L2) const
400  {
401  hline.Start().compat(seg.Start());
402  return _SqDist_(hline, seg, L1, L2);
403  }
404  // half-line and line-segment. keep track of closest approach points
405  double SqDist(LineSegment_t const& seg, HalfLine_t const& hline, Point_t& L1, Point_t& L2) const
406  {
407  return SqDist(hline, seg, L2, L1);
408  }
409  // half-line and line-segment. Do not keep track of closest approach points
410  double SqDist(HalfLine_t const& hline, LineSegment_t const& seg) const
411  {
412  Point_t L1;
413  Point_t L2;
414  return SqDist(hline, seg, L1, L2);
415  }
416  // half-line and line-segment. Do not keep track of closest approach points
417  double SqDist(LineSegment_t const& seg, HalfLine_t const& hline) const
418  {
419  return SqDist(hline, seg);
420  }
421 
422  //***************************************************
423  //CLOSEST APPROACH BETWEEN POINT AND AXIS ALIGNED BOX
424  //***************************************************
426  double SqDist(Point_t const& pt, AABox_t const& box) const
427  {
428  pt.compat(box.Min());
429  return _SqDist_(pt, box);
430  }
432  double SqDist(AABox_t const& box, Point_t const& pt) { return SqDist(pt, box); }
434  Point_t ClosestPt(Point_t const& pt, AABox_t const& box) const
435  {
436  pt.compat(box.Min());
437  return _ClosestPt_(pt, box);
438  }
440  Point_t ClosestPt(AABox_t const& box, Point_t const& pt) const { return ClosestPt(pt, box); }
441 
442  //***************************************************************************
443  //COMMON ORIGIN ALGORITHMS: DETERMINE IF TWO GEO-OBJECTS HAVE A COMMON ORIGIN
444  //***************************************************************************
446  double commonOrigin(Line_t const& lin1, Line_t const& lin2) const
447  {
448  Point_t origin(lin1.Pt1().size());
449  return commonOrigin(lin1, lin2, origin);
450  }
452  double commonOrigin(Line_t const& lin1, Line_t const& lin2, Point_t& origin) const
453  {
454  lin1.Pt1().compat(lin2.Pt1());
455  return _commonOrigin_(lin1, lin2, origin);
456  }
458  double commonOrigin(LineSegment_t const& seg1,
459  LineSegment_t const& seg2,
460  bool backwards = false) const
461  {
462  Point_t origin(seg1.Start().size());
463  return commonOrigin(seg1, seg2, origin, backwards);
464  }
466  double commonOrigin(LineSegment_t const& seg1,
467  LineSegment_t const& seg2,
468  Point_t& origin,
469  bool backwards = false) const
470  {
471  seg1.Start().compat(seg2.Start());
472  return _commonOrigin_(seg1, seg2, origin, backwards);
473  }
475  double commonOrigin(HalfLine_t const& lin,
476  LineSegment_t const& seg,
477  bool backwards = false) const
478  {
479  Point_t origin(lin.Start().size());
480  return commonOrigin(lin, seg, origin, backwards);
481  }
483  double commonOrigin(HalfLine_t const& lin,
484  LineSegment_t const& seg,
485  Point_t& origin,
486  bool backwards = false) const
487  {
488  lin.Start().compat(seg.Start());
489  return _commonOrigin_(lin, seg, origin, backwards);
490  }
492  double commonOrigin(LineSegment_t const& seg,
493  HalfLine_t const& lin,
494  bool backwards = false) const
495  {
496  Point_t origin(lin.Start().size());
497  return commonOrigin(lin, seg, origin, backwards);
498  }
500  double commonOrigin(LineSegment_t const& seg,
501  HalfLine_t const& lin,
502  Point_t& origin,
503  bool backwards = false) const
504  {
505  lin.Start().compat(seg.Start());
506  return _commonOrigin_(lin, seg, origin, backwards);
507  }
509  double commonOrigin(HalfLine_t const& lin1,
510  HalfLine_t const& lin2,
511  bool backwards = false) const
512  {
513  Point_t origin(lin1.Start().size());
514  return commonOrigin(lin1, lin2, origin, backwards);
515  }
517  double commonOrigin(HalfLine_t const& lin1,
518  HalfLine_t const& lin2,
519  Point_t& origin,
520  bool backwards = false) const
521  {
522  lin1.Start().compat(lin2.Start());
523  return _commonOrigin_(lin1, lin2, origin, backwards);
524  }
526  double commonOrigin(Trajectory_t const& trj1,
527  Trajectory_t const& trj2,
528  bool backwards = false) const
529  {
530  Point_t origin(trj1.front().size());
531  return commonOrigin(trj1, trj2, origin, backwards);
532  }
534  double commonOrigin(Trajectory_t const& trj1,
535  Trajectory_t const& trj2,
536  Point_t& origin,
537  bool backwards = false) const
538  {
539  trj1.front().compat(trj2.front());
540  return _commonOrigin_(trj1, trj2, origin, backwards);
541  }
543  double commonOrigin(Trajectory_t const& trj,
544  HalfLine_t const& lin,
545  bool backwards = false) const
546  {
547  Point_t origin(trj.front().size());
548  return commonOrigin(trj, lin, origin, backwards);
549  }
551  double commonOrigin(Trajectory_t const& trj,
552  HalfLine_t const& lin,
553  Point_t& origin,
554  bool backwards = false) const
555  {
556  trj.front().compat(lin.Start());
557  return _commonOrigin_(trj, lin, origin, backwards);
558  }
560  double commonOrigin(HalfLine_t const& lin,
561  Trajectory_t const& trj,
562  bool backwards = false) const
563  {
564  Point_t origin(trj.front().size());
565  return commonOrigin(trj, lin, origin, backwards);
566  }
568  double commonOrigin(HalfLine_t const& lin,
569  Trajectory_t const& trj,
570  Point_t& origin,
571  bool backwards = false) const
572  {
573  trj.front().compat(lin.Start());
574  return _commonOrigin_(trj, lin, origin, backwards);
575  }
577  double commonOrigin(Trajectory_t const& trj,
578  LineSegment_t const& seg,
579  bool backwards = false) const
580  {
581  Point_t origin(trj.front().size());
582  return commonOrigin(trj, seg, origin, backwards);
583  }
585  double commonOrigin(Trajectory_t const& trj,
586  LineSegment_t const& seg,
587  Point_t& origin,
588  bool backwards = false) const
589  {
590  trj.front().compat(seg.Start());
591  return _commonOrigin_(trj, seg, origin, backwards);
592  }
594  double commonOrigin(LineSegment_t const& seg,
595  Trajectory_t const& trj,
596  bool backwards = false) const
597  {
598  Point_t origin(trj.front().size());
599  return commonOrigin(trj, seg, origin, backwards);
600  }
602  double commonOrigin(LineSegment_t const& seg,
603  Trajectory_t const& trj,
604  Point_t& origin,
605  bool backwards = false) const
606  {
607  trj.front().compat(seg.Start());
608  return _commonOrigin_(trj, seg, origin, backwards);
609  }
610 
611  //************************************************************************
612  //BOUNDING SPHERE ALGORITHM: RETURN SMALLEST SPHERE THAT BOUNDS ALL POINTS
613  //************************************************************************
614  // Bounding Sphere problem given a vector of 3D points
615  Sphere_t boundingSphere(const std::vector<Point_t>& pts) const
616  {
617  for (auto& p : pts) {
618  pts.front().compat(p);
619  }
620  return _boundingSphere_(pts);
621  }
622 
623  protected:
625  double _SqDist_(Line_t const& l1, Line_t const& l2, Point_t& L1, Point_t& L2) const;
626 
628  double _SqDist_(HalfLine_t const& l1, HalfLine_t const& l2, Point_t& L1, Point_t& L2) const;
629 
631  double _SqDist_(Point_t const& pt, LineSegment_t const& line) const
632  {
633  return _SqDist_(pt, line.Start(), line.End());
634  }
635 
637  double _SqDist_(Point_t const& pt, Point_t const& line_s, Point_t const& line_e) const;
638 
640  double _SqDist_(LineSegment_t const& line, Point_t const& pt) const
641  {
642  return _SqDist_(pt, line);
643  }
644 
646  double _SqDist_(HalfLine_t const& hline,
647  LineSegment_t const& seg,
648  Point_t& L1,
649  Point_t& L2) const;
650 
652  double _SqDist_(LineSegment_t const& seg1,
653  LineSegment_t const& seg2,
654  Point_t& c1,
655  Point_t& c2) const;
656 
657  // Point & LineSegment closest point w/o dimensionality check
658  Point_t _ClosestPt_(Point_t const& pt, LineSegment_t const& line) const;
659  // Point & LineSegment closest point w/o dimensionality check
660  Point_t _ClosestPt_(LineSegment_t const& line, Point_t const& pt) const
661  {
662  return _ClosestPt_(pt, line);
663  }
664 
666  double _SqDist_(Point_t const& pt, HalfLine_t const& line) const;
668  double _SqDist_(HalfLine_t const& line, Point_t const& pt) const { return _SqDist_(pt, line); }
669  // Point & HalfLine closest point w/o dimensionality check
670  Point_t _ClosestPt_(Point_t const& pt, HalfLine_t const& line) const;
671  // Point & HalfLine closest point w/o dimensionality check
672  Point_t _ClosestPt_(HalfLine_t const& line, Point_t const& pt) const
673  {
674  return _ClosestPt_(pt, line);
675  }
676 
677  // Point & InfLine closest point w/o dimensionality check
678  Point_t _ClosestPt_(Line_t const& line, Point_t const& pt) const;
679  // Point & InfLine closest point w/o dimensionality check
680  Point_t _ClosestPt_(Point_t const& pt, Line_t const& line) const
681  {
682  return _ClosestPt_(line, pt);
683  }
684  // Point & InfLine distance w/o dimensionality check
685  double _SqDist_(Line_t const& line, Point_t const& pt) const;
686  // Point & InfLine distance w/o dimensionality check
687  double _SqDist_(Point_t const& pt, Line_t const& line) const { return _SqDist_(line, pt); }
688 
690  double _SqDist_(Point_t const& pt, AABox_t const& box) const;
692  double _SqDist_(AABox_t const& box, Point_t const& pt) const { return _SqDist_(pt, box); }
693 
695  Point_t _ClosestPt_(Point_t const& pt, AABox_t const& box) const;
697  Point_t _ClosestPt_(AABox_t const& box, Point_t const& pt) const
698  {
699  return _ClosestPt_(pt, box);
700  }
701 
703  double _commonOrigin_(Line_t const& lin1, Line_t const& lin2, Point_t& origin) const;
705  double _commonOrigin_(HalfLine_t const& lin1,
706  HalfLine_t const& lin2,
707  Point_t& origin,
708  bool backwards) const;
710  double _commonOrigin_(HalfLine_t const& lin,
711  LineSegment_t const& seg,
712  Point_t& origin,
713  bool backwards) const;
715  double _commonOrigin_(LineSegment_t const& seg1,
716  LineSegment_t const& seg2,
717  Point_t& origin,
718  bool backwards) const;
720  double _commonOrigin_(Trajectory_t const& trj1,
721  Trajectory_t const& trj2,
722  Point_t& origin,
723  bool backwards) const;
725  double _commonOrigin_(Trajectory_t const& trj,
726  LineSegment_t const& seg,
727  Point_t& origin,
728  bool backwards) const;
730  double _commonOrigin_(Trajectory_t const& trj,
731  HalfLine_t const& lin,
732  Point_t& origin,
733  bool backwards) const;
734 
735  // Bounding Sphere given a vector of points
736  Sphere_t _boundingSphere_(const std::vector<Point_t>& pts) const;
737  Sphere_t _RemainingPoints_(std::vector<Point_t>& remaining, Sphere_t const& thisSphere) const;
738  Sphere_t _WelzlSphere_(const std::vector<Point_t>& pts,
739  int numPts,
740  std::vector<Point_t> sosPts) const;
741 
743  double _Clamp_(double const n, double const min, double const max) const;
744 
746  inline void _Swap_(double& tmin, double& tmax) const
747  {
748  if (tmin > tmax) std::swap(tmin, tmax);
749  }
750  };
751 }
752 
753 #endif
754  // end of doxygen group
Point_t const & Start() const
Start getter.
double SqDist(Point_t const &pt, HalfLine_t const &line) const
Point & HalfLine distance.
Definition: GeoAlgo.h:376
double commonOrigin(Trajectory_t const &trj, HalfLine_t const &lin, Point_t &origin, bool backwards=false) const
Common origin: Trajectory & Half Line. Keep track of origin.
Definition: GeoAlgo.h:551
double SqDist(LineSegment_t const &seg1, LineSegment_t const &seg2) const
LineSegment & LineSegment, don&#39;t keep track of points.
Definition: GeoAlgo.h:161
void compat(Vector const &obj) const
Dimensional check for a compatibility.
Definition: GeoVector.cxx:128
double SqDist(const std::vector< geoalgo::Trajectory_t > &trj, Point_t const &pt) const
Point_t & Trajectory_t distance - don&#39;t keep track.
Definition: GeoAlgo.h:320
Algorithm to compute various geometrical relation among geometrical objects. In particular functions ...
Definition: GeoAlgo.h:43
double commonOrigin(Trajectory_t const &trj1, Trajectory_t const &trj2, bool backwards=false) const
Common origin: Trajectory & Trajectory. Do not keep track of origin.
Definition: GeoAlgo.h:526
double commonOrigin(LineSegment_t const &seg1, LineSegment_t const &seg2, bool backwards=false) const
Common origin: Line Segment & Line Segment. Do not keep track of origin.
Definition: GeoAlgo.h:458
Point_t _ClosestPt_(Point_t const &pt, Line_t const &line) const
Definition: GeoAlgo.h:680
double _Clamp_(double const n, double const min, double const max) const
Clamp function: checks if value out of bounds.
Definition: GeoAlgo.cxx:852
double commonOrigin(HalfLine_t const &lin, Trajectory_t const &trj, Point_t &origin, bool backwards=false) const
Common origin: Trajectory & Half Line. Keep track of origin.
Definition: GeoAlgo.h:568
Point_t ClosestPt(Point_t const &pt, LineSegment_t const &line) const
Point & LineSegment closest point.
Definition: GeoAlgo.h:361
double commonOrigin(Trajectory_t const &trj, HalfLine_t const &lin, bool backwards=false) const
Common origin: Trajectory & Half Line. Do not keep track of origin.
Definition: GeoAlgo.h:543
double commonOrigin(LineSegment_t const &seg1, LineSegment_t const &seg2, Point_t &origin, bool backwards=false) const
Common origin: Line Segment & Line Segment. Keep track of origin.
Definition: GeoAlgo.h:466
double SqDist(Trajectory_t const &trj, Point_t const &pt) const
Point_t & Trajectory_t distance.
Definition: GeoAlgo.h:278
Point_t ClosestPt(HalfLine_t const &line, Point_t const &pt) const
Point & HalfLine closest point.
Definition: GeoAlgo.h:390
double SqDist(Trajectory_t const &trj, LineSegment_t const &seg, Point_t &c1, Point_t &c2) const
LineSegment & Trajectory, keep track of points.
Definition: GeoAlgo.h:177
Trajectory_t BoxOverlap(Trajectory_t const &trj, AABox_t const &box) const
Get Trajectory inside box given some input trajectory -> now assumes trajectory cannot exit and re-en...
Definition: GeoAlgo.h:89
Class def header for a class HalfLine.
double SqDist(Point_t const &pt, const std::vector< geoalgo::Trajectory_t > &trj) const
Point_t & Trajectory_t distance - don&#39;t keep track.
Definition: GeoAlgo.h:314
Point_t ClosestPt(Point_t const &pt, AABox_t const &box) const
Point & AABox closest point.
Definition: GeoAlgo.h:434
void _Swap_(double &tmin, double &tmax) const
Swap two points if min & max are inverted.
Definition: GeoAlgo.h:746
double commonOrigin(HalfLine_t const &lin, LineSegment_t const &seg, bool backwards=false) const
Common origin: Line Segment & Half Line. Do not keep track of origin.
Definition: GeoAlgo.h:475
double SqDist(Line_t const &line, Point_t const &pt) const
Definition: GeoAlgo.h:98
Point_t _ClosestPt_(HalfLine_t const &line, Point_t const &pt) const
Definition: GeoAlgo.h:672
double SqDist(LineSegment_t const &seg, HalfLine_t const &hline, Point_t &L1, Point_t &L2) const
Definition: GeoAlgo.h:405
double SqDist(HalfLine_t const &l1, HalfLine_t const &l2, Point_t &L1, Point_t &L2) const
Definition: GeoAlgo.h:135
Representation of a simple 3D line segment Defines a finite 3D straight line by having the start and ...
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 SqDist(Trajectory_t const &trj1, Trajectory_t const &trj2) const
Trajectory & Trajectory, don&#39;t keep track of points.
Definition: GeoAlgo.h:205
Class def header for a class Line.
double _SqDist_(Line_t const &l1, Line_t const &l2, Point_t &L1, Point_t &L2) const
Line & Line distance w/o dimensionality check.
Definition: GeoAlgo.cxx:193
double SqDist(HalfLine_t const &hline, Trajectory_t const &trj) const
HalfLine & Trajectory, don&#39;t keep track of points.
Definition: GeoAlgo.h:265
double commonOrigin(Trajectory_t const &trj1, Trajectory_t const &trj2, Point_t &origin, bool backwards=false) const
Common origin: Trajectory & Trajectory. Keep track of origin.
Definition: GeoAlgo.h:534
double commonOrigin(Line_t const &lin1, Line_t const &lin2) const
Common origin: Line Segment & Line Segment. Do not keep track of origin.
Definition: GeoAlgo.h:446
double SqDist(LineSegment_t const &seg, const std::vector< geoalgo::Trajectory_t > &trj) const
LineSegment & vector of Trajectories, don&#39;t keep track of points.
Definition: GeoAlgo.h:239
double SqDist(Line_t const &l1, Line_t const &l2, Point_t &L1, Point_t &L2) const
Definition: GeoAlgo.h:118
double commonOrigin(LineSegment_t const &seg, HalfLine_t const &lin, bool backwards=false) const
Common origin: Line Segment & Half Line. Do not keep track of origin.
Definition: GeoAlgo.h:492
double commonOrigin(HalfLine_t const &lin1, HalfLine_t const &lin2, Point_t &origin, bool backwards=false) const
Common origin: Half Line & Half Line. Keep track of origin.
Definition: GeoAlgo.h:517
Point_t ClosestPt(Line_t const &line, Point_t const &pt) const
Definition: GeoAlgo.h:106
Class def header for a class AABox.
Sphere_t boundingSphere(const std::vector< Point_t > &pts) const
Definition: GeoAlgo.h:615
Point_t ClosestPt(AABox_t const &box, Point_t const &pt) const
Point & AABox closest point.
Definition: GeoAlgo.h:440
double commonOrigin(Trajectory_t const &trj, LineSegment_t const &seg, Point_t &origin, bool backwards=false) const
Common origin: Trajectory & Line Segment. Keep track of origin.
Definition: GeoAlgo.h:585
double commonOrigin(LineSegment_t const &seg, HalfLine_t const &lin, Point_t &origin, bool backwards=false) const
Common origin: Line Segment & Line Segment. Keep track of origin.
Definition: GeoAlgo.h:500
double SqDist(Line_t const &l1, Line_t const &l2) const
Definition: GeoAlgo.h:124
std::vector< Point_t > Intersection(LineSegment_t const &l, AABox_t const &box) const
Intersection between LineSegment and an AABox.
Definition: GeoAlgo.h:65
double SqDist(LineSegment_t const &seg1, LineSegment_t const &seg2, Point_t &c1, Point_t &c2) const
LineSegment_t & LineSegment_t distance - keep track of points.
Definition: GeoAlgo.h:152
Point_t _ClosestPt_(Point_t const &pt, LineSegment_t const &line) const
Definition: GeoAlgo.cxx:390
double _SqDist_(HalfLine_t const &line, Point_t const &pt) const
Point & HalfLine distance w/o dimensionality check.
Definition: GeoAlgo.h:668
Point_t ClosestPt(Trajectory_t const &trj, Point_t const &pt) const
Point_t & Trajectory_t closest point.
Definition: GeoAlgo.h:286
TCanvas * c1
Definition: plotHisto.C:7
double commonOrigin(HalfLine_t const &lin, Trajectory_t const &trj, bool backwards=false) const
Common origin: Trajectory & Half Line. Do not keep track of origin.
Definition: GeoAlgo.h:560
TCanvas * c2
Definition: plot_hist.C:75
std::vector< Point_t > Intersection(Trajectory_t const &trj, AABox_t const &box) const
Intersection between Trajectory and an AABox.
Definition: GeoAlgo.h:73
Point_t ClosestPt(Point_t const &pt, Line_t const &line) const
Definition: GeoAlgo.h:112
Class def header for a class Point and Vector.
double commonOrigin(Trajectory_t const &trj, LineSegment_t const &seg, bool backwards=false) const
Common origin: Trajectory & Line Segment. Do not keep track of origin.
Definition: GeoAlgo.h:577
Sphere_t _RemainingPoints_(std::vector< Point_t > &remaining, Sphere_t const &thisSphere) const
Definition: GeoAlgo.cxx:1070
double commonOrigin(LineSegment_t const &seg, Trajectory_t const &trj, Point_t &origin, bool backwards=false) const
Common origin: Trajectory & Line Segment. Keep track of origin.
Definition: GeoAlgo.h:602
Point_t ClosestPt(Point_t const &pt, HalfLine_t const &line) const
Point & HalfLine closest point.
Definition: GeoAlgo.h:384
Point_t ClosestPt(Point_t const &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:337
double SqDist(const std::vector< geoalgo::Trajectory_t > &trj, Point_t const &pt, int &trackIdx) const
Point_t & Trajectory_t distance - keep track of which track.
Definition: GeoAlgo.h:307
double SqDist(HalfLine_t const &line, Point_t const &pt) const
Point & HalfLine distance.
Definition: GeoAlgo.h:382
Point_t ClosestPt(LineSegment_t const &line, Point_t const &pt) const
Point & LineSegment closest point.
Definition: GeoAlgo.h:367
Point_t ClosestPt(const std::vector< geoalgo::Trajectory_t > &trj, Point_t const &pt) const
Point_t & Trajectory_t closest point - don&#39;t keep track of which track is closest.
Definition: GeoAlgo.h:343
Class def header for a class HalfLine.
TMarker * pt
Definition: egs.C:25
double SqDist(Trajectory_t const &trj, HalfLine_t const &hline) const
HalfLine & Trajectory, don&#39;t keep track of points.
Definition: GeoAlgo.h:258
double SqDist(Trajectory_t const &trj, LineSegment_t const &seg) const
LineSegment & Trajectory, don&#39;t keep track of points.
Definition: GeoAlgo.h:182
Representation of a 3D infinite line. Defines an infinite 3D line by having 2 points which completely...
Definition: GeoLine.h:27
double _SqDist_(AABox_t const &box, Point_t const &pt) const
Point & AABox distance w/o dimensionality check.
Definition: GeoAlgo.h:692
double _SqDist_(Point_t const &pt, Line_t const &line) const
Definition: GeoAlgo.h:687
double SqDist(AABox_t const &box, Point_t const &pt)
Point & AABox distance.
Definition: GeoAlgo.h:432
Sphere_t _WelzlSphere_(const std::vector< Point_t > &pts, int numPts, std::vector< Point_t > sosPts) const
Definition: GeoAlgo.cxx:1114
void compat(Point_t const &obj) const
Dimensionality check function w/ Trajectory.
Point_t ClosestPt(Trajectory_t const &trj, Point_t const &pt, int &idx) const
Point_t & Trajectory_t closest point. Keep track of index of segment.
Definition: GeoAlgo.h:294
double SqDist(Point_t const &pt, AABox_t const &box) const
Point & AABox distance.
Definition: GeoAlgo.h:426
double SqDist(const std::vector< geoalgo::Trajectory_t > &trj, LineSegment_t const &seg) const
LineSegment & vector of Trajectories, don&#39;t keep track of points.
Definition: GeoAlgo.h:231
Point_t _ClosestPt_(AABox_t const &box, Point_t const &pt) const
Point & AABox closest point w/o dimensionality check.
Definition: GeoAlgo.h:697
Sphere_t _boundingSphere_(const std::vector< Point_t > &pts) const
Definition: GeoAlgo.cxx:1033
double _SqDist_(Point_t const &pt, LineSegment_t const &line) const
Point & LineSegment distance w/o dimensionality check.
Definition: GeoAlgo.h:631
double SqDist(Point_t const &pt, LineSegment_t const &line) const
Point & LineSegment_t distance.
Definition: GeoAlgo.h:353
double SqDist(LineSegment_t const &seg, Trajectory_t const &trj) const
LineSegment & Trajectory, don&#39;t keep track of points.
Definition: GeoAlgo.h:189
double commonOrigin(HalfLine_t const &lin, LineSegment_t const &seg, Point_t &origin, bool backwards=false) const
Common origin: Line Segment & Line Segment. Keep track of origin.
Definition: GeoAlgo.h:483
double commonOrigin(Line_t const &lin1, Line_t const &lin2, Point_t &origin) const
Common origin: Line Segment & Line Segment. Keep track of origin.
Definition: GeoAlgo.h:452
void compat(Point_t const &p, double const r=0) const
3D point compatibility check
Definition: GeoSphere.cxx:371
Point_t _ClosestPt_(LineSegment_t const &line, Point_t const &pt) const
Definition: GeoAlgo.h:660
double SqDist(HalfLine_t const &l1, HalfLine_t const &l2) const
Definition: GeoAlgo.h:141
double _SqDist_(LineSegment_t const &line, Point_t const &pt) const
Point & LineSegment distance w/o dimensionality check.
Definition: GeoAlgo.h:640
Representation of a 3D semi-infinite line. Defines a semi-infinite 3D line by having a start point (P...
Definition: GeoHalfLine.h:30
Point_t const & Start() const
Start getter.
Definition: GeoHalfLine.cxx:28
Point_t ClosestPt(const std::vector< geoalgo::Trajectory_t > &trj, Point_t const &pt, int &trackIdx) const
Point_t & Trajectory_t closest point - keep track of which track is closest.
Definition: GeoAlgo.h:330
Class def header for a class Trajectory.
double commonOrigin(HalfLine_t const &lin1, HalfLine_t const &lin2, bool backwards=false) const
Common origin: Half Line & Half Line. Do not keep track of origin.
Definition: GeoAlgo.h:509
Class def header for a class LineSegment.
double SqDist(HalfLine_t const &hline, LineSegment_t const &seg) const
Definition: GeoAlgo.h:410
Char_t n[5]
Point_t const & End() const
End getter.
std::vector< Point_t > Intersection(AABox_t const &box, HalfLine_t const &line, bool back=false) const
Intersection between a HalfLine and an AABox.
Definition: GeoAlgo.cxx:11
double SqDist(Point_t const &pt, Line_t const &line) const
Definition: GeoAlgo.h:104
Point_t ClosestPt(Point_t const &pt, Trajectory_t const &trj) const
Point_t & Trajectory_t closest point.
Definition: GeoAlgo.h:280
Point_t const & Pt1() const
Start getter.
Definition: GeoLine.cxx:24
double commonOrigin(LineSegment_t const &seg, Trajectory_t const &trj, bool backwards=false) const
Common origin: Trajectory & Line Segment. Do not keep track of origin.
Definition: GeoAlgo.h:594
LineSegment_t BoxOverlap(AABox_t const &box, HalfLine_t const &line) const
LineSegment sub-segment of HalfLine inside an AABox.
Definition: GeoAlgo.cxx:168
double SqDist(LineSegment_t const &seg, HalfLine_t const &hline) const
Definition: GeoAlgo.h:417
double SqDist(HalfLine_t const &hline, LineSegment_t const &seg, Point_t &L1, Point_t &L2) const
Definition: GeoAlgo.h:399
double SqDist(LineSegment_t const &line, Point_t const &pt) const
Point & LineSegment distance.
Definition: GeoAlgo.h:359
Point_t const & Min() const
Minimum point getter.
Definition: GeoAABox.cxx:23
double SqDist(Trajectory_t const &trj, HalfLine_t const &hline, Point_t &c1, Point_t &c2) const
HalfLine & Trajectory, keep track of points.
Definition: GeoAlgo.h:253
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
double _commonOrigin_(Line_t const &lin1, Line_t const &lin2, Point_t &origin) const
Common origin: Line & Line. Keep track of origin.
Definition: GeoAlgo.cxx:860
LineSegment_t BoxOverlap(HalfLine_t const &line, AABox_t const &box) const
LineSegment sub-segment of HalfLine inside an AABox.
Definition: GeoAlgo.h:81
std::vector< Point_t > Intersection(HalfLine_t const &line, AABox_t const &box, bool back=false) const
Intersection between a HalfLine and an AABox.
Definition: GeoAlgo.h:55
double SqDist(const std::vector< geoalgo::Trajectory_t > &trj, LineSegment_t const &seg, Point_t &c1, Point_t &c2, int &trackIdx) const
LineSegment & vector of Trajectories, keep track of points.
Definition: GeoAlgo.h:222