CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/DataFormats/GeometrySurface/interface/Line.h

Go to the documentation of this file.
00001 #ifndef Geom_Line_H
00002 #define Geom_Line_H
00003 
00004 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00005 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
00006 
00010 class Line {
00011 public:
00012 
00013 typedef GlobalPoint           PositionType;
00014 typedef GlobalVector          DirectionType;
00015 
00016 Line(){}
00017 
00018 //Line( const PositionType& pos, const  DirectionType& dir) :
00019 Line(  PositionType& pos,  DirectionType& dir) :
00020   thePos(pos), theDir(dir.unit()) {}
00021 
00022 ~Line(){};
00023 
00024 //const PositionType& position()   const { return thePos;}
00025 //const DirectionType& direction() const { return theDir;}
00026 PositionType position()   const  { return thePos;}
00027 DirectionType direction() const  { return theDir;}
00028 
00029 GlobalPoint closerPointToLine( const Line & aLine) const {
00030 
00031 GlobalPoint  V = aLine.position();
00032 GlobalVector J = aLine.direction();
00033 GlobalVector Q = theDir - J.dot(theDir) * J;
00034 double lambda = Q.dot(V-thePos)/Q.dot(theDir);
00035 return   thePos + lambda*theDir;
00036 }
00037 
00038 GlobalVector distance( const Line & aLine) const {
00039 
00040 GlobalPoint  V = aLine.position();
00041 GlobalVector J = aLine.direction();
00042 GlobalVector P = (theDir.cross(J)).unit();
00043 GlobalVector D;
00044 D= P.dot(thePos-V) * P;
00045 return D;
00046 }
00047 
00048 GlobalVector distance(const GlobalPoint & aPoint) const {
00049 
00050 GlobalVector P(aPoint.x(),aPoint.y(),aPoint.z());
00051 GlobalVector T0(thePos.x(),thePos.y(),thePos.z());
00052 return T0-P + theDir.dot(P-T0) * theDir;
00053 }
00054 
00055 private:
00056   PositionType  thePos;
00057   DirectionType  theDir;
00058 };
00059   
00060 
00061 
00062 #endif // Geom_Line_H
00063 
00064 
00065 
00066 
00067 
00068