StRoot  1
Line.cc
1 //
2 // Pibero Djawotho <pibero@indiana.edu>
3 // Indiana University Cyclotron Facility
4 // 23 September 2005
5 //
6
7 // Local
8 #include "Line.hh"
9 using namespace std;
10 Line::Line(const StThreeVectorD& o, const StThreeVectorD& d)
11 {
12  mOrigin = o;
13  mDirection = d.unit();
14 }
15
16 StThreeVectorD Line::at(double pathlength) const
17 {
18  return mOrigin + pathlength * mDirection;
19 }
20
21 double Line::pathlength(const StThreeVectorD& point) const
22 {
23  return mDirection.dot(point - mOrigin);
24 }
25
27 {
28  return at(pathlength(point));
29 }
30
31 StThreeVectorD Line::dca(const Line& line) const
32 {
33  double cosAngle = mDirection.dot(line.direction());
34  double delta = cosAngle * cosAngle - 1;
35  StThreeVectorD distance = mOrigin - line.origin();
36  double pathlength = (distance.dot(mDirection) - cosAngle * distance.dot(line.direction())) / delta;
37  double pathlength2 = (cosAngle * distance.dot(mDirection) - distance.dot(line.direction())) / delta;
38  return at(pathlength) - line.at(pathlength2);
39 }
40
41 pair<double, double> Line::pathlengths(const Line& line) const
42 {
43  double cosAngle = mDirection.dot(line.direction());
44  double delta = cosAngle * cosAngle - 1;
45  double s = pathlength(line.origin());
46  double t = line.pathlength(mOrigin);
47  return make_pair(-(s + t * cosAngle) / delta, -(s * cosAngle + t) / delta);
48 }
StThreeVectorD at(double pathlength) const
Point at a given path length along the line.
Definition: Line.cc:16
STAR includes.
Definition: Line.hh:23
StThreeVectorD perigee(const StThreeVectorD &point) const
Perigee, i.e. Closest point on the line to a given point.
Definition: Line.cc:26
StThreeVectorD dca(const Line &line) const
DCA = Distance of Closest Approach to a given line.
Definition: Line.cc:31
double pathlength(const StThreeVectorD &point) const
Pathlength of a given point from the origin of the line.
Definition: Line.cc:21
StThreeVectorD direction() const
Direction vector of the line (normalized to the unit vector)
Definition: Line.hh:95
StThreeVectorD origin() const
Origin of the line.
Definition: Line.hh:94
pair< double, double > pathlengths(const Line &line) const
Pathlengths of the points of closest approach between the lines.
Definition: Line.cc:41