LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
geoalgo::GeoAlgo Class Reference

Algorithm to compute various geometrical relation among geometrical objects. In particular functions to inspect following relations are implemented:
0) Distance between geometrical objects
1) Closest point of approach
2) Intersection points
3) Containment/Overlap of objects
4) Common Origin functions
5) Bounding Sphere functions
. More...

#include "GeoAlgo.h"

Public Member Functions

std::vector< Point_tIntersection (const AABox_t &box, const HalfLine_t &line, bool back=false) const
 Intersection between a HalfLine and an AABox. More...
 
std::vector< Point_tIntersection (const HalfLine_t &line, const AABox_t &box, bool back=false) const
 Intersection between a HalfLine and an AABox. More...
 
std::vector< Point_tIntersection (const AABox_t &box, const LineSegment_t &l) const
 Intersection between LineSegment and an AABox. More...
 
std::vector< Point_tIntersection (const LineSegment_t &l, const AABox_t &box) const
 Intersection between LineSegment and an AABox. More...
 
std::vector< Point_tIntersection (const AABox_t &box, const Trajectory_t &trj) const
 Intersection between Trajectory and an AABox. More...
 
std::vector< Point_tIntersection (const Trajectory_t &trj, const AABox_t &box) const
 Intersection between Trajectory and an AABox. More...
 
LineSegment_t BoxOverlap (const AABox_t &box, const HalfLine_t &line) const
 LineSegment sub-segment of HalfLine inside an AABox. More...
 
LineSegment_t BoxOverlap (const HalfLine_t &line, const AABox_t &box) const
 LineSegment sub-segment of HalfLine inside an AABox. More...
 
Trajectory_t BoxOverlap (const AABox_t &box, const Trajectory_t &trj) const
 Get Trajectory inside box given some input trajectory -> now assumes trajectory cannot exit and re-enter box. More...
 
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-enter box. More...
 
double SqDist (const Line_t &line, const Point_t &pt) const
 
double SqDist (const Point_t &pt, const Line_t &line) const
 
Point_t ClosestPt (const Line_t &line, const Point_t &pt) const
 
Point_t ClosestPt (const Point_t &pt, const Line_t &line) const
 
double SqDist (const Line_t &l1, const Line_t &l2, Point_t &L1, Point_t &L2) const
 
double SqDist (const Line_t &l1, const Line_t &l2) const
 
double SqDist (const HalfLine_t &l1, const HalfLine_t &l2, Point_t &L1, Point_t &L2) const
 
double SqDist (const HalfLine_t &l1, const HalfLine_t &l2) const
 
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. More...
 
double SqDist (const LineSegment_t &seg1, const LineSegment_t &seg2) const
 LineSegment & LineSegment, don't keep track of points. More...
 
double SqDist (const LineSegment_t &seg, const Trajectory_t &trj, Point_t &c1, Point_t &c2) const
 LineSegment & Trajectory, keep track of points. More...
 
double SqDist (const Trajectory_t &trj, const LineSegment_t &seg, Point_t &c1, Point_t &c2) const
 LineSegment & Trajectory, keep track of points. More...
 
double SqDist (const Trajectory_t &trj, const LineSegment_t &seg) const
 LineSegment & Trajectory, don't keep track of points. More...
 
double SqDist (const LineSegment_t &seg, const Trajectory_t &trj) const
 LineSegment & Trajectory, don't keep track of points. More...
 
double SqDist (const Trajectory_t &trj1, const Trajectory_t &trj2, Point_t &c1, Point_t &c2) const
 Trajectory & Trajectory, keep track of points. More...
 
double SqDist (const Trajectory_t &trj1, const Trajectory_t &trj2) const
 Trajectory & Trajectory, don't keep track of points. More...
 
double SqDist (const LineSegment_t &seg, const std::vector< geoalgo::Trajectory_t > &trj, Point_t &c1, Point_t &c2, int &trackIdx) const
 LineSegment & vector of Trajectories, keep track of points. More...
 
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. More...
 
double SqDist (const std::vector< geoalgo::Trajectory_t > &trj, const LineSegment_t &seg) const
 LineSegment & vector of Trajectories, don't keep track of points. More...
 
double SqDist (const LineSegment_t &seg, const std::vector< geoalgo::Trajectory_t > &trj) const
 LineSegment & vector of Trajectories, don't keep track of points. More...
 
double SqDist (const HalfLine_t &hline, const Trajectory_t &trj, Point_t &c1, Point_t &c2) const
 HalfLine & Trajectory, keep track of points. More...
 
double SqDist (const Trajectory_t &trj, const HalfLine_t &hline, Point_t &c1, Point_t &c2) const
 HalfLine & Trajectory, keep track of points. More...
 
double SqDist (const Trajectory_t &trj, const HalfLine_t &hline) const
 HalfLine & Trajectory, don't keep track of points. More...
 
double SqDist (const HalfLine_t &hline, const Trajectory_t &trj) const
 HalfLine & Trajectory, don't keep track of points. More...
 
double SqDist (const Point_t &pt, const Trajectory_t &trj) const
 Point_t & Trajectory_t distance. More...
 
double SqDist (const Trajectory_t &trj, const Point_t &pt) const
 Point_t & Trajectory_t distance. More...
 
Point_t ClosestPt (const Point_t &pt, const Trajectory_t &trj) const
 Point_t & Trajectory_t closest point. More...
 
Point_t ClosestPt (const Trajectory_t &trj, const Point_t &pt) const
 Point_t & Trajectory_t closest point. More...
 
Point_t ClosestPt (const Point_t &pt, const Trajectory_t &trj, int &idx) const
 Point_t & Trajectory_t closest point. Keep track of index of segment. More...
 
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. More...
 
double SqDist (const Point_t &pt, const std::vector< geoalgo::Trajectory_t > &trj, int &trackIdx) const
 Point_t & Trajectory_t distance - keep track of which track. More...
 
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. More...
 
double SqDist (const Point_t &pt, const std::vector< geoalgo::Trajectory_t > &trj) const
 Point_t & Trajectory_t distance - don't keep track. More...
 
double SqDist (const std::vector< geoalgo::Trajectory_t > &trj, const Point_t &pt) const
 Point_t & Trajectory_t distance - don't keep track. More...
 
Point_t ClosestPt (const Point_t &pt, const std::vector< geoalgo::Trajectory_t > &trj, int &trackIdx) const
 Point_t & Trajectory_t closest point - keep track of which track is closest. More...
 
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. More...
 
Point_t ClosestPt (const Point_t &pt, const std::vector< geoalgo::Trajectory_t > &trj) const
 Point_t & Trajectory_t closest point - don't keep track of which track is closest. More...
 
Point_t ClosestPt (const std::vector< geoalgo::Trajectory_t > &trj, const Point_t &pt) const
 Point_t & Trajectory_t closest point - don't keep track of which track is closest. More...
 
double SqDist (const Point_t &pt, const LineSegment_t &line) const
 Point & LineSegment_t distance. More...
 
double SqDist (const LineSegment_t &line, const Point_t &pt) const
 Point & LineSegment distance. More...
 
Point_t ClosestPt (const Point_t &pt, const LineSegment_t &line) const
 Point & LineSegment closest point. More...
 
Point_t ClosestPt (const LineSegment_t &line, const Point_t &pt) const
 Point & LineSegment closest point. More...
 
double SqDist (const Point_t &pt, const HalfLine_t &line) const
 Point & HalfLine distance. More...
 
double SqDist (const HalfLine_t &line, const Point_t &pt) const
 Point & HalfLine distance. More...
 
Point_t ClosestPt (const Point_t &pt, const HalfLine_t &line) const
 Point & HalfLine closest point. More...
 
Point_t ClosestPt (const HalfLine_t &line, const Point_t &pt) const
 Point & HalfLine closest point. More...
 
double SqDist (const HalfLine_t &hline, const LineSegment_t &seg, Point_t &L1, Point_t &L2) const
 
double SqDist (const LineSegment_t &seg, const HalfLine_t &hline, Point_t &L1, Point_t &L2) const
 
double SqDist (const HalfLine_t &hline, const LineSegment_t &seg) const
 
double SqDist (const LineSegment_t &seg, const HalfLine_t &hline) const
 
double SqDist (const Point_t &pt, const AABox_t &box) const
 Point & AABox distance. More...
 
double SqDist (const AABox_t &box, const Point_t &pt)
 Point & AABox distance. More...
 
Point_t ClosestPt (const Point_t &pt, const AABox_t &box) const
 Point & AABox closest point. More...
 
Point_t ClosestPt (const AABox_t &box, const Point_t &pt) const
 Point & AABox closest point. More...
 
double commonOrigin (const Line_t &lin1, const Line_t &lin2) const
 Common origin: Line Segment & Line Segment. Do not keep track of origin. More...
 
double commonOrigin (const Line_t &lin1, const Line_t &lin2, Point_t &origin) const
 Common origin: Line Segment & Line Segment. Keep track of origin. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
double commonOrigin (const Trajectory_t &trj1, const Trajectory_t &trj2, bool backwards=false) const
 Common origin: Trajectory & Trajectory. Do not keep track of origin. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
Sphere_t boundingSphere (const std::vector< Point_t > &pts) const
 

Protected Member Functions

double _SqDist_ (const Line_t &l1, const Line_t &l2, Point_t &L1, Point_t &L2) const
 Line & Line distance w/o dimensionality check. More...
 
double _SqDist_ (const HalfLine_t &l1, const HalfLine_t &l2, Point_t &L1, Point_t &L2) const
 HalfLine & HalfLine distance w/o dimensionality check. More...
 
double _SqDist_ (const Point_t &pt, const LineSegment_t &line) const
 Point & LineSegment distance w/o dimensionality check. More...
 
double _SqDist_ (const Point_t &pt, const Point_t &line_s, const Point_t &line_e) const
 Point & LineSegment distance w/o dimensionality check. More...
 
double _SqDist_ (const LineSegment_t &line, const Point_t &pt) const
 Point & LineSegment distance w/o dimensionality check. More...
 
double _SqDist_ (const HalfLine_t &hline, const LineSegment_t &seg, Point_t &L1, Point_t &L2) const
 HalfLine & LineSegment distance w/o dimensionality check. More...
 
double _SqDist_ (const LineSegment_t &seg1, const LineSegment_t &seg2, Point_t &c1, Point_t &c2) const
 LineSegment & LineSegment distance w/o dimensionality check. More...
 
Point_t _ClosestPt_ (const Point_t &pt, const LineSegment_t &line) const
 
Point_t _ClosestPt_ (const LineSegment_t &line, const Point_t &pt) const
 
double _SqDist_ (const Point_t &pt, const HalfLine_t &line) const
 Point & HalfLine distance w/o dimensionality check. More...
 
double _SqDist_ (const HalfLine_t &line, const Point_t &pt) const
 Point & HalfLine distance w/o dimensionality check. More...
 
Point_t _ClosestPt_ (const Point_t &pt, const HalfLine_t &line) const
 
Point_t _ClosestPt_ (const HalfLine_t &line, const Point_t &pt) const
 
Point_t _ClosestPt_ (const Line_t &line, const Point_t &pt) const
 
Point_t _ClosestPt_ (const Point_t &pt, const Line_t &line) const
 
double _SqDist_ (const Line_t &line, const Point_t &pt) const
 
double _SqDist_ (const Point_t &pt, const Line_t &line) const
 
double _SqDist_ (const Point_t &pt, const AABox_t &box) const
 Point & AABox distance w/o dimensionality check. More...
 
double _SqDist_ (const AABox_t &box, const Point_t &pt) const
 Point & AABox distance w/o dimensionality check. More...
 
Point_t _ClosestPt_ (const Point_t &pt, const AABox_t &box) const
 Point & AABox closest point w/o dimensionality check. More...
 
Point_t _ClosestPt_ (const AABox_t &box, const Point_t &pt) const
 Point & AABox closest point w/o dimensionality check. More...
 
double _commonOrigin_ (const Line_t &lin1, const Line_t &lin2, Point_t &origin) const
 Common origin: Line & Line. Keep track of origin. More...
 
double _commonOrigin_ (const HalfLine_t &lin1, const HalfLine_t &lin2, Point_t &origin, bool backwards) const
 Common origin: Half Line & Half Line. Keep track of origin. More...
 
double _commonOrigin_ (const HalfLine_t &lin, const LineSegment_t &seg, Point_t &origin, bool backwards) const
 Common origin: Line Segment & Half Line. Keep track of origin. More...
 
double _commonOrigin_ (const LineSegment_t &seg1, const LineSegment_t &seg2, Point_t &origin, bool backwards) const
 Common origin: Line Segment & Line Segment. Keep track of origin. More...
 
double _commonOrigin_ (const Trajectory_t &trj1, const Trajectory_t &trj2, Point_t &origin, bool backwards) const
 Common origin: Trajectory & Trajectory. Keep track of origin. More...
 
double _commonOrigin_ (const Trajectory_t &trj, const LineSegment_t &seg, Point_t &origin, bool backwards) const
 Common origin: Trajectory & Line Segment. Keep track of origin. More...
 
double _commonOrigin_ (const Trajectory_t &trj, const HalfLine_t &lin, Point_t &origin, bool backwards) const
 Common origin: Trajectory & Half Line. Keep track of origin. More...
 
Sphere_t _boundingSphere_ (const std::vector< Point_t > &pts) const
 
Sphere_t _RemainingPoints_ (std::vector< Point_t > &remaining, const Sphere_t &thisSphere) const
 
Sphere_t _WelzlSphere_ (const std::vector< Point_t > &pts, int numPts, std::vector< Point_t > sosPts) const
 
