CMS 3D CMS Logo

Line.h
Go to the documentation of this file.
1 #ifndef Geom_Line_H
2 #define Geom_Line_H
3 
6 
10 class Line {
11 public:
14 
15  Line() {}
16 
17  //Line( const PositionType& pos, const DirectionType& dir) :
18  Line(PositionType& pos, DirectionType& dir) : thePos(pos), theDir(dir.unit()) {}
19 
20  ~Line(){};
21 
22  //const PositionType& position() const { return thePos;}
23  //const DirectionType& direction() const { return theDir;}
24  PositionType position() const { return thePos; }
25  DirectionType direction() const { return theDir; }
26 
27  GlobalPoint closerPointToLine(const Line& aLine) const {
28  GlobalPoint V = aLine.position();
29  GlobalVector J = aLine.direction();
30  GlobalVector Q = theDir - J.dot(theDir) * J;
31  double lambda = Q.dot(V - thePos) / Q.dot(theDir);
32  return thePos + lambda * theDir;
33  }
34 
35  GlobalVector distance(const Line& aLine) const {
36  GlobalPoint V = aLine.position();
37  GlobalVector J = aLine.direction();
38  GlobalVector P = (theDir.cross(J)).unit();
40  D = P.dot(thePos - V) * P;
41  return D;
42  }
43 
44  GlobalVector distance(const GlobalPoint& aPoint) const {
45  GlobalVector P(aPoint.x(), aPoint.y(), aPoint.z());
46  GlobalVector T0(thePos.x(), thePos.y(), thePos.z());
47  return T0 - P + theDir.dot(P - T0) * theDir;
48  }
49 
50 private:
51  PositionType thePos;
52  DirectionType theDir;
53 };
54 
55 #endif // Geom_Line_H
DirectionType theDir
Definition: Line.h:52
Vector3DBase< typename PreciseFloatType< T, U >::Type, FrameTag > cross(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:110
DirectionType direction() const
Definition: Line.h:25
~Line()
Definition: Line.h:20
GlobalVector DirectionType
Definition: Line.h:13
Line(PositionType &pos, DirectionType &dir)
Definition: Line.h:18
Line()
Definition: Line.h:15
Definition: Line.h:10
T y() const
Definition: PV3DBase.h:60
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:99
GlobalPoint PositionType
Definition: Line.h:12
PositionType thePos
Definition: Line.h:51
GlobalVector distance(const Line &aLine) const
Definition: Line.h:35
PositionType position() const
Definition: Line.h:24
T z() const
Definition: PV3DBase.h:61
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:141
GlobalPoint closerPointToLine(const Line &aLine) const
Definition: Line.h:27
GlobalVector distance(const GlobalPoint &aPoint) const
Definition: Line.h:44
std::pair< OmniClusterRef, TrackingParticleRef > P
T x() const
Definition: PV3DBase.h:59
Basic3DVector unit() const