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:
12 
15 
16 Line(){}
17 
18 //Line( const PositionType& pos, const DirectionType& dir) :
19 Line( PositionType& pos, DirectionType& dir) :
20  thePos(pos), theDir(dir.unit()) {}
21 
22 ~Line(){};
23 
24 //const PositionType& position() const { return thePos;}
25 //const DirectionType& direction() const { return theDir;}
26 PositionType position() const { return thePos;}
27 DirectionType direction() const { return theDir;}
28 
29 GlobalPoint closerPointToLine( const Line & aLine) const {
30 
31 GlobalPoint V = aLine.position();
32 GlobalVector J = aLine.direction();
33 GlobalVector Q = theDir - J.dot(theDir) * J;
34 double lambda = Q.dot(V-thePos)/Q.dot(theDir);
35 return thePos + lambda*theDir;
36 }
37 
38 GlobalVector distance( const Line & aLine) const {
39 
40 GlobalPoint V = aLine.position();
41 GlobalVector J = aLine.direction();
42 GlobalVector P = (theDir.cross(J)).unit();
44 D= P.dot(thePos-V) * P;
45 return D;
46 }
47 
48 GlobalVector distance(const GlobalPoint & aPoint) const {
49 
50 GlobalVector P(aPoint.x(),aPoint.y(),aPoint.z());
51 GlobalVector T0(thePos.x(),thePos.y(),thePos.z());
52 return T0-P + theDir.dot(P-T0) * theDir;
53 }
54 
55 private:
56  PositionType thePos;
57  DirectionType theDir;
58 };
59 
60 
61 
62 #endif // Geom_Line_H
63 
64 
65 
66 
67 
68 
DirectionType theDir
Definition: Line.h:57
DirectionType direction() const
Definition: Line.h:27
~Line()
Definition: Line.h:22
GlobalVector DirectionType
Definition: Line.h:14
Line(PositionType &pos, DirectionType &dir)
Definition: Line.h:19
Line()
Definition: Line.h:16
Definition: Line.h:10
T y() const
Definition: PV3DBase.h:63
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:107
GlobalPoint PositionType
Definition: Line.h:13
PositionType thePos
Definition: Line.h:56
GlobalVector distance(const Line &aLine) const
Definition: Line.h:38
PositionType position() const
Definition: Line.h:26
Vector3DBase< typename PreciseFloatType< T, U >::Type, FrameTag > cross(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:119
T z() const
Definition: PV3DBase.h:64
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:150
GlobalPoint closerPointToLine(const Line &aLine) const
Definition: Line.h:29
GlobalVector distance(const GlobalPoint &aPoint) const
Definition: Line.h:48
std::pair< OmniClusterRef, TrackingParticleRef > P
dbl *** dir
Definition: mlp_gen.cc:35
T x() const
Definition: PV3DBase.h:62