double _Clamp_ (const double n, const double min, const double max) const
 Clamp function: checks if value out of bounds. More...
 
void _Swap_ (double &tmin, double &tmax) const
 Swap two points if min & max are inverted. More...
 

Detailed Description

Algorithm to compute various geometrical relation among geometrical objects. In particular functions to inspect following relations are implemented:
0) Distance between geometrical objects
1) Closest point of approach
2) Intersection points
3) Containment/Overlap of objects
4) Common Origin functions
5) Bounding Sphere functions
.

Most functions are taken from the reference Real-Time-Collision-Detection (RTCD): Ref: http://realtimecollisiondetection.net

Definition at line 43 of file GeoAlgo.h.

Member Function Documentation

Sphere_t geoalgo::GeoAlgo::_boundingSphere_ ( const std::vector< Point_t > &  pts) const
protected

Bounding Sphere problem Real-Time Collision Analysis 4.3.5 (Pg. 100) - WelzlSphere

Definition at line 1033 of file GeoAlgo.cxx.

References _RemainingPoints_().

Referenced by _ClosestPt_(), and boundingSphere().

1034  {
1035 
1036  // Remove any duplicate points
1037  std::vector<Point_t> copyPts = {pts[0]};
1038  for (size_t p1 = 0; p1 < pts.size(); p1++) {
1039  // if an identical point does not already exist in copyPts -> then add
1040  bool found = false;
1041  for (size_t p2 = 0; p2 < copyPts.size(); p2++)
1042  if (pts[p1] == copyPts[p2]) {
1043  found = true;
1044  break;
1045  }
1046  if (!found) copyPts.push_back(pts[p1]);
1047  }
1048 
1049  // if 4 or less points call appropriate constructor
1050  if (copyPts.size() < 5) return Sphere_t(copyPts);
1051 
1052  size_t npoints = copyPts.size();
1053  std::vector<Point_t> points4 = {
1054  copyPts[npoints - 1], copyPts[npoints - 2], copyPts[npoints - 3], copyPts[npoints - 4]};
1055  copyPts.pop_back();
1056  copyPts.pop_back();
1057  copyPts.pop_back();
1058  copyPts.pop_back();
1059  Sphere_t tmpSphere = Sphere(points4);
1060  return _RemainingPoints_(copyPts, tmpSphere);
1061 
1062  // too many points to call simple constructor! find minimally bounding sphere
1063  // compute sphere for first 4 points
1064  //Sphere_t tmpSphere(copyPts[0],copyPts[1],copyPts[2],copyPts[3]);
1065  //std::vector<Point_t> sosPoints;// = {pts[0]};
1066  //sosPoints.clear();
1067  //return _WelzlSphere_(copyPts,copyPts.size(),sosPoints);
1068  }
Sphere_t _RemainingPoints_(std::vector< Point_t > &remaining, const Sphere_t &thisSphere) const
Definition: GeoAlgo.cxx:1070
Sphere Sphere_t
Definition: GeoSphere.h:126
double geoalgo::GeoAlgo::_Clamp_ ( const double  n,
const double  min,
const double  max 
) const
protected

Clamp function: checks if value out of bounds.

Definition at line 852 of file GeoAlgo.cxx.

References n.

Referenced by _ClosestPt_(), and _SqDist_().

853  {
854  if (n < min) { return min; }
855  if (n > max) { return max; }
856  return n;
857  }
Char_t n[5]
Point_t geoalgo::GeoAlgo::_ClosestPt_ ( const Point_t pt,
const LineSegment_t line 
) const
protected

Definition at line 390 of file GeoAlgo.cxx.

References geoalgo::LineSegment::Dir(), geoalgo::LineSegment::End(), geoalgo::Vector::SqLength(), and geoalgo::LineSegment::Start().

Referenced by _ClosestPt_(), _SqDist_(), and ClosestPt().

391  {
392 
393  auto const& ab = line.Dir();
394  // Project pt on line (ab), but deferring divide by ab * ab
395  auto t = ((pt - line.Start()) * ab);
396  // pt projects outside line, on the start side; clamp to start
397  if (t <= 0.)
398  return line.Start();
399  else {
400  auto denom = ab.SqLength();
401  // pt projects outside line, on the end side; clamp to end
402  if (t >= denom) return line.End();
403  // pt projects inside the line. must deferred divide now
404  else
405  return (line.Start() + ab * (t / denom));
406  }
407  }
TMarker * pt
Definition: egs.C:25
Point_t geoalgo::GeoAlgo::_ClosestPt_ ( const LineSegment_t line,
const Point_t pt 
) const
inlineprotected

Definition at line 660 of file GeoAlgo.h.

References _ClosestPt_(), and _SqDist_().

661  {
662  return _ClosestPt_(pt, line);
663  }
TMarker * pt
Definition: egs.C:25
Point_t _ClosestPt_(const Point_t &pt, const LineSegment_t &line) const
Definition: GeoAlgo.cxx:390
Point_t geoalgo::GeoAlgo::_ClosestPt_ ( const Point_t pt,
const HalfLine_t line 
) const
protected

Definition at line 423 of file GeoAlgo.cxx.

References geoalgo::HalfLine::Dir(), geoalgo::Vector::Length(), and geoalgo::HalfLine::Start().

424  {
425  auto const& ab = line.Dir();
426  auto t = (pt - line.Start()) * ab;
427  if (t <= 0.)
428  return line.Start();
429  else {
430  auto denom = ab.Length();
431  return (line.Start() + ab * (t / denom));
432  }
433  }
TMarker * pt
Definition: egs.C:25
Point_t geoalgo::GeoAlgo::_ClosestPt_ ( const HalfLine_t line,
const Point_t pt 
) const
inlineprotected

Definition at line 672 of file GeoAlgo.h.

References _ClosestPt_().

673  {
674  return _ClosestPt_(pt, line);
675  }
TMarker * pt
Definition: egs.C:25
Point_t _ClosestPt_(const Point_t &pt, const LineSegment_t &line) const
Definition: GeoAlgo.cxx:390
Point_t geoalgo::GeoAlgo::_ClosestPt_ ( const Line_t line,
const Point_t pt 
) const
protected

Definition at line 448 of file GeoAlgo.cxx.

References geoalgo::Vector::Length(), geoalgo::Line::Pt1(), and geoalgo::Line::Pt2().

449  {
450  auto const& ab = line.Pt2() - line.Pt1();
451  auto t = (pt - line.Pt1()) * ab;
452  auto denom = ab.Length();
453  return (line.Pt1() + ab * (t / denom));
454  }
TMarker * pt
Definition: egs.C:25
Point_t geoalgo::GeoAlgo::_ClosestPt_ ( const Point_t pt,
const Line_t line 
) const
inlineprotected

Definition at line 680 of file GeoAlgo.h.

References _ClosestPt_(), and _SqDist_().

681  {
682  return _ClosestPt_(line, pt);
683  }
TMarker * pt
Definition: egs.C:25
Point_t _ClosestPt_(const Point_t &pt, const LineSegment_t &line) const
Definition: GeoAlgo.cxx:390
Point_t geoalgo::GeoAlgo::_ClosestPt_ ( const Point_t pt,
const AABox_t box 
) const
protected

Point & AABox closest point w/o dimensionality check.

Definition at line 502 of file GeoAlgo.cxx.

References geoalgo::AABox::Max(), geoalgo::AABox::Min(), and pt.

503  {
504  // Result
505  auto res = pt;
506  // For each coordinate axis, if the point coordinate value is outside box,
507  // clamp it to the box, else keep it as is
508  for (size_t i = 0; i < pt.size(); ++i) {
509  auto const& v_pt = pt[i];
510  auto const& v_min = box.Min()[i];
511  auto const& v_max = box.Max()[i];
512  res[i] = v_pt;
513  if (v_pt < v_min) res[i] = v_min;
514  if (v_pt > v_max) res[i] = v_max;
515  }
516  return res;
517  }
TMarker * pt
Definition: egs.C:25
Point_t geoalgo::GeoAlgo::_ClosestPt_ ( const AABox_t box,
const Point_t pt 
) const
inlineprotected

Point & AABox closest point w/o dimensionality check.

Definition at line 697 of file GeoAlgo.h.

References _boundingSphere_(), _Clamp_(), _ClosestPt_(), _commonOrigin_(), _RemainingPoints_(), _WelzlSphere_(), n, and geo::origin().

698  {
699  return _ClosestPt_(pt, box);
700  }
TMarker * pt
Definition: egs.C:25
Point_t _ClosestPt_(const Point_t &pt, const LineSegment_t &line) const
Definition: GeoAlgo.cxx:390
double geoalgo::GeoAlgo::_commonOrigin_ ( const Line_t lin1,
const Line_t lin2,
Point_t origin 
) const
protected

Common origin: Line & Line. Keep track of origin.

Common origin: Half Line & Half Line. Keep track of origin.

Definition at line 860 of file GeoAlgo.cxx.

References geoalgo::Vector::Dot(), geoalgo::Vector::Normalize(), geo::origin(), geoalgo::Line::Pt1(), pt1, geoalgo::Line::Pt2(), and pt2.

Referenced by _ClosestPt_(), _commonOrigin_(), and commonOrigin().

861  {
862 
863  // Function Description:
864  // Given two HalfLine objects, project them backwards
865  // and find the point of closest approach on both
866  // lines.
867  // The half-point between these two is considered the
868  // candidate origin or vertex of the two lines
869  // Then make segments uniting this vertex and
870  // the start point of both half lines.
871  // Take the dot product of the segment uniting
872  // the vertex with the start of lin1, and the direction
873  // of lin1. Similarly for lin2.
874  // These dot-products will be close to 1 if the lines,
875  // traced backwards, indeed point to the reconstructed
876  // vertex.
877  // return the sum of these dot products, which
878  // is bound between -2 and +2.
879  // other values of this return (1, 0, -1, -2)
880  // will give insight on other possible topologies.
881 
882  // get directions of two lines
883  Vector_t dir1(lin1.Pt2() - lin1.Pt1());
884  Vector_t dir2(lin2.Pt2() - lin2.Pt1());
885  dir1.Normalize();
886  dir2.Normalize();
887 
888  // Closest approach points on the two lines
889  Point_t pt1(lin1.Pt1().size());
890  Point_t pt2(lin2.Pt1().size());
891 
892  //double IP = _SqDist_(lin1, lin2, pt1, pt2);
893  origin = (pt1 + pt2) / 2.;
894 
895  // If origin coincides with lin1 start
896  // -> vec1 should be in same direction of lin1
897  Vector_t vec1(dir1);
898  if (lin1.Pt1() != origin) vec1 = lin1.Pt1() - origin;
899  vec1.Normalize();
900  // similarly for vec1
901  Vector_t vec2(dir2);
902  if (lin2.Pt1() != origin) vec2 = lin2.Pt1() - origin;
903  vec2.Normalize();
904 
905  return vec1.Dot(dir1) + vec2.Dot(dir2);
906  }
recob::tracking::Point_t Point_t
TText * pt2
Definition: plot.C:64
TText * pt1
Definition: plot.C:61
recob::tracking::Vector_t Vector_t
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
double geoalgo::GeoAlgo::_commonOrigin_ ( const HalfLine_t lin1,
const HalfLine_t lin2,
Point_t origin,
bool  backwards 
) const
protected

Common origin: Half Line & Half Line. Keep track of origin.

Definition at line 909 of file GeoAlgo.cxx.

References _commonOrigin_(), geoalgo::HalfLine::Dir(), geo::origin(), pt1, pt2, and geoalgo::HalfLine::Start().

913  {
914 
915  //If backwards is false, call infinite line function, otherwise proceed
916  if (!backwards) {
917  Line_t l1(lin1.Start(), lin1.Start() + lin1.Dir());
918  Line_t l2(lin2.Start(), lin2.Start() + lin2.Dir());
919  return _commonOrigin_(l1, l2, origin);
920  }
921 
922  // Function Description:
923  // Given two HalfLine objects, project them backwards
924  // and find the point of closest approach on both
925  // lines.
926  // The half-point between these two is considered the
927  // candidate origin or vertex of the two lines
928  // Then make segments uniting this vertex and
929  // the start point of both half lines.
930  // Take the dot product of the segment uniting
931  // the vertex with the start of lin1, and the direction
932  // of lin1. Similarly for lin2.
933  // These dot-products will be close to 1 if the lines,
934  // traced backwards, indeed point to the reconstructed
935  // vertex.
936  // return the sum of these dot products, which
937  // is bound between -2 and +2.
938  // other values of this return (1, 0, -1, -2)
939  // will give insight on other possible topologies.
940 
941  // Flip the HalfLines: want to project backwards
942  HalfLine_t lin1Back(lin1.Start(), lin1.Dir() * (-1));
943  HalfLine_t lin2Back(lin2.Start(), lin2.Dir() * (-1));
944  // Closest approach points on the two lines
945  Point_t pt1(lin1.Start().size());
946  Point_t pt2(lin2.Start().size());
947 
948  // double IP = _SqDist_(lin1Back, lin2Back, pt1, pt2); Unused variable
949  origin = (pt1 + pt2) / 2.;
950 
951  // If origin coincides with lin1 start
952  // -> vec1 should be in same direction of lin1
953  Vector_t vec1(lin1.Dir());
954  if (lin1.Start() != origin) vec1 = lin1.Start() - origin;
955  vec1.Normalize();
956  // similarly for vec1
957  Vector_t vec2(lin2.Dir());
958  if (lin2.Start() != origin) vec2 = lin2.Start() - origin;
959  vec2.Normalize();
960 
961  return vec1.Dot(lin1.Dir()) + vec2.Dot(lin2.Dir());
962  // std::cout << "dot is: " << dot << std::endl;
963  // if ( !((dot <= 2) && (dot >= -2)) )
964  // throw GeoAlgoException("commonOrigin failed. Sum of two dot-products must be bound by [-2,2]");
965 
966  // return dot;
967  }
HalfLine HalfLine_t
Definition: GeoHalfLine.h:94
recob::tracking::Point_t Point_t
TText * pt2
Definition: plot.C:64
TText * pt1
Definition: plot.C:61
recob::tracking::Vector_t Vector_t
Line Line_t
Definition: GeoLine.h:92
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
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
double geoalgo::GeoAlgo::_commonOrigin_ ( const HalfLine_t lin,
const LineSegment_t seg,
Point_t origin,
bool  backwards 
) const
protected

