LArSoft  v09_90_00
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(const AABox_t& box,
52  const HalfLine_t& line,
53  bool back = false) const;
55  std::vector<Point_t> Intersection(const HalfLine_t& line,
56  const AABox_t& box,
57  bool back = false) const
58  {
59  return Intersection(box, line, back);
60  }
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  {
67  return Intersection(box, l);
68  }
69 
71  std::vector<Point_t> Intersection(const AABox_t& box, const Trajectory_t& trj) const;
73  std::vector<Point_t> Intersection(const Trajectory_t& trj, const AABox_t& box) const
74  {
75  return Intersection(box, trj);
76  }
77 
79  LineSegment_t BoxOverlap(const AABox_t& box, const HalfLine_t& line) const;
81  LineSegment_t BoxOverlap(const HalfLine_t& line, const AABox_t& box) const
82  {
83  return BoxOverlap(box, line);
84  }
85 
87  Trajectory_t BoxOverlap(const AABox_t& box, const Trajectory_t& trj) const;
89  Trajectory_t BoxOverlap(const Trajectory_t& trj, const AABox_t& 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(const Line_t& line, const Point_t& 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(const Point_t& pt, const Line_t& line) const { return SqDist(line, pt); }
105  // closest point (on infinite line) from point
106  Point_t ClosestPt(const Line_t& line, const Point_t& 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(const Point_t& pt, const Line_t& 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(const Line_t& l1, const Line_t& 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(const Line_t& l1, const Line_t& 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(const HalfLine_t& l1, const HalfLine_t& 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(const HalfLine_t& l1, const HalfLine_t& 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(const LineSegment_t& seg1,
153  const LineSegment_t& 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(const LineSegment_t& seg1, const LineSegment_t& 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(const LineSegment_t& seg,
173  const Trajectory_t& trj,
174  Point_t& c1,
175  Point_t& c2) const;
177  double SqDist(const Trajectory_t& trj, const LineSegment_t& seg, Point_t& c1, Point_t& c2) const
178  {
179  return SqDist(seg, trj, c1, c2);
180  }
182  double SqDist(const Trajectory_t& trj, const LineSegment_t& seg) const
183  {
184  Point_t c1;
185  Point_t c2;
186  return SqDist(seg, trj, c1, c2);
187  }
189  double SqDist(const LineSegment_t& seg, const Trajectory_t& 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(const Trajectory_t& trj1,
201  const Trajectory_t& trj2,
202  Point_t& c1,
203  Point_t& c2) const;
205  double SqDist(const Trajectory_t& trj1, const Trajectory_t& 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(const LineSegment_t& 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  const LineSegment_t& 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, const LineSegment_t& 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(const LineSegment_t& 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(const HalfLine_t& hline, const Trajectory_t& trj, Point_t& c1, Point_t& c2) const;
253  double SqDist(const Trajectory_t& trj, const HalfLine_t& hline, Point_t& c1, Point_t& c2) const
254  {
255  return SqDist(hline, trj, c2, c1);
256  }
258  double SqDist(const Trajectory_t& trj, const HalfLine_t& hline) const
259  {
260  Point_t c1;
261  Point_t c2;
262  return SqDist(hline, trj, c1, c2);
263  }
265  double SqDist(const HalfLine_t& hline, const Trajectory_t& 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(const Point_t& pt, const Trajectory_t& trj) const;
278  double SqDist(const Trajectory_t& trj, const Point_t& pt) const { return SqDist(pt, trj); }
280  Point_t ClosestPt(const Point_t& pt, const Trajectory_t& trj) const
281  {
282  int idx = 0;
283  return ClosestPt(pt, trj, idx);
284  }
286  Point_t ClosestPt(const Trajectory_t& trj, const Point_t& pt) const
287  {
288  int idx = 0;
289  return ClosestPt(pt, trj, idx);
290  }
292  Point_t ClosestPt(const Point_t& pt, const Trajectory_t& trj, int& idx) const;
294  Point_t ClosestPt(const Trajectory_t& trj, const Point_t& 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(const Point_t& pt,
304  const std::vector<geoalgo::Trajectory_t>& trj,
305  int& trackIdx) const;
307  double SqDist(const std::vector<geoalgo::Trajectory_t>& trj,
308  const Point_t& pt,
309  int& trackIdx) const
310  {
311  return SqDist(pt, trj, trackIdx);
312  }
314  double SqDist(const Point_t& 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, const Point_t& pt) const
321  {
322  int trackIdx;
323  return SqDist(pt, trj, trackIdx);
324  }
326  Point_t ClosestPt(const Point_t& 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  const Point_t& pt,
332  int& trackIdx) const
333  {
334  return ClosestPt(pt, trj, trackIdx);
335  }
337  Point_t ClosestPt(const Point_t& 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, const Point_t& 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(const Point_t& pt, const LineSegment_t& line) const
354  {
355  pt.compat(line.Start());
356  return _SqDist_(pt, line);
357  }
359  double SqDist(const LineSegment_t& line, const Point_t& pt) const { return SqDist(pt, line); }
361  Point_t ClosestPt(const Point_t& pt, const LineSegment_t& line) const
362  {
363  pt.compat(line.Start());
364  return _ClosestPt_(pt, line);
365  }
367  Point_t ClosestPt(const LineSegment_t& line, const Point_t& pt) const
368  {
369  return ClosestPt(pt, line);
370  }
371 
372  //********************************************
373  //CLOSEST APPROACH BETWEEN POINT AND HALF LINE
374  //********************************************
376  double SqDist(const Point_t& pt, const HalfLine_t& line) const
377  {
378  pt.compat(line.Start());
379  return _SqDist_(pt, line);
380  }
382  double SqDist(const HalfLine_t& line, const Point_t& pt) const { return SqDist(pt, line); }
384  Point_t ClosestPt(const Point_t& pt, const HalfLine_t& line) const
385  {
386  pt.compat(line.Start());
387  return _ClosestPt_(pt, line);
388  }
390  Point_t ClosestPt(const HalfLine_t& line, const Point_t& 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(const HalfLine_t& hline, const LineSegment_t& 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(const LineSegment_t& seg, const HalfLine_t& 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(const HalfLine_t& hline, const LineSegment_t& 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(const LineSegment_t& seg, const HalfLine_t& hline) const
418  {
419  return SqDist(hline, seg);
420  }
421 
422  //***************************************************
423  //CLOSEST APPROACH BETWEEN POINT AND AXIS ALIGNED BOX
424  //***************************************************
426  double SqDist(const Point_t& pt, const AABox_t& box) const
427  {
428  pt.compat(box.Min());
429  return _SqDist_(pt, box);
430  }
432  double SqDist(const AABox_t& box, const Point_t& pt) { return SqDist(pt, box); }
434  Point_t ClosestPt(const Point_t& pt, const AABox_t& box) const
435  {
436  pt.compat(box.Min());
437  return _ClosestPt_(pt, box);
438  }
440  Point_t ClosestPt(const AABox_t& box, const Point_t& 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(const Line_t& lin1, const Line_t& lin2) const
447  {
448  Point_t origin(lin1.Pt1().size());
449  return commonOrigin(lin1, lin2, origin);
450  }
452  double commonOrigin(const Line_t& lin1, const Line_t& lin2, Point_t& origin) const
453  {
454  lin1.Pt1().compat(lin2.Pt1());
455  return _commonOrigin_(lin1, lin2, origin);
456  }
458  double commonOrigin(const LineSegment_t& seg1,
459  const LineSegment_t& 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(const LineSegment_t& seg1,
467  const LineSegment_t& 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(const HalfLine_t& lin,
476  const LineSegment_t& 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(const HalfLine_t& lin,
484  const LineSegment_t& 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(const LineSegment_t& seg,
493  const HalfLine_t& 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(const LineSegment_t& seg,
501  const HalfLine_t& 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(const HalfLine_t& lin1,
510  const HalfLine_t& 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(const HalfLine_t& lin1,
518  const HalfLine_t& 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(const Trajectory_t& trj1,
527  const Trajectory_t& 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(const Trajectory_t& trj1,
535  const Trajectory_t& 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(const Trajectory_t& trj,
544  const HalfLine_t& 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(const Trajectory_t& trj,
552  const HalfLine_t& 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(const HalfLine_t& lin,
561  const Trajectory_t& 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(const HalfLine_t& lin,
569  const Trajectory_t& 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(const Trajectory_t& trj,
578  const LineSegment_t& 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(const Trajectory_t& trj,
586  const LineSegment_t& 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(const LineSegment_t& seg,
595  const Trajectory_t& 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(const LineSegment_t& seg,
603  const Trajectory_t& 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_(const Line_t& l1, const Line_t& l2, Point_t& L1, Point_t& L2) const;
626 
628  double _SqDist_(const HalfLine_t& l1, const HalfLine_t& l2, Point_t& L1, Point_t& L2) const;
629 
631  double _SqDist_(const Point_t& pt, const LineSegment_t& line) const
632  {
633  return _SqDist_(pt, line.Start(), line.End());
634  }
635 
637  double _SqDist_(const Point_t& pt, const Point_t& line_s, const Point_t& line_e) const;
638 
640  double _SqDist_(const LineSegment_t& line, const Point_t& pt) const
641  {
642  return _SqDist_(pt, line);
643  }
644 
646  double _SqDist_(const HalfLine_t& hline,
647  const LineSegment_t& seg,
648  Point_t& L1,
649  Point_t& L2) const;
650 
652  double _SqDist_(const LineSegment_t& seg1,
653  const LineSegment_t& seg2,
654  Point_t& c1,
655  Point_t& c2) const;
656 
657  // Point & LineSegment closest point w/o dimensionality check
658  Point_t _ClosestPt_(const Point_t& pt, const LineSegment_t& line) const;
659  // Point & LineSegment closest point w/o dimensionality check
660  Point_t _ClosestPt_(const LineSegment_t& line, const Point_t& pt) const
661  {
662  return _ClosestPt_(pt, line);
663  }
664 
666  double _SqDist_(const Point_t& pt, const HalfLine_t& line) const;
668  double _SqDist_(const HalfLine_t& line, const Point_t& pt) const { return _SqDist_(pt, line); }
669  // Point & HalfLine closest point w/o dimensionality check
670  Point_t _ClosestPt_(const Point_t& pt, const HalfLine_t& line) const;
671  // Point & HalfLine closest point w/o dimensionality check
672  Point_t _ClosestPt_(const HalfLine_t& line, const Point_t& pt) const
673  {
674  return _ClosestPt_(pt, line);
675  }
676 
677  // Point & InfLine closest point w/o dimensionality check
678  Point_t _ClosestPt_(const Line_t& line, const Point_t& pt) const;
679  // Point & InfLine closest point w/o dimensionality check
680  Point_t _ClosestPt_(const Point_t& pt, const Line_t& line) const
681  {
682  return _ClosestPt_(line, pt);
683  }
684  // Point & InfLine distance w/o dimensionality check
685  double _SqDist_(const Line_t& line, const Point_t& pt) const;
686  // Point & InfLine distance w/o dimensionality check
687  double _SqDist_(const Point_t& pt, const Line_t& line) const { return _SqDist_(line, pt); }
688 
690  double _SqDist_(const Point_t& pt, const AABox_t& box) const;
692  double _SqDist_(const AABox_t& box, const Point_t& pt) const { return _SqDist_(pt, box); }
693 
695  Point_t _ClosestPt_(const Point_t& pt, const AABox_t& box) const;
697  Point_t _ClosestPt_(const AABox_t& box, const Point_t& pt) const
698  {
699  return _ClosestPt_(pt, box);
700  }
701 
703  double _commonOrigin_(const Line_t& lin1, const Line_t& lin2, Point_t& origin) const;
705  double _commonOrigin_(const HalfLine_t& lin1,
706  const HalfLine_t& lin2,
707  Point_t& origin,
708  bool backwards) const;
710  double _commonOrigin_(const HalfLine_t& lin,
711  const LineSegment_t& seg,
712  Point_t& origin,
713  bool backwards) const;
715  double _commonOrigin_(const LineSegment_t& seg1,
716  const LineSegment_t& seg2,
717  Point_t& origin,
718  bool backwards) const;
720  double _commonOrigin_(const Trajectory_t& trj1,
721  const Trajectory_t& trj2,
722  Point_t& origin,
723  bool backwards) const;
725  double _commonOrigin_(const Trajectory_t& trj,
726  const LineSegment_t& seg,
727  Point_t& origin,
728  bool backwards) const;
730  double _commonOrigin_(const Trajectory_t& trj,
731  const HalfLine_t& 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, const Sphere_t& 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_(const double n, const double min, const double 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
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:602
Point_t ClosestPt(const Point_t &pt, const Line_t &line) const
Definition: GeoAlgo.h:112
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:585
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:222
Point_t ClosestPt(const AABox_t &box, const Point_t &pt) const
Point & AABox closest point.
Definition: GeoAlgo.h:440
double SqDist(const HalfLine_t &line, const Point_t &pt) const
Point & HalfLine distance.
Definition: GeoAlgo.h:382
Point_t ClosestPt(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:106
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:193
double SqDist(const AABox_t &box, const Point_t &pt)
Point & AABox distance.
Definition: GeoAlgo.h:432
double SqDist(const Point_t &pt, const LineSegment_t &line) const
Point & LineSegment_t distance.
Definition: GeoAlgo.h:353
Algorithm to compute various geometrical relation among geometrical objects. In particular functions ...
Definition: GeoAlgo.h:43
const Point_t & Start() const
Start getter.
Definition: GeoHalfLine.cxx:28
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:337
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:343
double SqDist(const LineSegment_t &line, const Point_t &pt) const
Point & LineSegment distance.
Definition: GeoAlgo.h:359
double SqDist(const LineSegment_t &seg, const HalfLine_t &hline, Point_t &L1, Point_t &L2) const
Definition: GeoAlgo.h:405
double SqDist(const LineSegment_t &seg1, const LineSegment_t &seg2) const
LineSegment & LineSegment, don&#39;t keep track of points.
Definition: GeoAlgo.h:161
double _Clamp_(const double n, const double min, const double max) const
Clamp function: checks if value out of bounds.
Definition: GeoAlgo.cxx:852
Point_t ClosestPt(const Point_t &pt, const LineSegment_t &line) const
Point & LineSegment closest point.
Definition: GeoAlgo.h:361
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:560
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:239
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:746
Point_t ClosestPt(const Point_t &pt, const HalfLine_t &line) const
Point & HalfLine closest point.
Definition: GeoAlgo.h:384
double SqDist(const HalfLine_t &l1, const HalfLine_t &l2, Point_t &L1, Point_t &L2) const
Definition: GeoAlgo.h:135
Point_t _ClosestPt_(const LineSegment_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:660
double SqDist(const Trajectory_t &trj, const HalfLine_t &hline) const
HalfLine & Trajectory, don&#39;t keep track of points.
Definition: GeoAlgo.h:258
double SqDist(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:98
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:152
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:177
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:483
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:314
Class def header for a class Line.
void compat(const Vector &obj) const
Dimensional check for a compatibility.
Definition: GeoVector.cxx:128
double _SqDist_(const HalfLine_t &line, const Point_t &pt) const
Point & HalfLine distance w/o dimensionality check.
Definition: GeoAlgo.h:668
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:543
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:492
double SqDist(const Line_t &l1, const Line_t &l2) const
Definition: GeoAlgo.h:124
double SqDist(const HalfLine_t &hline, const Trajectory_t &trj) const
HalfLine & Trajectory, don&#39;t keep track of points.
Definition: GeoAlgo.h:265
const Point_t & Min() const
Minimum point getter.
Definition: GeoAABox.cxx:23
Class def header for a class AABox.
Sphere_t boundingSphere(const std::vector< Point_t > &pts) const
Definition: GeoAlgo.h:615
Point_t _ClosestPt_(const Point_t &pt, const Line_t &line) const
Definition: GeoAlgo.h:680
Point_t ClosestPt(const HalfLine_t &line, const Point_t &pt) const
Point & HalfLine closest point.
Definition: GeoAlgo.h:390
double SqDist(const Point_t &pt, const AABox_t &box) const
Point & AABox distance.
Definition: GeoAlgo.h:426
Point_t ClosestPt(const Trajectory_t &trj, const Point_t &pt) const
Point_t & Trajectory_t closest point.
Definition: GeoAlgo.h:286
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:452
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:307
Class def header for a class Point and Vector.
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:568
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:594
double SqDist(const Trajectory_t &trj, const LineSegment_t &seg) const
LineSegment & Trajectory, don&#39;t keep track of points.
Definition: GeoAlgo.h:182
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:330
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:526
double SqDist(const Trajectory_t &trj, const Point_t &pt) const
Point_t & Trajectory_t distance.
Definition: GeoAlgo.h:278
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:446
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:55
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:434
Point_t ClosestPt(const Point_t &pt, const Trajectory_t &trj) const
Point_t & Trajectory_t closest point.
Definition: GeoAlgo.h:280
Sphere_t _WelzlSphere_(const std::vector< Point_t > &pts, int numPts, std::vector< Point_t > sosPts) const
Definition: GeoAlgo.cxx:1114
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:517
double SqDist(const HalfLine_t &hline, const LineSegment_t &seg, Point_t &L1, Point_t &L2) const
Definition: GeoAlgo.h:399
double SqDist(const Line_t &l1, const Line_t &l2, Point_t &L1, Point_t &L2) const
Definition: GeoAlgo.h:118
double SqDist(const Point_t &pt, const Line_t &line) const
Definition: GeoAlgo.h:104
const Point_t & Start() const
Start getter.
Sphere_t _boundingSphere_(const std::vector< Point_t > &pts) const
Definition: GeoAlgo.cxx:1033
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:577
double _SqDist_(const Point_t &pt, const LineSegment_t &line) const
Point & LineSegment distance w/o dimensionality check.
Definition: GeoAlgo.h:631
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:294
double _SqDist_(const AABox_t &box, const Point_t &pt) const
Point & AABox distance w/o dimensionality check.
Definition: GeoAlgo.h:692
double SqDist(const LineSegment_t &seg, const Trajectory_t &trj) const
LineSegment & Trajectory, don&#39;t keep track of points.
Definition: GeoAlgo.h:189
Point_t ClosestPt(const LineSegment_t &line, const Point_t &pt) const
Point & LineSegment closest point.
Definition: GeoAlgo.h:367
Representation of a 3D semi-infinite line. Defines a semi-infinite 3D line by having a start point (P...
Definition: GeoHalfLine.h:30
Sphere_t _RemainingPoints_(std::vector< Point_t > &remaining, const Sphere_t &thisSphere) const
Definition: GeoAlgo.cxx:1070
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:458
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:672
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:466
double SqDist(const LineSegment_t &seg, const HalfLine_t &hline) const
Definition: GeoAlgo.h:417
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:231
void compat(const Point_t &p, const double r=0) const
3D point compatibility check
Definition: GeoSphere.cxx:371
double _SqDist_(const Point_t &pt, const Line_t &line) const
Definition: GeoAlgo.h:687
double SqDist(const HalfLine_t &l1, const HalfLine_t &l2) const
Definition: GeoAlgo.h:141
LineSegment_t BoxOverlap(const AABox_t &box, const HalfLine_t &line) const
LineSegment sub-segment of HalfLine inside an AABox.
Definition: GeoAlgo.cxx:168
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:320
double SqDist(const Trajectory_t &trj1, const Trajectory_t &trj2) const
Trajectory & Trajectory, don&#39;t keep track of points.
Definition: GeoAlgo.h:205
LineSegment_t BoxOverlap(const HalfLine_t &line, const AABox_t &box) const
LineSegment sub-segment of HalfLine inside an AABox.
Definition: GeoAlgo.h:81
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:500
Point_t _ClosestPt_(const AABox_t &box, const Point_t &pt) const
Point & AABox closest point w/o dimensionality check.
Definition: GeoAlgo.h:697
double SqDist(const Point_t &pt, const HalfLine_t &line) const
Point & HalfLine distance.
Definition: GeoAlgo.h:376
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:475
double _SqDist_(const LineSegment_t &line, const Point_t &pt) const
Point & LineSegment distance w/o dimensionality check.
Definition: GeoAlgo.h:640
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:11
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:253
double SqDist(const HalfLine_t &hline, const LineSegment_t &seg) const
Definition: GeoAlgo.h:410
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:551
std::vector< Point_t > Intersection(const Trajectory_t &trj, const AABox_t &box) const
Intersection between Trajectory and an AABox.
Definition: GeoAlgo.h:73
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:860
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:534
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
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:89
Point_t _ClosestPt_(const Point_t &pt, const LineSegment_t &line) const
Definition: GeoAlgo.cxx:390
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:509