25#define TLINE2D_INLINE_DEFINE_HERE
26#define HEP_SHORT_NAMES
27#include "CLHEP/Alist/ConstAList.h"
28#include "TrkReco/TPoint2D.h"
29#include "TrkReco/TLine2D.h"
47 if (_list)
delete _list;
72 if (! _list)
return -1;
74 unsigned n = _list->length();
78 double x0 = (* _list)[0]->x();
79 double y0 = (* _list)[0]->y();
80 double x1 = (* _list)[1]->x();
81 double y1 = (* _list)[1]->y();
82 if (x0 == x1)
return -2;
83 _slope = (y0 - y1) / (x0 - x1);
84 _yOffset = - _slope * x1 + y1;
89 double sum = double(
n);
90 double sumX = 0., sumY = 0., sumX2 = 0., sumXY = 0., sumY2 = 0.;
91 for (
unsigned i = 0; i <
n; i++) {
102 _det = sum * sumX2 - sumX * sumX;
103 if (_det == 0.)
return -3;
105 _slope = (sumXY * sum - sumX * sumY) / _det;
106 _yOffset = (sumX2 * sumY - sumX * sumXY) / _det;
113 double ydif = p.
y() - _yOffset;
114 double vmag = sqrt(1. + _slope * _slope);
115 double dot = (p.
x() + ydif * _slope) / vmag;
116 double xmag2 = p.
x() * p.
x() + ydif * ydif;
117 return sqrt(xmag2 - dot * dot);
double distance(const TPoint2D &) const
const CAList< TPoint2D > & list(void) const
void append(const TPoint2D &)
virtual ~TLine2D()
Destructor.
void remove(const TPoint2D &)
A class to represent a point in 2D.