Common origin: Line Segment & Half Line. Keep track of origin.

Definition at line 969 of file GeoAlgo.cxx.

References _commonOrigin_(), geoalgo::LineSegment::Dir(), and geoalgo::LineSegment::Start().

973  {
974  // Make a Half-line out of the line-segment
975  // we want to project backwards to a common origin
976  // not limit ourselves to an origin that must be on the segment
977  HalfLine_t lin2(seg.Start(), seg.Dir());
978  return _commonOrigin_(lin, lin2, origin, backwards);
979  }
HalfLine HalfLine_t
Definition: GeoHalfLine.h:94
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
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
double geoalgo::GeoAlgo::_commonOrigin_ ( const LineSegment_t seg1,
const LineSegment_t seg2,
Point_t origin,
bool  backwards 
) const
protected

Common origin: Line Segment & Line Segment. Keep track of origin.

Definition at line 981 of file GeoAlgo.cxx.

References _commonOrigin_(), geoalgo::LineSegment::Dir(), and geoalgo::LineSegment::Start().

985  {
986  // Make a Half-line out of the line-segments
987  // we want to project backwards to a common origin
988  // not limit ourselves to an origin that must be on the segment
989  HalfLine_t lin1(seg1.Start(), seg1.Dir());
990  HalfLine_t lin2(seg2.Start(), seg2.Dir());
991  return _commonOrigin_(lin1, lin2, origin, backwards);
992  }
HalfLine HalfLine_t
Definition: GeoHalfLine.h:94
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
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
double geoalgo::GeoAlgo::_commonOrigin_ ( const Trajectory_t trj1,
const Trajectory_t trj2,
Point_t origin,
bool  backwards 
) const
protected

Common origin: Trajectory & Trajectory. Keep track of origin.

Common origin: Trajectory & Trajectory/ Keep track of origin.

Definition at line 995 of file GeoAlgo.cxx.

References _commonOrigin_().

999  {
1000  // Turn the trajectory into half-line that connect start -> end
1001  HalfLine_t lin1(trj1.front(), trj1.back() - trj1.front());
1002  // Turn the segment into half-line
1003  HalfLine_t lin2(trj2.front(), trj2.back() - trj2.front());
1004  return _commonOrigin_(lin1, lin2, origin, backwards);
1005  }
HalfLine HalfLine_t
Definition: GeoHalfLine.h:94
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
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
double geoalgo::GeoAlgo::_commonOrigin_ ( const Trajectory_t trj,
const LineSegment_t seg,
Point_t origin,
bool  backwards 
) const
protected

Common origin: Trajectory & Line Segment. Keep track of origin.

Definition at line 1008 of file GeoAlgo.cxx.

References _commonOrigin_(), geoalgo::LineSegment::Dir(), and geoalgo::LineSegment::Start().

1012  {
1013  // Turn the trajectory into half-line that connect start -> end
1014  HalfLine_t lin1(trj.front(), trj.back() - trj.front());
1015  // Turn the segment into half-line
1016  HalfLine_t lin2(seg.Start(), seg.Dir());
1017  return _commonOrigin_(lin1, lin2, origin, backwards);
1018  }
HalfLine HalfLine_t
Definition: GeoHalfLine.h:94
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
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
double geoalgo::GeoAlgo::_commonOrigin_ ( const Trajectory_t trj,
const HalfLine_t lin,
Point_t origin,
bool  backwards 
) const
protected

Common origin: Trajectory & Half Line. Keep track of origin.

Definition at line 1021 of file GeoAlgo.cxx.

References _commonOrigin_().

1025  {
1026  // Turn the trajectory into half-line that connect start -> end
1027  HalfLine_t lin2(trj.front(), trj.back() - trj.front());
1028  return _commonOrigin_(lin, lin2, origin, backwards);
1029  }
HalfLine HalfLine_t
Definition: GeoHalfLine.h:94
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
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
Sphere_t geoalgo::GeoAlgo::_RemainingPoints_ ( std::vector< Point_t > &  remaining,
const Sphere_t thisSphere 
) const
protected

Definition at line 1070 of file GeoAlgo.cxx.

References geoalgo::Sphere::Center(), geoalgo::Sphere::Contain(), dir, larg4::dist(), geoalgo::Vector::Normalize(), and geoalgo::Sphere::Radius().

Referenced by _boundingSphere_(), and _ClosestPt_().

1072  {
1073 
1074  // if no points lef -> done...return the current sphere
1075  if (remaining.size() == 0) return thisSphere;
1076 
1077  //std::cout << "Remaining points: " << remaining.size() << std::endl;
1078 
1079  auto const& lastPoint = remaining.back();
1080 
1081  // if this point is bounded by the already constructed sphere, continue
1082  if (thisSphere.Contain(lastPoint)) {
1083  remaining.pop_back();
1084  return _RemainingPoints_(remaining, thisSphere);
1085  }
1086  // if not, need to adjust so that the new point is also bound
1087  // get distance from lastPoint and center
1088  double dist = lastPoint.Dist(thisSphere.Center());
1089  //std::cout << "point does not fit: " << lastPoint << std::endl;
1090  //std::cout << "distance: " << dist << std::endl;
1091  //std::cout << "center : " << thisSphere.Center() << std::endl;
1092  //std::cout << "radius : " << thisSphere.Radius() << std::endl;
1093  // the new center should be shifted in the direction
1094  // of the new point by half the difference between
1095  // the current radius and "dist"
1096  // direction in which to move:
1097  Vector_t dir = lastPoint - thisSphere.Center();
1098  dir.Normalize();
1099  // amount to move by
1100  double shift = (dist - thisSphere.Radius()) / 2.;
1101  if (shift < 0) { shift *= -1; }
1102  Point_t newCenter = thisSphere.Center() + dir * shift;
1103  double newRadius = thisSphere.Radius() + shift;
1104  //std::cout << "new center: " << newCenter << std::endl;
1105  //std::cout << "new radius: " << newRadius << std::endl;
1106  Sphere_t newsphere(newCenter, newRadius);
1107  //if (newsphere.Contain(lastPoint)) { std::cout << "new point contained!" << std::endl; }
1108  //else { std::cout << "WRONG!" << std::endl; }
1109  remaining.pop_back();
1110 
1111  return _RemainingPoints_(remaining, newsphere);
1112  }
recob::tracking::Point_t Point_t
TDirectory * dir
Definition: macro.C:5
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
Sphere_t _RemainingPoints_(std::vector< Point_t > &remaining, const Sphere_t &thisSphere) const
Definition: GeoAlgo.cxx:1070
recob::tracking::Vector_t Vector_t
Sphere Sphere_t
Definition: GeoSphere.h:126
double geoalgo::GeoAlgo::_SqDist_ ( const Line_t l1,
const Line_t l2,
Point_t L1,
Point_t L2 
) const
protected

Line & Line distance w/o dimensionality check.

Definition at line 193 of file GeoAlgo.cxx.

References _ClosestPt_(), geoalgo::Vector::_SqDist_(), d, larg4::dist(), e, f, geoalgo::Line::Pt1(), geoalgo::Line::Pt2(), and r.

Referenced by _ClosestPt_(), _SqDist_(), boundingSphere(), ClosestPt(), and SqDist().

194  {
195 
196  // closest approach when segment connecting the two lines
197  // is perpendicular to both lines
198 
199  // L1 = P1 + s(Q1-P1)
200  // L1 = P2 + t(Q2-P2)
201  // L1(s) and L2(t) are the closest approach points
202  // d1 = Q1-P1
203  // d2 = Q2-P2
204  // v(s,t) = L1(s) - L2(t)
205  // require d1*v == 0 && d2*v == 0
206  Vector_t d1 = l1.Pt2() - l1.Pt1();
207  Vector_t d2 = l2.Pt2() - l2.Pt1();
208  Vector_t r = l1.Pt1() - l2.Pt1();
209 
210  double a = d1 * d1;
211  double b = d1 * d2;
212  double c = d1 * r;
213  double e = d2 * d2;
214  double f = d2 * r;
215 
216  double d = a * e - b * b;
217 
218  // if d==0 the lines are parallel
219  // return Pt1 (doesn't matter) for line 1
220  // distance is distance between Pt1 of 1 line & second line
221  if (d == 0) {
222  L1 = l1.Pt1();
223  L2 = _ClosestPt_(l1.Pt1(), l2);
224  return L1._SqDist_(L2);
225  }
226 
227  double s = (b * f - c * e) / d;
228  double t = (a * f - b * c) / d;
229 
230  // s & t represent the paramteric points on the lines
231  // for the closest approach point
232  // now find the Point_t object at those locations
233 
234  L1 = l1.Pt1() + (l1.Pt2() - l1.Pt1()) * s;
235  L2 = l2.Pt1() + (l2.Pt2() - l2.Pt1()) * t;
236 
237  // find distance between these points
238  double dist = L1._SqDist_(L2);
239 
240  return dist;
241  }
TRandom r
Definition: spectrum.C:23
double _SqDist_(const Vector &obj) const
Compute the squared-distance to another vector w/o dimension check.
Definition: GeoVector.cxx:138
TFile f
Definition: plotHisto.C:6
Float_t d
Definition: plot.C:235
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
Float_t e
Definition: plot.C:35
recob::tracking::Vector_t Vector_t
Point_t _ClosestPt_(const Point_t &pt, const LineSegment_t &line) const
Definition: GeoAlgo.cxx:390
double geoalgo::GeoAlgo::_SqDist_ ( const HalfLine_t l1,
const HalfLine_t l2,
Point_t L1,
Point_t L2 
) const
protected

HalfLine & HalfLine distance w/o dimensionality check.

Definition at line 249 of file GeoAlgo.cxx.

References _ClosestPt_(), geoalgo::Vector::_SqDist_(), d, geoalgo::HalfLine::Dir(), larg4::dist(), e, f, r, and geoalgo::HalfLine::Start().

253  {
254 
255  //Same as for _SqDist_ with infinite line but check whether s & t go out of bounds (i.e. negative)
256 
257  Vector_t d1 = l1.Dir();
258  Vector_t d2 = l2.Dir();
259  Vector_t r = l1.Start() - l2.Start();
260 
261  double a = d1 * d1;
262  double b = d1 * d2;
263  double c = d1 * r;
264  double e = d2 * d2;
265  double f = d2 * r;
266 
267  double d = a * e - b * b;
268 
269  // Need to make sure d != 0
270  if (d == 0) {
271  // lines are parallel
272  // check closest distance from one start point
273  // to other line. Order indifferent
274  // Choose l1 to have cloest point be Start point
275  L1 = l1.Start();
276  L2 = _ClosestPt_(L1, l2);
277  return L1._SqDist_(L2);
278  }
279 
280  double s = (b * f - c * e) / d;
281  double t = (a * f - b * c) / d;
282 
283  // if s or t < 0, out of bounds for half-line
284  if (s < 0) s = 0;
285  if (t < 0) t = 0;
286 
287  // s & t represent the paramteric points on the lines
288  // for the closest approach point
289  // now find the Point_t object at those locations
290 
291  L1 = l1.Start() + l1.Dir() * s;
292  L2 = l2.Start() + l2.Dir() * t;
293 
294  // find distance between these points
295  double dist = L1._SqDist_(L2);
296 
297  return dist;
298  }
TRandom r
Definition: spectrum.C:23
TFile f
Definition: plotHisto.C:6
Float_t d
Definition: plot.C:235
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
Float_t e
Definition: plot.C:35
recob::tracking::Vector_t Vector_t
Point_t _ClosestPt_(const Point_t &pt, const LineSegment_t &line) const
Definition: GeoAlgo.cxx:390
double geoalgo::GeoAlgo::_SqDist_ ( const Point_t pt,
const LineSegment_t line 
) const
inlineprotected

Point & LineSegment distance w/o dimensionality check.

Definition at line 631 of file GeoAlgo.h.

References _SqDist_(), geoalgo::LineSegment::End(), and geoalgo::LineSegment::Start().

632  {
633  return _SqDist_(pt, line.Start(), line.End());
634  }
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
TMarker * pt
Definition: egs.C:25
double geoalgo::GeoAlgo::_SqDist_ ( const Point_t pt,
const Point_t line_s,
const Point_t line_e 
) const
protected

Point & LineSegment distance w/o dimensionality check.

Definition at line 377 of file GeoAlgo.cxx.

References e, and f.

378  {
379  auto const ab = line_e - line_s;
380  auto const ac = pt - line_s;
381  auto const bc = pt - line_e;
382  auto e = ac * ab;
383  if (e <= 0.) return ac.SqLength();
384  auto f = ab.SqLength();
385  if (e >= f) return bc.SqLength();
386  return (ac.SqLength() - e * e / f);
387  }
TFile f
Definition: plotHisto.C:6
TMarker * pt
Definition: egs.C:25
Float_t e
Definition: plot.C:35
double geoalgo::GeoAlgo::_SqDist_ ( const LineSegment_t line,
const Point_t pt 
) const
inlineprotected

Point & LineSegment distance w/o dimensionality check.

Definition at line 640 of file GeoAlgo.h.

References _ClosestPt_(), and _SqDist_().

641  {
642  return _SqDist_(pt, line);
643  }
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
TMarker * pt
Definition: egs.C:25
double geoalgo::GeoAlgo::_SqDist_ ( const HalfLine_t hline,
const LineSegment_t seg,
Point_t L1,
Point_t L2 
) const
protected

HalfLine & LineSegment distance w/o dimensionality check.

Definition at line 306 of file GeoAlgo.cxx.

References _Clamp_(), _ClosestPt_(), geoalgo::Vector::_SqDist_(), _SqDist_(), d, geoalgo::HalfLine::Dir(), e, geoalgo::LineSegment::End(), f, r, geoalgo::LineSegment::Start(), and geoalgo::HalfLine::Start().

310  {
311 
312  //Same as for _SqDist_ with infinite line but check whether s & t go out of bounds (i.e. negative)
313 
314  auto const d1 = hline.Dir();
315  auto const d2 = seg.End() - seg.Start();
316  auto const r = hline.Start() - seg.Start();
317 
318  double a = d1 * d1;
319  double b = d1 * d2;
320  double c = d1 * r;
321  double e = d2 * d2;
322  double f = d2 * r;
323 
324  double d = a * e - b * b;
325 
326  // if parallel then d == 0
327  if (d == 0) {
328  // distance is smallest quantity between:
329  // - distance from segment start to line
330  // - distance from segment end to line
331  double sDist = _SqDist_(seg.Start(), hline);
332  double eDist = _SqDist_(seg.End(), hline);
333  if (sDist <= eDist) {
334  // get closest point on line
335  L1 = _ClosestPt_(seg.Start(), hline);
336  L2 = seg.Start();
337  return sDist;
338  }
339  else {
340  L1 = _ClosestPt_(seg.End(), hline);
341  L2 = seg.End();
342  return eDist;
343  }
344  } // if parallel
345 
346  double s = (b * f - c * e) / d;
347 
348  // now check if parameters are out of bounds
349  if (s < 0) {
350  s = 0; // closest point on half-line is start
351  // re-evaluate closest point on segment using line start point
352  L1 = hline.Start();
353  L2 = _ClosestPt_(L1, seg);
354  return L1._SqDist_(L2);
355  }
356 
357  // if closest point is not beyond half-line
358  // it could be due to an intersection between half-line
359  // and segment projection.
360  // check value of t
361  double t = (a * f - b * c) / d;
362  // if t > 0 && < 1 then the two lines intersect. We are good!
363  if ((t < 1) and (t > 0)) {
364  L1 = hline.Start() + hline.Dir() * s;
365  L2 = seg.Start() + (seg.End() - seg.Start()) * t;
366  return L1._SqDist_(L2);
367  }
368  // if out of bounds clamp
369  // then re-evaluate closest point on line
370  t = _Clamp_(t, 0, 1);
371  L2 = seg.Start() + (seg.End() - seg.Start()) * t;
372  L1 = _ClosestPt_(L2, hline);
373  return L1._SqDist_(L2);
374  }
TRandom r
Definition: spectrum.C:23
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 _Clamp_(const double n, const double min, const double max) const
Clamp function: checks if value out of bounds.
Definition: GeoAlgo.cxx:852
TFile f
Definition: plotHisto.C:6
Float_t d
Definition: plot.C:235
Float_t e
Definition: plot.C:35
Point_t _ClosestPt_(const Point_t &pt, const LineSegment_t &line) const
Definition: GeoAlgo.cxx:390
double geoalgo::GeoAlgo::_SqDist_ ( const LineSegment_t seg1,
const LineSegment_t seg2,
Point_t c1,
Point_t c2 
) const
protected

LineSegment & LineSegment distance w/o dimensionality check.

Definition at line 776 of file GeoAlgo.cxx.

References _Clamp_(), c1, e, geoalgo::LineSegment::End(), f, r, geoalgo::Vector::SqLength(), geoalgo::LineSegment::Start(), t1, and t2.

780  {
781 
782  double t1, t2;
783 
784  auto const& s1 = seg1.Start();
785  auto const& s2 = seg2.Start();
786  auto const& e1 = seg1.End();
787  auto const& e2 = seg2.End();
788 
789  auto d1 = e1 - s1;
790  auto d2 = e2 - s2;
791  auto r = s1 - s2;
792 
793  double a = d1.SqLength();
794  double e = d2.SqLength();
795  double f = d2 * r;
796 
797  // check if segment is too short
798  if ((a <= 0) and (e <= 0)) {
799  //both segments are too short
800  t1 = t2 = 0.;
801  c1 = s1;
802  c2 = s2;
803  Vector_t distVector = c2 - c1;
804  return distVector.SqLength();
805  }
806  if (a <= 0) {
807  //first segment degenerates into a point
808  t1 = 0.;
809  t2 = f / e;
810  t2 = _Clamp_(t2, 0., 1.);
811  }
812  else {
813  double c = d1 * r;
814  if (e <= 0) {
815  //second segment degenerates into a point
816  t2 = 0.;
817  t1 = _Clamp_(-c / a, 0., 1.);
818  }
819  else {
820  // the general case...no degeneracies
821  double b = d1 * d2;
822  double denom = (a * e) - (b * b);
823 
824  if (denom != 0.)
825  t1 = _Clamp_((b * f - c * e) / denom, 0., 1.);
826  else
827  t1 = 0.;
828 
829  t2 = (b * t1 + f) / e;
830 
831  if (t2 < 0.) {
832  t2 = 0.;
833  t1 = _Clamp_(-c / a, 0., 1.);
834  }
835  else if (t2 > 1.) {
836  t2 = 1.;
837  t1 = _Clamp_((b - c) / a, 0., 1.);
838  }
839  }
840  }
841 
842  c1 = s1 + d1 * t1;
843  c2 = s2 + d2 * t2;
844 
845  Vector_t distVector = c2 - c1;
846  return distVector.SqLength();
847  }
TRandom r
Definition: spectrum.C:23
TTree * t1
Definition: plottest35.C:26
double _Clamp_(const double n, const double min, const double max) const
Clamp function: checks if value out of bounds.
Definition: GeoAlgo.cxx:852
TFile f
Definition: plotHisto.C:6
TCanvas * c1
Definition: plotHisto.C:7
TCanvas * c2
Definition: plot_hist.C:75
TTree * t2
Definition: plottest35.C:36
Float_t e
Definition: plot.C:35
recob::tracking::Vector_t Vector_t
double geoalgo::GeoAlgo::_SqDist_ ( const Point_t pt,
const HalfLine_t line 
) const
protected

Point & HalfLine distance w/o dimensionality check.

Definition at line 410 of file GeoAlgo.cxx.

References geoalgo::HalfLine::Dir(), e, f, and geoalgo::HalfLine::Start().

411  {
412  auto const& ab = line.Dir();
413  auto const ac = pt - line.Start();
414  auto const bc = ac - ab;
415 
416  auto e = ac * ab;
417  if (e <= 0.) return (ac * ac);
418  auto f = ab.SqLength();
419  return (ac.SqLength() - e * e / f);
420  }
TFile f
Definition: plotHisto.C:6
TMarker * pt
Definition: egs.C:25
Float_t e
Definition: plot.C:35
double geoalgo::GeoAlgo::_SqDist_ ( const HalfLine_t line,
const Point_t pt 
) const
inlineprotected

Point & HalfLine distance w/o dimensionality check.

Definition at line 668 of file GeoAlgo.h.

References _ClosestPt_(), and _SqDist_().

Referenced by _SqDist_().

668 { return _SqDist_(pt, line); }
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
TMarker * pt
Definition: egs.C:25
double geoalgo::GeoAlgo::_SqDist_ ( const Line_t line,
const Point_t pt 
) const
protected

Definition at line 436 of file GeoAlgo.cxx.

References e, f, geoalgo::Line::Pt1(), and geoalgo::Line::Pt2().

437  {
438  auto const ab = line.Pt2() - line.Pt1();
439  auto const ac = pt - line.Pt1();
440  auto const bc = ac - ab;
441 
442  auto e = ac * ab;
443  auto f = ab.SqLength();
444  return (ac.SqLength() - e * e / f);
445  }
TFile f
Definition: plotHisto.C:6
TMarker * pt
Definition: egs.C:25
Float_t e
Definition: plot.C:35
double geoalgo::GeoAlgo::_SqDist_ ( const Point_t pt,
const Line_t line 
) const
inlineprotected

Definition at line 687 of file GeoAlgo.h.

References _SqDist_().

Referenced by _SqDist_().

687 { return _SqDist_(line, pt); }
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
TMarker * pt
Definition: egs.C:25
double geoalgo::GeoAlgo::_SqDist_ ( const Point_t pt,
const AABox_t box 
) const
protected

Point & AABox distance w/o dimensionality check.

Definition at line 457 of file GeoAlgo.cxx.

References geoalgo::AABox::Contain(), larg4::dist(), geoalgo::kINVALID_DOUBLE, geoalgo::AABox::Max(), and geoalgo::AABox::Min().

458  {
459  double dist = kINVALID_DOUBLE;
460 
461  // If a point is inside the box, simply compute the smallest perpendicular distance
462  if (box.Contain(pt)) {
463 
464  auto const& pt_min = box.Min();
465  auto const& pt_max = box.Max();
466  // (1) Compute the distance to the YZ wall
467  double dist_to_yz = pt[0] - pt_min[0];
468  if (dist_to_yz > (pt_max[0] - pt[0])) dist_to_yz = pt_max[0] - pt[0];
469 
470  // (2) Compute the distance to the XZ wall
471  double dist_to_zx = pt[1] - pt_min[1];
472  if (dist_to_zx > (pt_max[1] - pt[1])) dist_to_zx = pt_max[1] - pt[1];
473 
474  // (3) Compute the distance to the XY wall
475  double dist_to_xy = pt[2] - pt_min[2];
476  if (dist_to_xy > (pt_max[2] - pt[2])) dist_to_xy = pt_max[2] - pt[2];
477 
478  // (4) Compute the minimum of (3), (4), and (5)
479  dist = (dist_to_yz < dist_to_zx ? dist_to_yz : dist_to_zx);
480  dist = (dist < dist_to_xy ? dist : dist_to_xy);
481  dist *= dist;
482  }
483 
484  else {
485  // This refers to Ref. RTCD 5.1.3.1
486  // re-set distance
487  dist = 0;
488  for (size_t i = 0; i < pt.size(); ++i) {
489 
490  auto const& v_pt = pt[i];
491  auto const& v_max = box.Max()[i];
492  auto const& v_min = box.Min()[i];
493 
494  if (v_pt < v_min) dist += (v_min - v_pt) * (v_min - v_pt);
495  if (v_pt > v_max) dist += (v_pt - v_max) * (v_pt - v_max);
496  }
497  }
498  return dist;
499  }
TMarker * pt
Definition: egs.C:25
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
static const double kINVALID_DOUBLE
double geoalgo::GeoAlgo::_SqDist_ ( const AABox_t box,
const Point_t pt 
) const
inlineprotected

Point & AABox distance w/o dimensionality check.

Definition at line 692 of file GeoAlgo.h.

References _ClosestPt_(), and _SqDist_().

Referenced by _SqDist_().

692 { return _SqDist_(pt, box); }
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
TMarker * pt
Definition: egs.C:25
void geoalgo::GeoAlgo::_Swap_ ( double &  tmin,
double &  tmax 
) const
inlineprotected

Swap two points if min & max are inverted.

Definition at line 746 of file GeoAlgo.h.

747  {
748  if (tmin > tmax) std::swap(tmin, tmax);
749  }
void swap(lar::deep_const_fwd_iterator_nested< CITER, INNERCONTEXTRACT > &a, lar::deep_const_fwd_iterator_nested< CITER, INNERCONTEXTRACT > &b)
Sphere_t geoalgo::GeoAlgo::_WelzlSphere_ ( const std::vector< Point_t > &  pts,
int  numPts,
std::vector< Point_t sosPts 
) const
protected

Definition at line 1114 of file GeoAlgo.cxx.

References geoalgo::Sphere::Contain().

Referenced by _ClosestPt_().

1117  {
1118 
1119  if (numPts == 0) return Sphere_t(sosPts);
1120  // choose last point in the input set as the one to test (if it fits in current sphere or not)
1121  int index = numPts - 1;
1122  // recursively compute the smallest bounding sphere of the remaining points
1123  Sphere_t smallestSphere = _WelzlSphere_(pts, numPts - 1, sosPts);
1124  // if the selected point lies inside this sphere, it is indeed the smallest
1125  if (smallestSphere.Contain(pts[index])) return smallestSphere;
1126  // otherwise, update the set-of-support to additionally contain the new point
1127  sosPts.push_back(pts[index]);
1128  return _WelzlSphere_(pts, numPts - 1, sosPts);
1129  }
Sphere_t _WelzlSphere_(const std::vector< Point_t > &pts, int numPts, std::vector< Point_t > sosPts) const
Definition: GeoAlgo.cxx:1114
Sphere Sphere_t
Definition: GeoSphere.h:126
Sphere_t geoalgo::GeoAlgo::boundingSphere ( const std::vector< Point_t > &  pts) const
inline

Definition at line 615 of file GeoAlgo.h.

References _boundingSphere_(), _SqDist_(), and geoalgo::Sphere::compat().

616  {
617  for (auto& p : pts) {
618  pts.front().compat(p);
619  }
620  return _boundingSphere_(pts);
621  }
Sphere_t _boundingSphere_(const std::vector< Point_t > &pts) const
Definition: GeoAlgo.cxx:1033
LineSegment_t geoalgo::GeoAlgo::BoxOverlap ( const AABox_t box,
const HalfLine_t line 
) const

LineSegment sub-segment of HalfLine inside an AABox.

Definition at line 168 of file GeoAlgo.cxx.

References Intersection(), and geoalgo::HalfLine::Start().

Referenced by BoxOverlap(), and Intersection().

169  {
170  // First find interection point of half-line and box
171  auto xs_v = Intersection(box, line);
172  if (xs_v.size() == 2) return LineSegment_t(xs_v[0], xs_v[1]);
173 
174  // Build a new LineSegment
175  if (!(xs_v.size())) return LineSegment_t();
176 
177  // Only other possiblity is # = 1
178  return LineSegment_t(line.Start(), xs_v[0]);
179  }
LineSegment LineSegment_t
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
LineSegment_t geoalgo::GeoAlgo::BoxOverlap ( const HalfLine_t line,
const AABox_t box 
) const
inline

LineSegment sub-segment of HalfLine inside an AABox.

Definition at line 81 of file GeoAlgo.h.

References BoxOverlap().

82  {
83  return BoxOverlap(box, line);
84  }
LineSegment_t BoxOverlap(const AABox_t &box, const HalfLine_t &line) const
LineSegment sub-segment of HalfLine inside an AABox.
Definition: GeoAlgo.cxx:168
Trajectory_t geoalgo::GeoAlgo::BoxOverlap ( const AABox_t box,
const Trajectory_t trj 
) const

Get Trajectory inside box given some input trajectory -> now assumes trajectory cannot exit and re-enter box.

Definition at line 182 of file GeoAlgo.cxx.

References geoalgo::AABox::Contain().

183  {
184 
185  // if first & last points inside, then return full trajectory
186  if (box.Contain(trj[0]) and box.Contain(trj.back())) return trj;
187 
188  return trj;
189  }
Trajectory_t geoalgo::GeoAlgo::BoxOverlap ( const Trajectory_t trj,
const AABox_t box 
) const
inline

Get Trajectory inside box given some input trajectory -> now assumes trajectory cannot exit and re-enter box.

Definition at line 89 of file GeoAlgo.h.

References BoxOverlap().

90  {
91  return BoxOverlap(box, trj);
92  }
LineSegment_t BoxOverlap(const AABox_t &box, const HalfLine_t &line) const
LineSegment sub-segment of HalfLine inside an AABox.
Definition: GeoAlgo.cxx:168
Point_t geoalgo::GeoAlgo::ClosestPt ( const Line_t line,
const Point_t pt 
) const
inline

Definition at line 106 of file GeoAlgo.h.

References _ClosestPt_(), geoalgo::Vector::compat(), and geoalgo::Line::Pt1().

Referenced by ClosestPt(), and SqDist().

107  {
108  pt.compat(line.Pt1());
109  return _ClosestPt_(pt, line);
110  }
TMarker * pt
Definition: egs.C:25
Point_t _ClosestPt_(const Point_t &pt, const LineSegment_t &line) const
Definition: GeoAlgo.cxx:390
Point_t geoalgo::GeoAlgo::ClosestPt ( const Point_t pt,
const Line_t line 
) const
inline

Definition at line 112 of file GeoAlgo.h.

References _ClosestPt_().

112 { return _ClosestPt_(pt, line); }
TMarker * pt
Definition: egs.C:25
Point_t _ClosestPt_(const Point_t &pt, const LineSegment_t &line) const
Definition: GeoAlgo.cxx:390
Point_t geoalgo::GeoAlgo::ClosestPt ( const Point_t pt,
const Trajectory_t trj 
) const
inline

Point_t & Trajectory_t closest point.

Definition at line 280 of file GeoAlgo.h.

References ClosestPt().

281  {
282  int idx = 0;
283  return ClosestPt(pt, trj, idx);
284  }
Point_t ClosestPt(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:106
TMarker * pt
Definition: egs.C:25
Point_t geoalgo::GeoAlgo::ClosestPt ( const Trajectory_t trj,
const Point_t pt 
) const
inline

Point_t & Trajectory_t closest point.

Definition at line 286 of file GeoAlgo.h.

References ClosestPt().

287  {
288  int idx = 0;
289  return ClosestPt(pt, trj, idx);
290  }
Point_t ClosestPt(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:106
TMarker * pt
Definition: egs.C:25
Point_t geoalgo::GeoAlgo::ClosestPt ( const Point_t pt,
const Trajectory_t trj,
int &  idx 
) const

Point_t & Trajectory_t closest point. Keep track of index of segment.

Definition at line 572 of file GeoAlgo.cxx.

References _ClosestPt_(), _SqDist_(), geoalgo::Trajectory::compat(), and geoalgo::kINVALID_DOUBLE.

573  {
574 
575  // Make sure trajectory object is properly defined
576  if (!trj.size()) throw GeoAlgoException("Trajectory object not properly set...");
577 
578  // Check dimensionality compatibility between point and trajectory
579  trj.compat(pt);
580 
581  // Now keep track of smallest distance and loop over traj segments
582  double distMin = kINVALID_DOUBLE;
583  // For that smallest distance, keep track of the segment for which it was found
584  for (size_t l = 0; l < trj.size() - 1; l++) {
585  double distTmp = _SqDist_(pt, trj[l], trj[l + 1]);
586  if (distTmp < distMin) {
587  distMin = distTmp;
588  idx = l;
589  }
590  }
591 
592  // Now that we have the segment for the closest approach
593  // Use it to find the closest point on that segment
594  LineSegment_t segMin(trj[idx], trj[idx + 1]);
595  return _ClosestPt_(pt, segMin);
596  }
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
LineSegment LineSegment_t
TMarker * pt
Definition: egs.C:25
static const double kINVALID_DOUBLE
Point_t _ClosestPt_(const Point_t &pt, const LineSegment_t &line) const
Definition: GeoAlgo.cxx:390
Point_t geoalgo::GeoAlgo::ClosestPt ( const Trajectory_t trj,
const Point_t pt,
int &  idx 
) const
inline

Point_t & Trajectory_t closest point. Keep track of index of segment.

Definition at line 294 of file GeoAlgo.h.

References ClosestPt(), and SqDist().

295  {
296  return ClosestPt(pt, trj, idx);
297  }
Point_t ClosestPt(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:106
TMarker * pt
Definition: egs.C:25
Point_t geoalgo::GeoAlgo::ClosestPt ( const Point_t pt,
const std::vector< geoalgo::Trajectory_t > &  trj,
int &  trackIdx 
) const

Point_t & Trajectory_t closest point - keep track of which track is closest.

Definition at line 602 of file GeoAlgo.cxx.

References ClosestPt(), geoalgo::kINVALID_DOUBLE, and SqDist().

605  {
606 
607  // since finding the smallest distance is faster than finding the closest point
608  // first loop through tracks, and find the one that is closest to the point
609  // then finally find the closest point on that track
610 
611  for (size_t t = 0; t < trj.size(); t++) {
612 
613  // holder for smallest distance
614  double minDist = kINVALID_DOUBLE;
615 
616  // track & point dimensionality will be checked per-track by next function
617  // now calculate distance w.r.t. this track
618  double tmpDist = SqDist(pt, trj[t]);
619  if (tmpDist < minDist) {
620  minDist = tmpDist;
621  TrackIdx = t;
622  }
623 
624  } // for all tracks
625 
626  // now we know which track is closest -> find the closest point to that track
627  return ClosestPt(pt, trj[TrackIdx]);
628  }
Point_t ClosestPt(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:106
double SqDist(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:98
TMarker * pt
Definition: egs.C:25
static const double kINVALID_DOUBLE
Point_t geoalgo::GeoAlgo::ClosestPt ( const std::vector< geoalgo::Trajectory_t > &  trj,
const Point_t pt,
int &  trackIdx 
) const
inline

Point_t & Trajectory_t closest point - keep track of which track is closest.

Definition at line 330 of file GeoAlgo.h.

References ClosestPt().

333  {
334  return ClosestPt(pt, trj, trackIdx);
335  }
Point_t ClosestPt(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:106
TMarker * pt
Definition: egs.C:25
Point_t geoalgo::GeoAlgo::ClosestPt ( const Point_t pt,
const std::vector< geoalgo::Trajectory_t > &  trj 
) const
inline

Point_t & Trajectory_t closest point - don't keep track of which track is closest.

Definition at line 337 of file GeoAlgo.h.

References ClosestPt().

338  {
339  int trackIdx;
340  return ClosestPt(pt, trj, trackIdx);
341  }
Point_t ClosestPt(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:106
TMarker * pt
Definition: egs.C:25
Point_t geoalgo::GeoAlgo::ClosestPt ( const std::vector< geoalgo::Trajectory_t > &  trj,
const Point_t pt 
) const
inline

Point_t & Trajectory_t closest point - don't keep track of which track is closest.

Definition at line 343 of file GeoAlgo.h.

References ClosestPt().

344  {
345  int trackIdx;
346  return ClosestPt(pt, trj, trackIdx);
347  }
Point_t ClosestPt(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:106
TMarker * pt
Definition: egs.C:25
Point_t geoalgo::GeoAlgo::ClosestPt ( const Point_t pt,
const LineSegment_t line 
) const
inline

Point & LineSegment closest point.

Definition at line 361 of file GeoAlgo.h.

References _ClosestPt_(), geoalgo::Vector::compat(), and geoalgo::LineSegment::Start().

362  {
363  pt.compat(line.Start());
364  return _ClosestPt_(pt, line);
365  }
TMarker * pt
Definition: egs.C:25
Point_t _ClosestPt_(const Point_t &pt, const LineSegment_t &line) const
Definition: GeoAlgo.cxx:390
Point_t geoalgo::GeoAlgo::ClosestPt ( const LineSegment_t line,
const Point_t pt 
) const
inline

Point & LineSegment closest point.

Definition at line 367 of file GeoAlgo.h.

References ClosestPt().

368  {
369  return ClosestPt(pt, line);
370  }
Point_t ClosestPt(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:106
TMarker * pt
Definition: egs.C:25
Point_t geoalgo::GeoAlgo::ClosestPt ( const Point_t pt,
const HalfLine_t line 
) const
inline

Point & HalfLine closest point.

Definition at line 384 of file GeoAlgo.h.

References _ClosestPt_(), geoalgo::Vector::compat(), and geoalgo::HalfLine::Start().

385  {
386  pt.compat(line.Start());
387  return _ClosestPt_(pt, line);
388  }
TMarker * pt
Definition: egs.C:25
Point_t _ClosestPt_(const Point_t &pt, const LineSegment_t &line) const
Definition: GeoAlgo.cxx:390
Point_t geoalgo::GeoAlgo::ClosestPt ( const HalfLine_t line,
const Point_t pt 
) const
inline

Point & HalfLine closest point.

Definition at line 390 of file GeoAlgo.h.

References ClosestPt().

391  {
392  return ClosestPt(pt, line);
393  }
Point_t ClosestPt(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:106
TMarker * pt
Definition: egs.C:25
Point_t geoalgo::GeoAlgo::ClosestPt ( const Point_t pt,
const AABox_t box 
) const
inline

Point & AABox closest point.

Definition at line 434 of file GeoAlgo.h.

References _ClosestPt_(), geoalgo::Vector::compat(), and geoalgo::AABox::Min().

435  {
436  pt.compat(box.Min());
437  return _ClosestPt_(pt, box);
438  }
TMarker * pt
Definition: egs.C:25
Point_t _ClosestPt_(const Point_t &pt, const LineSegment_t &line) const
Definition: GeoAlgo.cxx:390
Point_t geoalgo::GeoAlgo::ClosestPt ( const AABox_t box,
const Point_t pt 
) const
inline

Point & AABox closest point.

Definition at line 440 of file GeoAlgo.h.

References ClosestPt().

Referenced by ClosestPt().

440 { return ClosestPt(pt, box); }
Point_t ClosestPt(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:106
TMarker * pt
Definition: egs.C:25
double geoalgo::GeoAlgo::commonOrigin ( const Line_t lin1,
const Line_t lin2 
) const
inline

Common origin: Line Segment & Line Segment. Do not keep track of origin.

Definition at line 446 of file GeoAlgo.h.

References geo::origin(), and geoalgo::Line::Pt1().

Referenced by commonOrigin().

447  {
448  Point_t origin(lin1.Pt1().size());
449  return commonOrigin(lin1, lin2, origin);
450  }
recob::tracking::Point_t Point_t
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
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
double geoalgo::GeoAlgo::commonOrigin ( const Line_t lin1,
const Line_t lin2,
Point_t origin 
) const
inline

Common origin: Line Segment & Line Segment. Keep track of origin.

Definition at line 452 of file GeoAlgo.h.

References _commonOrigin_(), geoalgo::Vector::compat(), and geoalgo::Line::Pt1().

453  {
454  lin1.Pt1().compat(lin2.Pt1());
455  return _commonOrigin_(lin1, lin2, origin);
456  }
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
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
double geoalgo::GeoAlgo::commonOrigin ( const LineSegment_t seg1,
const LineSegment_t seg2,
bool  backwards = false 
) const
inline

Common origin: Line Segment & Line Segment. Do not keep track of origin.

Definition at line 458 of file GeoAlgo.h.

References commonOrigin(), geo::origin(), and geoalgo::LineSegment::Start().

461  {
462  Point_t origin(seg1.Start().size());
463  return commonOrigin(seg1, seg2, origin, backwards);
464  }
recob::tracking::Point_t Point_t
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
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
double geoalgo::GeoAlgo::commonOrigin ( const LineSegment_t seg1,
const LineSegment_t seg2,
Point_t origin,
bool  backwards = false 
) const
inline

Common origin: Line Segment & Line Segment. Keep track of origin.

Definition at line 466 of file GeoAlgo.h.

References _commonOrigin_(), geoalgo::Vector::compat(), and geoalgo::LineSegment::Start().

470  {
471  seg1.Start().compat(seg2.Start());
472  return _commonOrigin_(seg1, seg2, origin, backwards);
473  }
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
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
double geoalgo::GeoAlgo::commonOrigin ( const HalfLine_t lin,
const LineSegment_t seg,
bool  backwards = false 
) const
inline

Common origin: Line Segment & Half Line. Do not keep track of origin.

Definition at line 475 of file GeoAlgo.h.

References commonOrigin(), geo::origin(), and geoalgo::HalfLine::Start().

478  {
479  Point_t origin(lin.Start().size());
480  return commonOrigin(lin, seg, origin, backwards);
481  }
recob::tracking::Point_t Point_t
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
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
double geoalgo::GeoAlgo::commonOrigin ( const HalfLine_t lin,
const LineSegment_t seg,
Point_t origin,
bool  backwards = false 
) const
inline

Common origin: Line Segment & Line Segment. Keep track of origin.

Definition at line 483 of file GeoAlgo.h.

References _commonOrigin_(), geoalgo::Vector::compat(), geoalgo::LineSegment::Start(), and geoalgo::HalfLine::Start().

487  {
488  lin.Start().compat(seg.Start());
489  return _commonOrigin_(lin, seg, origin, backwards);
490  }
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
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
double geoalgo::GeoAlgo::commonOrigin ( const LineSegment_t seg,
const HalfLine_t lin,
bool  backwards = false 
) const
inline

Common origin: Line Segment & Half Line. Do not keep track of origin.

Definition at line 492 of file GeoAlgo.h.

References commonOrigin(), geo::origin(), and geoalgo::HalfLine::Start().

495  {
496  Point_t origin(lin.Start().size());
497  return commonOrigin(lin, seg, origin, backwards);
498  }
recob::tracking::Point_t Point_t
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
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
double geoalgo::GeoAlgo::commonOrigin ( const LineSegment_t seg,
const HalfLine_t lin,
Point_t origin,
bool  backwards = false 
) const
inline

Common origin: Line Segment & Line Segment. Keep track of origin.

Definition at line 500 of file GeoAlgo.h.

References _commonOrigin_(), geoalgo::Vector::compat(), geoalgo::LineSegment::Start(), and geoalgo::HalfLine::Start().

504  {
505  lin.Start().compat(seg.Start());
506  return _commonOrigin_(lin, seg, origin, backwards);
507  }
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
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
double geoalgo::GeoAlgo::commonOrigin ( const HalfLine_t lin1,
const HalfLine_t lin2,
bool  backwards = false 
) const
inline

Common origin: Half Line & Half Line. Do not keep track of origin.

Definition at line 509 of file GeoAlgo.h.

References commonOrigin(), geo::origin(), and geoalgo::HalfLine::Start().

512  {
513  Point_t origin(lin1.Start().size());
514  return commonOrigin(lin1, lin2, origin, backwards);
515  }
recob::tracking::Point_t Point_t
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
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
double geoalgo::GeoAlgo::commonOrigin ( const HalfLine_t lin1,
const HalfLine_t lin2,
Point_t origin,
bool  backwards = false 
) const
inline

Common origin: Half Line & Half Line. Keep track of origin.

Definition at line 517 of file GeoAlgo.h.

References _commonOrigin_(), geoalgo::Vector::compat(), and geoalgo::HalfLine::Start().

521  {
522  lin1.Start().compat(lin2.Start());
523  return _commonOrigin_(lin1, lin2, origin, backwards);
524  }
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
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
double geoalgo::GeoAlgo::commonOrigin ( const Trajectory_t trj1,
const Trajectory_t trj2,
bool  backwards = false 
) const
inline

Common origin: Trajectory & Trajectory. Do not keep track of origin.

Definition at line 526 of file GeoAlgo.h.

References commonOrigin(), and geo::origin().

529  {
530  Point_t origin(trj1.front().size());
531  return commonOrigin(trj1, trj2, origin, backwards);
532  }
recob::tracking::Point_t Point_t
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
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
double geoalgo::GeoAlgo::commonOrigin ( const Trajectory_t trj1,
const Trajectory_t trj2,
Point_t origin,
bool  backwards = false 
) const
inline

Common origin: Trajectory & Trajectory. Keep track of origin.

Definition at line 534 of file GeoAlgo.h.

References _commonOrigin_(), and geoalgo::Trajectory::compat().

538  {
539  trj1.front().compat(trj2.front());
540  return _commonOrigin_(trj1, trj2, origin, backwards);
541  }
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
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
double geoalgo::GeoAlgo::commonOrigin ( const Trajectory_t trj,
const HalfLine_t lin,
bool  backwards = false 
) const
inline

Common origin: Trajectory & Half Line. Do not keep track of origin.

Definition at line 543 of file GeoAlgo.h.

References commonOrigin(), and geo::origin().

546  {
547  Point_t origin(trj.front().size());
548  return commonOrigin(trj, lin, origin, backwards);
549  }
recob::tracking::Point_t Point_t
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
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
double geoalgo::GeoAlgo::commonOrigin ( const Trajectory_t trj,
const HalfLine_t lin,
Point_t origin,
bool  backwards = false 
) const
inline

Common origin: Trajectory & Half Line. Keep track of origin.

Definition at line 551 of file GeoAlgo.h.

References _commonOrigin_(), geoalgo::Trajectory::compat(), and geoalgo::HalfLine::Start().

555  {
556  trj.front().compat(lin.Start());
557  return _commonOrigin_(trj, lin, origin, backwards);
558  }
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
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
double geoalgo::GeoAlgo::commonOrigin ( const HalfLine_t lin,
const Trajectory_t trj,
bool  backwards = false 
) const
inline

Common origin: Trajectory & Half Line. Do not keep track of origin.

Definition at line 560 of file GeoAlgo.h.

References commonOrigin(), and geo::origin().

563  {
564  Point_t origin(trj.front().size());
565  return commonOrigin(trj, lin, origin, backwards);
566  }
recob::tracking::Point_t Point_t
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
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
double geoalgo::GeoAlgo::commonOrigin ( const HalfLine_t lin,
const Trajectory_t trj,
Point_t origin,
bool  backwards = false 
) const
inline

Common origin: Trajectory & Half Line. Keep track of origin.

Definition at line 568 of file GeoAlgo.h.

References _commonOrigin_(), geoalgo::Trajectory::compat(), and geoalgo::HalfLine::Start().

572  {
573  trj.front().compat(lin.Start());
574  return _commonOrigin_(trj, lin, origin, backwards);
575  }
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
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
double geoalgo::GeoAlgo::commonOrigin ( const Trajectory_t trj,
const LineSegment_t seg,
bool  backwards = false 
) const
inline

Common origin: Trajectory & Line Segment. Do not keep track of origin.

Definition at line 577 of file GeoAlgo.h.

References commonOrigin(), and geo::origin().

580  {
581  Point_t origin(trj.front().size());
582  return commonOrigin(trj, seg, origin, backwards);
583  }
recob::tracking::Point_t Point_t
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
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
double geoalgo::GeoAlgo::commonOrigin ( const Trajectory_t trj,
const LineSegment_t seg,
Point_t origin,
bool  backwards = false 
) const
inline

Common origin: Trajectory & Line Segment. Keep track of origin.

Definition at line 585 of file GeoAlgo.h.

References _commonOrigin_(), geoalgo::Trajectory::compat(), and geoalgo::LineSegment::Start().

589  {
590  trj.front().compat(seg.Start());
591  return _commonOrigin_(trj, seg, origin, backwards);
592  }
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
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
double geoalgo::GeoAlgo::commonOrigin ( const LineSegment_t seg,
const Trajectory_t trj,
bool  backwards = false 
) const
inline

Common origin: Trajectory & Line Segment. Do not keep track of origin.

Definition at line 594 of file GeoAlgo.h.

References commonOrigin(), and geo::origin().

597  {
598  Point_t origin(trj.front().size());
599  return commonOrigin(trj, seg, origin, backwards);
600  }
recob::tracking::Point_t Point_t
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
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
double geoalgo::GeoAlgo::commonOrigin ( const LineSegment_t seg,
const Trajectory_t trj,
Point_t origin,
bool  backwards = false 
) const
inline

Common origin: Trajectory & Line Segment. Keep track of origin.

Definition at line 602 of file GeoAlgo.h.

References _commonOrigin_(), geoalgo::Trajectory::compat(), and geoalgo::LineSegment::Start().

606  {
607  trj.front().compat(seg.Start());
608  return _commonOrigin_(trj, seg, origin, backwards);
609  }
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
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
std::vector< Point_t > geoalgo::GeoAlgo::Intersection ( const AABox_t box,
const HalfLine_t line,
bool  back = false 
) const

Intersection between a HalfLine and an AABox.

Definition at line 11 of file GeoAlgo.cxx.

References geoalgo::Vector::_SqDist_(), dir, geoalgo::HalfLine::Dir(), geoalgo::Vector::IsValid(), geoalgo::AABox::Max(), geoalgo::AABox::Min(), and geoalgo::HalfLine::Start().

Referenced by BoxOverlap(), and Intersection().

14  {
15  // Result container
16  std::vector<Point_t> result;
17  Point_t xs1(3); // Only 2 points max possible
18  Point_t xs2(3); // Create in advance for early termination checks
19  // One-time only initialization for unit vectors
20  static std::vector<Point_t> min_plane_n;
21  static std::vector<Point_t> max_plane_n;
22  if (!min_plane_n.size()) {
23  min_plane_n.reserve(3);
24  min_plane_n.push_back(Vector_t(-1, 0, 0));
25  min_plane_n.push_back(Vector_t(0, -1, 0));
26  min_plane_n.push_back(Vector_t(0, 0, -1));
27  max_plane_n.reserve(3);
28  max_plane_n.push_back(Vector_t(1, 0, 0));
29  max_plane_n.push_back(Vector_t(0, 1, 0));
30  max_plane_n.push_back(Vector_t(0, 0, 1));
31  }
32  // min/max points of the AABox
33  auto const& min_pt = box.Min();
34  auto const& max_pt = box.Max();
35  // start/dir of the line
36  auto const& start = line.Start();
37  auto dir = line.Dir();
38  if (back) dir *= -1;
39  // Inspect the case of parallel line
40  for (size_t i = 0; i < min_pt.size(); ++i) {
41  if (dir[i] == 0 && (start[i] <= min_pt[i] || max_pt[i] <= start[i])) return result;
42  }
43  // Look for xs w/ 3 planes
44  for (size_t i = 0; i < 3; ++i) {
45  auto const& normal = min_plane_n[i];
46  double s = (-1.) * (normal * (start - min_pt)) / (normal * dir);
47  if (s < 0) continue;
48  auto xs = start + dir * s;
49  // Check if the found point is within the surface area of other 2 axis
50  bool on_surface = true;
51  for (size_t sur_axis = 0; sur_axis < 3; ++sur_axis) {
52  if (sur_axis == i) continue;
53  if (xs[sur_axis] < min_pt[sur_axis] || max_pt[sur_axis] < xs[sur_axis]) {
54  on_surface = false;
55  break;
56  }
57  }
58  if (on_surface && xs != xs1) {
59  // Directly assign to xs1 instead of making a copy
60  if (!(xs1.IsValid()))
61  for (size_t j = 0; j < 3; ++j)
62  xs1[j] = xs[j];
63  else {
64  // If xs2 is filled, no more point to search. Exit.
65  for (size_t j = 0; j < 3; ++j)
66  xs2[j] = xs[j];
67  break;
68  }
69  }
70  }
71  // If xs2 is filled, simply return the result. Order the output via distance
72  if (xs2.IsValid()) {
73  result.reserve(2);
74  if (xs1._SqDist_(start) > xs2._SqDist_(start)) std::swap(xs1, xs2);
75  result.push_back(xs1);
76  result.push_back(xs2);
77  return result;
78  }
79  // Look for xs w/ 3 planes
80  for (size_t i = 0; i < 3; ++i) {
81  auto const& normal = max_plane_n[i];
82  double s = (-1.) * (normal * (start - max_pt)) / (normal * dir);
83  if (s < 0) continue;
84  auto xs = start + dir * s;
85  bool on_surface = true;
86  for (size_t sur_axis = 0; sur_axis < 3; ++sur_axis) {
87  if (sur_axis == i) continue;
88  if (xs[sur_axis] < min_pt[sur_axis] || max_pt[sur_axis] < xs[sur_axis]) {
89  on_surface = false;
90  break;
91  }
92  }
93  if (on_surface && xs != xs1) {
94  if (!(xs1.IsValid()))
95  for (size_t j = 0; j < 3; ++j)
96  xs1[j] = xs[j];
97  else {
98  for (size_t j = 0; j < 3; ++j)
99  xs2[j] = xs[j];
100  break;
101  }
102  }
103  }
104  if (!xs1.IsValid()) return result;
105  if (xs2.IsValid()) {
106  result.reserve(2);
107  if (xs1._SqDist_(start) > xs2._SqDist_(start)) std::swap(xs1, xs2);
108  result.push_back(xs1);
109  result.push_back(xs2);
110  return result;
111  }
112  result.push_back(xs1);
113  return result;
114  }
recob::tracking::Point_t Point_t
TDirectory * dir
Definition: macro.C:5
Vector Vector_t
Point has same feature as Vector.
Definition: GeoVector.h:203
std::vector<Point_t> geoalgo::GeoAlgo::Intersection ( const HalfLine_t line,
const AABox_t box,
bool  back = false 
) const
inline

Intersection between a HalfLine and an AABox.

Definition at line 55 of file GeoAlgo.h.

References Intersection().

58  {
59  return Intersection(box, line, back);
60  }
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
std::vector< Point_t > geoalgo::GeoAlgo::Intersection ( const AABox_t box,
const LineSegment_t l 
) const

Intersection between LineSegment and an AABox.

Definition at line 117 of file GeoAlgo.cxx.

References geoalgo::HalfLine::Dir(), geoalgo::LineSegment::End(), Intersection(), pt, geoalgo::LineSegment::Start(), and geoalgo::HalfLine::Start().

118  {
119  auto const& st = line.Start();
120  auto const& ed = line.End();
121  // Create a static HalfLine_t for this algorithm
122  static HalfLine_t hline(st, ed - st);
123  hline.Start(st[0], st[1], st[2]);
124  hline.Dir(ed[0] - st[0], ed[1] - st[1], ed[2] - st[2]);
125 
126  auto hline_result = Intersection(box, hline);
127 
128  if (!hline_result.size()) return hline_result;
129 
130  // For non-empty result, only keep ones that is within the line length
131  std::vector<Point_t> result;
132  auto length = st._SqDist_(ed);
133  for (auto const& pt : hline_result)
134  if (st._SqDist_(pt) < length) result.push_back(pt);
135  return result;
136  }
HalfLine HalfLine_t
Definition: GeoHalfLine.h:94
TMarker * pt
Definition: egs.C:25
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
std::vector<Point_t> geoalgo::GeoAlgo::Intersection ( const LineSegment_t l,
const AABox_t box 
) const
inline

Intersection between LineSegment and an AABox.

Definition at line 65 of file GeoAlgo.h.

References Intersection().

66  {
67  return Intersection(box, l);
68  }
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
std::vector< Point_t > geoalgo::GeoAlgo::Intersection ( const AABox_t box,
const Trajectory_t trj 
) const

Intersection between Trajectory and an AABox.

Definition at line 139 of file GeoAlgo.cxx.

References geoalgo::Trajectory::compat(), geoalgo::HalfLine::Dir(), Intersection(), geoalgo::AABox::Min(), pt, and geoalgo::HalfLine::Start().

140  {
141 
142  std::vector<Point_t> result;
143  if (trj.size() < 2) return result; // If only 1 point, return
144  // Check compat
145  trj.compat(box.Min());
146  // Call the onetime-only HalfLine constructor
147  static HalfLine_t hline(trj[0], trj[1]);
148  for (size_t i = 0; i < trj.size() - 1; ++i) {
149 
150  auto const& st = trj[i];
151  auto const& ed = trj[i + 1];
152  hline.Start(st[0], st[1], st[2]);
153  hline.Dir(ed[0] - st[0], ed[1] - st[1], ed[2] - st[2]);
154 
155  auto hline_result = Intersection(box, hline);
156 
157  if (!hline_result.size()) continue;
158 
159  // Check if the length makes sense
160  auto length = st._SqDist_(ed);
161  for (auto const& pt : hline_result)
162  if (st._SqDist_(pt) < length) result.push_back(pt);
163  }
164  return result;
165  }
HalfLine HalfLine_t
Definition: GeoHalfLine.h:94
TMarker * pt
Definition: egs.C:25
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
std::vector<Point_t> geoalgo::GeoAlgo::Intersection ( const Trajectory_t trj,
const AABox_t box 
) const
inline

Intersection between Trajectory and an AABox.

Definition at line 73 of file GeoAlgo.h.

References BoxOverlap(), and Intersection().

74  {
75  return Intersection(box, trj);
76  }
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 geoalgo::GeoAlgo::SqDist ( const Line_t line,
const Point_t pt 
) const
inline

Definition at line 98 of file GeoAlgo.h.

References _SqDist_(), geoalgo::Vector::compat(), and geoalgo::Line::Pt1().

Referenced by ClosestPt(), geoalgo::Cylinder::Contain(), and SqDist().

99  {
100  pt.compat(line.Pt1());
101  return _SqDist_(line, pt);
102  }
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
TMarker * pt
Definition: egs.C:25
double geoalgo::GeoAlgo::SqDist ( const Point_t pt,
const Line_t line 
) const
inline

Definition at line 104 of file GeoAlgo.h.

References SqDist().

Referenced by SqDist().

104 { return SqDist(line, pt); }
double SqDist(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:98
TMarker * pt
Definition: egs.C:25
double geoalgo::GeoAlgo::SqDist ( const Line_t l1,
const Line_t l2,
Point_t L1,
Point_t L2 
) const
inline

Definition at line 118 of file GeoAlgo.h.

References _SqDist_(), geoalgo::Vector::compat(), and geoalgo::Line::Pt1().

119  {
120  l1.Pt1().compat(l2.Pt1());
121  return _SqDist_(l1, l2, L1, L2);
122  }
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 geoalgo::GeoAlgo::SqDist ( const Line_t l1,
const Line_t l2 
) const
inline

Definition at line 124 of file GeoAlgo.h.

References SqDist().

125  {
126  Point_t L1;
127  Point_t L2;
128  return SqDist(l1, l2, L1, L2);
129  }
double SqDist(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:98
recob::tracking::Point_t Point_t
double geoalgo::GeoAlgo::SqDist ( const HalfLine_t l1,
const HalfLine_t l2,
Point_t L1,
Point_t L2 
) const
inline

Definition at line 135 of file GeoAlgo.h.

References _SqDist_(), geoalgo::Vector::compat(), and geoalgo::HalfLine::Start().

136  {
137  l1.Start().compat(l2.Start());
138  return _SqDist_(l1, l2, L1, L2);
139  }
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 geoalgo::GeoAlgo::SqDist ( const HalfLine_t l1,
const HalfLine_t l2 
) const
inline

Definition at line 141 of file GeoAlgo.h.

References SqDist().

142  {
143  Point_t L1;
144  Point_t L2;
145  return SqDist(l1, l2, L1, L2);
146  }
double SqDist(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:98
recob::tracking::Point_t Point_t
double geoalgo::GeoAlgo::SqDist ( const LineSegment_t seg1,
const LineSegment_t seg2,
Point_t c1,
Point_t c2 
) const
inline

LineSegment_t & LineSegment_t distance - keep track of points.

Definition at line 152 of file GeoAlgo.h.

References _SqDist_(), geoalgo::Vector::compat(), and geoalgo::LineSegment::Start().

156  {
157  seg1.Start().compat(seg2.Start());
158  return _SqDist_(seg1, seg2, c1, c2);
159  }
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
TCanvas * c1
Definition: plotHisto.C:7
TCanvas * c2
Definition: plot_hist.C:75
double geoalgo::GeoAlgo::SqDist ( const LineSegment_t seg1,
const LineSegment_t seg2 
) const
inline

LineSegment & LineSegment, don't keep track of points.

Definition at line 161 of file GeoAlgo.h.

References c1, c2, and SqDist().

162  {
163  Point_t c1;
164  Point_t c2;
165  return SqDist(seg1, seg2, c1, c2);
166  }
double SqDist(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:98
recob::tracking::Point_t Point_t
TCanvas * c1
Definition: plotHisto.C:7
TCanvas * c2
Definition: plot_hist.C:75
double geoalgo::GeoAlgo::SqDist ( const LineSegment_t seg,
const Trajectory_t trj,
Point_t c1,
Point_t c2 
) const

LineSegment & Trajectory, keep track of points.

Definition at line 633 of file GeoAlgo.cxx.

References _SqDist_(), geoalgo::Trajectory::compat(), geoalgo::kMAX_DOUBLE, and geoalgo::LineSegment::Start().

637  {
638 
639  // Make sure trajectory object is properly defined
640  if (!trj.size()) throw GeoAlgoException("Trajectory object not properly set...");
641 
642  // Check dimensionality compatibility between point and trajectory
643  trj.compat(seg.Start());
644 
645  // keep track of c1 & c2
646  Point_t c1min;
647  Point_t c2min;
648  // Now keep track of smallest distance and loop over traj segments
649  double distMin = kMAX_DOUBLE;
650 
651  for (size_t l = 0; l < trj.size() - 1; l++) {
652  LineSegment_t segTmp(trj[l], trj[l + 1]);
653  double distTmp = _SqDist_(segTmp, seg, c1min, c2min);
654  if (distTmp < distMin) {
655  c1 = c1min;
656  c2 = c2min;
657  distMin = distTmp;
658  }
659  } //for all segments in the track
660 
661  return distMin;
662  }
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
recob::tracking::Point_t Point_t
TCanvas * c1
Definition: plotHisto.C:7
LineSegment LineSegment_t
TCanvas * c2
Definition: plot_hist.C:75
static const double kMAX_DOUBLE
double geoalgo::GeoAlgo::SqDist ( const Trajectory_t trj,
const LineSegment_t seg,
Point_t c1,
Point_t c2 
) const
inline

LineSegment & Trajectory, keep track of points.

Definition at line 177 of file GeoAlgo.h.

References SqDist().

178  {
179  return SqDist(seg, trj, c1, c2);
180  }
double SqDist(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:98
TCanvas * c1
Definition: plotHisto.C:7
TCanvas * c2
Definition: plot_hist.C:75
double geoalgo::GeoAlgo::SqDist ( const Trajectory_t trj,
const LineSegment_t seg 
) const
inline

LineSegment & Trajectory, don't keep track of points.

Definition at line 182 of file GeoAlgo.h.

References c1, c2, and SqDist().

183  {
184  Point_t c1;
185  Point_t c2;
186  return SqDist(seg, trj, c1, c2);
187  }
double SqDist(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:98
recob::tracking::Point_t Point_t
TCanvas * c1
Definition: plotHisto.C:7
TCanvas * c2
Definition: plot_hist.C:75
double geoalgo::GeoAlgo::SqDist ( const LineSegment_t seg,
const Trajectory_t trj 
) const
inline

LineSegment & Trajectory, don't keep track of points.

Definition at line 189 of file GeoAlgo.h.

References c1, c2, and SqDist().

190  {
191  Point_t c1;
192  Point_t c2;
193  return SqDist(seg, trj, c1, c2);
194  }
double SqDist(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:98
recob::tracking::Point_t Point_t
TCanvas * c1
Definition: plotHisto.C:7
TCanvas * c2
Definition: plot_hist.C:75
double geoalgo::GeoAlgo::SqDist ( const Trajectory_t trj1,
const Trajectory_t trj2,
Point_t c1,
Point_t c2 
) const

Trajectory & Trajectory, keep track of points.

Definition at line 667 of file GeoAlgo.cxx.

References _SqDist_(), geoalgo::Trajectory::compat(), and geoalgo::kMAX_DOUBLE.

671  {
672 
673  // Make sure trajectory object is properly defined
674  if (!trj1.size() or !trj2.size())
675  throw GeoAlgoException("Trajectory object not properly set...");
676 
677  // Check dimensionality compatibility between point and trajectory
678  trj1.compat(trj2[0]);
679 
680  // keep track of c1 & c2
681  Point_t c1min;
682  Point_t c2min;
683  // Now keep track of smallest distance and loop over traj segments
684  double distMin = kMAX_DOUBLE;
685 
686  for (size_t l1 = 0; l1 < trj1.size() - 1; l1++) {
687  for (size_t l2 = 0; l2 < trj2.size() - 1; l2++) {
688  LineSegment_t segTmp1(trj1[l1], trj1[l1 + 1]);
689  LineSegment_t segTmp2(trj2[l2], trj2[l2 + 1]);
690  double distTmp = _SqDist_(segTmp1, segTmp2, c1min, c2min);
691  if (distTmp < distMin) {
692  c1 = c1min;
693  c2 = c2min;
694  distMin = distTmp;
695  }
696  } // for segments in trajectory 2
697  } //for all segments in trajectory 1
698 
699  return distMin;
700  }
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
recob::tracking::Point_t Point_t
TCanvas * c1
Definition: plotHisto.C:7
LineSegment LineSegment_t
TCanvas * c2
Definition: plot_hist.C:75
static const double kMAX_DOUBLE
double geoalgo::GeoAlgo::SqDist ( const Trajectory_t trj1,
const Trajectory_t trj2 
) const
inline

Trajectory & Trajectory, don't keep track of points.

Definition at line 205 of file GeoAlgo.h.

References c1, c2, and SqDist().

206  {
207  Point_t c1;
208  Point_t c2;
209  return SqDist(trj1, trj2, c1, c2);
210  }
double SqDist(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:98
recob::tracking::Point_t Point_t
TCanvas * c1
Definition: plotHisto.C:7
TCanvas * c2
Definition: plot_hist.C:75
double geoalgo::GeoAlgo::SqDist ( const LineSegment_t seg,
const std::vector< geoalgo::Trajectory_t > &  trj,
Point_t c1,
Point_t c2,
int &  trackIdx 
) const

LineSegment & vector of Trajectories, keep track of points.

Definition at line 740 of file GeoAlgo.cxx.

References geoalgo::kMAX_DOUBLE, and SqDist().

745  {
746 
747  // holders to keep track of track with shortest distance
748  double minDist = kMAX_DOUBLE;
749  // holders for points of closest approach
750  Point_t c1min;
751  Point_t c2min;
752 
753  for (size_t t = 0; t < trj.size(); t++) {
754 
755  //need to loop over all tracks and find the one which is closest
756 
757  // dimensionality checks will be done in next function, per track.
758 
759  // now calculate closest approach
760  double tmpDist = SqDist(seg, trj[t], c1min, c2min);
761 
762  // is this the best yet?
763  if (tmpDist < minDist) {
764  minDist = tmpDist;
765  c1 = c1min;
766  c2 = c2min;
767  trackIdx = t;
768  }
769 
770  } // for all tracks in vector
771 
772  return minDist;
773  }
double SqDist(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:98
recob::tracking::Point_t Point_t
TCanvas * c1
Definition: plotHisto.C:7
TCanvas * c2
Definition: plot_hist.C:75
static const double kMAX_DOUBLE
double geoalgo::GeoAlgo::SqDist ( const std::vector< geoalgo::Trajectory_t > &  trj,
const LineSegment_t seg,
Point_t c1,
Point_t c2,
int &  trackIdx 
) const
inline

LineSegment & vector of Trajectories, keep track of points.

Definition at line 222 of file GeoAlgo.h.

References SqDist().

227  {
228  return SqDist(seg, trj, c2, c1, trackIdx);
229  }
double SqDist(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:98
TCanvas * c1
Definition: plotHisto.C:7
TCanvas * c2
Definition: plot_hist.C:75
double geoalgo::GeoAlgo::SqDist ( const std::vector< geoalgo::Trajectory_t > &  trj,
const LineSegment_t seg 
) const
inline

LineSegment & vector of Trajectories, don't keep track of points.

Definition at line 231 of file GeoAlgo.h.

References c1, c2, and SqDist().

232  {
233  Point_t c1;
234  Point_t c2;
235  int trackIdx;
236  return SqDist(seg, trj, c1, c2, trackIdx);
237  }
double SqDist(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:98
recob::tracking::Point_t Point_t
TCanvas * c1
Definition: plotHisto.C:7
TCanvas * c2
Definition: plot_hist.C:75
double geoalgo::GeoAlgo::SqDist ( const LineSegment_t seg,
const std::vector< geoalgo::Trajectory_t > &  trj 
) const
inline

LineSegment & vector of Trajectories, don't keep track of points.

Definition at line 239 of file GeoAlgo.h.

References c1, c2, and SqDist().

240  {
241  Point_t c1;
242  Point_t c2;
243  int trackIdx;
244  return SqDist(seg, trj, c1, c2, trackIdx);
245  }
double SqDist(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:98
recob::tracking::Point_t Point_t
TCanvas * c1
Definition: plotHisto.C:7
TCanvas * c2
Definition: plot_hist.C:75
double geoalgo::GeoAlgo::SqDist ( const HalfLine_t hline,
const Trajectory_t trj,
Point_t c1,
Point_t c2 
) const

HalfLine & Trajectory, keep track of points.

Definition at line 705 of file GeoAlgo.cxx.

References _SqDist_(), geoalgo::Trajectory::compat(), geoalgo::kMAX_DOUBLE, and geoalgo::HalfLine::Start().

709  {
710 
711  // Make sure trajectory object is properly defined
712  if (!trj.size()) throw GeoAlgoException("Trajectory object not properly set...");
713 
714  // Check dimensionality compatibility between point and trajectory
715  trj.compat(hline.Start());
716 
717  // keep track of c1 & c2
718  Point_t c1min;
719  Point_t c2min;
720  // Now keep track of smallest distance and loop over traj segments
721  double distMin = kMAX_DOUBLE;
722 
723  for (size_t l = 0; l < trj.size() - 1; l++) {
724  LineSegment_t segTmp(trj[l], trj[l + 1]);
725  double distTmp = _SqDist_(hline, segTmp, c1min, c2min);
726  if (distTmp < distMin) {
727  c1 = c1min;
728  c2 = c2min;
729  distMin = distTmp;
730  }
731  } //for all segments in the track
732 
733  return distMin;
734  }
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
recob::tracking::Point_t Point_t
TCanvas * c1
Definition: plotHisto.C:7
LineSegment LineSegment_t
TCanvas * c2
Definition: plot_hist.C:75
static const double kMAX_DOUBLE
double geoalgo::GeoAlgo::SqDist ( const Trajectory_t trj,
const HalfLine_t hline,
Point_t c1,
Point_t c2 
) const
inline

HalfLine & Trajectory, keep track of points.

Definition at line 253 of file GeoAlgo.h.

References SqDist().

254  {
255  return SqDist(hline, trj, c2, c1);
256  }
double SqDist(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:98
TCanvas * c1
Definition: plotHisto.C:7
TCanvas * c2
Definition: plot_hist.C:75
double geoalgo::GeoAlgo::SqDist ( const Trajectory_t trj,
const HalfLine_t hline 
) const
inline

HalfLine & Trajectory, don't keep track of points.

Definition at line 258 of file GeoAlgo.h.

References c1, c2, and SqDist().

259  {
260  Point_t c1;
261  Point_t c2;
262  return SqDist(hline, trj, c1, c2);
263  }
double SqDist(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:98
recob::tracking::Point_t Point_t
TCanvas * c1
Definition: plotHisto.C:7
TCanvas * c2
Definition: plot_hist.C:75
double geoalgo::GeoAlgo::SqDist ( const HalfLine_t hline,
const Trajectory_t trj 
) const
inline

HalfLine & Trajectory, don't keep track of points.

Definition at line 265 of file GeoAlgo.h.

References c1, c2, pt, and SqDist().

266  {
267  Point_t c1;
268  Point_t c2;
269  return SqDist(hline, trj, c1, c2);
270  }
double SqDist(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:98
recob::tracking::Point_t Point_t
TCanvas * c1
Definition: plotHisto.C:7
TCanvas * c2
Definition: plot_hist.C:75
double geoalgo::GeoAlgo::SqDist ( const Point_t pt,
const Trajectory_t trj 
) const

Point_t & Trajectory_t distance.

Definition at line 523 of file GeoAlgo.cxx.

References _SqDist_(), geoalgo::Trajectory::compat(), and geoalgo::kINVALID_DOUBLE.

524  {
525 
526  // Make sure trajectory object is properly defined
527  if (!trj.size()) throw GeoAlgoException("Trajectory object not properly set...");
528 
529  // Check dimensionality compatibility between point and trajectory
530  trj.compat(pt);
531 
532  // Now keep track of smallest distance and loop over traj segments
533  double distMin = kINVALID_DOUBLE;
534  for (size_t l = 0; l < trj.size() - 1; l++) {
535  double distTmp = _SqDist_(pt, trj[l], trj[l + 1]);
536  if (distTmp < distMin) { distMin = distTmp; }
537  }
538 
539  return distMin;
540  }
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
TMarker * pt
Definition: egs.C:25
static const double kINVALID_DOUBLE
double geoalgo::GeoAlgo::SqDist ( const Trajectory_t trj,
const Point_t pt 
) const
inline

Point_t & Trajectory_t distance.

Definition at line 278 of file GeoAlgo.h.

References SqDist().

Referenced by SqDist().

278 { return SqDist(pt, trj); }
double SqDist(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:98
TMarker * pt
Definition: egs.C:25
double geoalgo::GeoAlgo::SqDist ( const Point_t pt,
const std::vector< geoalgo::Trajectory_t > &  trj,
int &  trackIdx 
) const

Point_t & Trajectory_t distance - keep track of which track.

Definition at line 545 of file GeoAlgo.cxx.

References geoalgo::kINVALID_DOUBLE, and SqDist().

548  {
549 
550  // holder for shortest distance
551  double minDist = kINVALID_DOUBLE;
552 
553  // loop over trajectories
554  for (size_t t = 0; t < trj.size(); t++) {
555 
556  // trajectory & point dimensionality will be checked in next function
557  // now calculate distance w.r.t. this track
558  double tmpDist = SqDist(pt, trj[t]);
559  if (tmpDist < minDist) {
560  minDist = tmpDist;
561  trackIdx = t;
562  }
563  } // for all tracks
564 
565  return minDist;
566  }
double SqDist(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:98
TMarker * pt
Definition: egs.C:25
static const double kINVALID_DOUBLE
double geoalgo::GeoAlgo::SqDist ( const std::vector< geoalgo::Trajectory_t > &  trj,
const Point_t pt,
int &  trackIdx 
) const
inline

Point_t & Trajectory_t distance - keep track of which track.

Definition at line 307 of file GeoAlgo.h.

References SqDist().

310  {
311  return SqDist(pt, trj, trackIdx);
312  }
double SqDist(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:98
TMarker * pt
Definition: egs.C:25
double geoalgo::GeoAlgo::SqDist ( const Point_t pt,
const std::vector< geoalgo::Trajectory_t > &  trj 
) const
inline

Point_t & Trajectory_t distance - don't keep track.

Definition at line 314 of file GeoAlgo.h.

References SqDist().

315  {
316  int trackIdx;
317  return SqDist(pt, trj, trackIdx);
318  }
double SqDist(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:98
TMarker * pt
Definition: egs.C:25
double geoalgo::GeoAlgo::SqDist ( const std::vector< geoalgo::Trajectory_t > &  trj,
const Point_t pt 
) const
inline

Point_t & Trajectory_t distance - don't keep track.

Definition at line 320 of file GeoAlgo.h.

References ClosestPt(), and SqDist().

321  {
322  int trackIdx;
323  return SqDist(pt, trj, trackIdx);
324  }
double SqDist(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:98
TMarker * pt
Definition: egs.C:25
double geoalgo::GeoAlgo::SqDist ( const Point_t pt,
const LineSegment_t line 
) const
inline

Point & LineSegment_t distance.

Definition at line 353 of file GeoAlgo.h.

References _SqDist_(), geoalgo::Vector::compat(), and geoalgo::LineSegment::Start().

354  {
355  pt.compat(line.Start());
356  return _SqDist_(pt, line);
357  }
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
TMarker * pt
Definition: egs.C:25
double geoalgo::GeoAlgo::SqDist ( const LineSegment_t line,
const Point_t pt 
) const
inline

Point & LineSegment distance.

Definition at line 359 of file GeoAlgo.h.

References SqDist().

Referenced by SqDist().

359 { return SqDist(pt, line); }
double SqDist(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:98
TMarker * pt
Definition: egs.C:25
double geoalgo::GeoAlgo::SqDist ( const Point_t pt,
const HalfLine_t line 
) const
inline

Point & HalfLine distance.

Definition at line 376 of file GeoAlgo.h.

References _SqDist_(), geoalgo::Vector::compat(), and geoalgo::HalfLine::Start().

377  {
378  pt.compat(line.Start());
379  return _SqDist_(pt, line);
380  }
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
TMarker * pt
Definition: egs.C:25
double geoalgo::GeoAlgo::SqDist ( const HalfLine_t line,
const Point_t pt 
) const
inline

Point & HalfLine distance.

Definition at line 382 of file GeoAlgo.h.

References SqDist().

Referenced by SqDist().

382 { return SqDist(pt, line); }
double SqDist(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:98
TMarker * pt
Definition: egs.C:25
double geoalgo::GeoAlgo::SqDist ( const HalfLine_t hline,
const LineSegment_t seg,
Point_t L1,
Point_t L2 
) const
inline

Definition at line 399 of file GeoAlgo.h.

References _SqDist_(), geoalgo::Vector::compat(), geoalgo::LineSegment::Start(), and geoalgo::HalfLine::Start().

400  {
401  hline.Start().compat(seg.Start());
402  return _SqDist_(hline, seg, L1, L2);
403  }
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 geoalgo::GeoAlgo::SqDist ( const LineSegment_t seg,
const HalfLine_t hline,
Point_t L1,
Point_t L2 
) const
inline

Definition at line 405 of file GeoAlgo.h.

References SqDist().

406  {
407  return SqDist(hline, seg, L2, L1);
408  }
double SqDist(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:98
double geoalgo::GeoAlgo::SqDist ( const HalfLine_t hline,
const LineSegment_t seg 
) const
inline

Definition at line 410 of file GeoAlgo.h.

References SqDist().

411  {
412  Point_t L1;
413  Point_t L2;
414  return SqDist(hline, seg, L1, L2);
415  }
double SqDist(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:98
recob::tracking::Point_t Point_t
double geoalgo::GeoAlgo::SqDist ( const LineSegment_t seg,
const HalfLine_t hline 
) const
inline

Definition at line 417 of file GeoAlgo.h.

References SqDist().

418  {
419  return SqDist(hline, seg);
420  }
double SqDist(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:98
double geoalgo::GeoAlgo::SqDist ( const Point_t pt,
const AABox_t box 
) const
inline

Point & AABox distance.

Definition at line 426 of file GeoAlgo.h.

References _SqDist_(), geoalgo::Vector::compat(), and geoalgo::AABox::Min().

427  {
428  pt.compat(box.Min());
429  return _SqDist_(pt, box);
430  }
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
TMarker * pt
Definition: egs.C:25
double geoalgo::GeoAlgo::SqDist ( const AABox_t box,
const Point_t pt 
)
inline

Point & AABox distance.

Definition at line 432 of file GeoAlgo.h.

References SqDist().

Referenced by SqDist().

432 { return SqDist(pt, box); }
double SqDist(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:98
TMarker * pt
Definition: egs.C:25

The documentation for this class was generated from the following files: