G4Line Class Reference

#include <G4Line.hh>

Inheritance diagram for G4Line:

G4Curve

Public Member Functions

 G4Line ()
virtual ~G4Line ()
 G4Line (const G4Line &orig)
G4Lineoperator= (const G4Line &right)
G4CurveProject (const G4Transform3D &tr=G4Transform3D::Identity)
G4bool Tangent (G4CurvePoint &cp, G4Vector3D &vec)
G4double GetPMax () const
G4Point3D GetPoint (G4double param) const
G4double GetPPoint (const G4Point3D &pt) const
G4Point3D GetPnt () const
G4Vector3D GetDir () const
void Init (const G4Point3D &pnt0, const G4Vector3D &dir0)
G4int IntersectRay2D (const G4Ray &ray)

Protected Member Functions

void InitBounded ()

Detailed Description

Definition at line 44 of file G4Line.hh.


Constructor & Destructor Documentation

G4Line::G4Line (  ) 

Definition at line 38 of file G4Line.cc.

Referenced by Project().

00038 {}

G4Line::~G4Line (  )  [virtual]

Definition at line 39 of file G4Line.cc.

00039 {}

G4Line::G4Line ( const G4Line orig  ) 

Definition at line 41 of file G4Line.cc.

References G4Curve::bBox, G4Curve::bounded, G4Curve::end, G4Curve::pEnd, G4Curve::pRange, G4Curve::pStart, G4Curve::sameSense, and G4Curve::start.

00042   : G4Curve(), pnt(right.pnt), dir(right.dir),
00043     invDir(right.invDir), v(right.v)
00044 {
00045   bBox      = right.bBox;
00046   start     = right.start;
00047   end       = right.end;
00048   pStart    = right.pStart;
00049   pEnd      = right.pEnd;
00050   pRange    = right.pRange;
00051   bounded   = right.bounded;
00052   sameSense = right.sameSense;
00053 }


Member Function Documentation

G4Vector3D G4Line::GetDir (  )  const [inline]

Definition at line 73 of file G4Line.icc.

00074 {
00075   return dir;
00076 }

G4double G4Line::GetPMax (  )  const [inline, virtual]

Implements G4Curve.

Definition at line 38 of file G4Line.icc.

00039 {
00040   return -1;
00041 }

G4Point3D G4Line::GetPnt (  )  const [inline]

Definition at line 67 of file G4Line.icc.

00068 {
00069   return pnt;
00070 }

G4Point3D G4Line::GetPoint ( G4double  param  )  const [inline, virtual]

Implements G4Curve.

Definition at line 44 of file G4Line.icc.

00045 {
00046   return G4Point3D( pnt+param*dir );
00047 }

G4double G4Line::GetPPoint ( const G4Point3D pt  )  const [inline, virtual]

Implements G4Curve.

Definition at line 50 of file G4Line.icc.

00051 { 
00052   return (pt-pnt)*invDir; 
00053 }

void G4Line::Init ( const G4Point3D pnt0,
const G4Vector3D dir0 
) [inline]

Definition at line 58 of file G4Line.icc.

Referenced by G4CompositeCurve::G4CompositeCurve(), and Project().

00059 {
00060   pnt= pnt0;
00061   dir= dir0;
00062   invDir= dir*(1/dir.mag2());
00063   v= dir.unit();
00064 }

void G4Line::InitBounded (  )  [inline, protected, virtual]

Implements G4Curve.

Definition at line 81 of file G4Line.icc.

References G4Curve::bBox, G4Curve::GetEnd(), G4Curve::GetStart(), and G4BoundingBox3D::Init().

00082 {
00083   bBox.Init(GetStart(), GetEnd());
00084 }

G4int G4Line::IntersectRay2D ( const G4Ray ray  )  [inline, virtual]

Implements G4Curve.

Definition at line 131 of file G4Line.icc.

References G4Ray::GetDir(), G4Ray::GetStart(), and G4Curve::kCarTolerance.

00132 {
00133   const G4Point3D& st= ray.GetStart();
00134   const G4Vector3D& d= ray.GetDir();
00135 
00136   G4double num1= (pnt.x()-st.x())*d.y()-(pnt.y()-st.y())*d.x();
00137   G4double num2= (pnt.x()-st.x())*dir.y()-(pnt.y()-st.y())*dir.x();
00138   G4double denom= d.x()*dir.y()-d.y()*dir.x();
00139   
00140   G4int nbinter = 0;
00141 
00142   if (std::fabs(denom) < kCarTolerance) 
00143   {
00144     if (std::fabs(num1) < kCarTolerance) 
00145     {
00146       // identical lines
00147     } 
00148     else 
00149     {
00150       // parallel lines
00151     }
00152   } 
00153   else
00154   {
00155     // properly intersecting lines
00156     G4double u = num1/denom;
00157     G4double t = num2/denom;
00158 
00159     if( (u > -kCarTolerance/2) && (u < kCarTolerance/2) )
00160       u = 0;
00161 
00162     if( (t > -kCarTolerance/2) && (t < kCarTolerance/2) )
00163       t = 0;
00164     
00165     // test the validity of the results 
00166     if(t>=0 && u>=0 && u<=1)
00167     {
00168       // test if the point is on the line
00169       if( t==0 || u==0 )
00170         return 999;
00171       else      
00172         nbinter = 1;
00173     }
00174   }
00175   
00176   return nbinter;
00177 }

G4Line & G4Line::operator= ( const G4Line right  ) 

Definition at line 55 of file G4Line.cc.

References G4Curve::bBox, G4Curve::bounded, dir, G4Curve::end, invDir, G4Curve::pEnd, pnt, G4Curve::pRange, G4Curve::pStart, G4Curve::sameSense, G4Curve::start, and v.

00056 {
00057   if (&right == this) return *this;
00058   
00059   pnt       = right.pnt;
00060   dir       = right.dir;
00061   invDir    = right.invDir;
00062   v         = right.v;
00063   bBox      = right.bBox;
00064   start     = right.start;
00065   end       = right.end;
00066   pStart    = right.pStart;
00067   pEnd      = right.pEnd;
00068   pRange    = right.pRange;
00069   bounded   = right.bounded;
00070   sameSense = right.sameSense;
00071   
00072   return *this;
00073 }

G4Curve * G4Line::Project ( const G4Transform3D tr = G4Transform3D::Identity  )  [virtual]

Implements G4Curve.

Definition at line 75 of file G4Line.cc.

References G4Line(), G4Curve::GetPEnd(), G4Curve::GetPStart(), Init(), G4Curve::kCarTolerance, and G4Curve::SetBounds().

00076 {
00077   G4Vector3D newDir= tr*dir;
00078   
00079   if (std::abs(newDir.x())+std::abs(newDir.y()) < kCarTolerance){
00080   
00081      newDir.setX(kCarTolerance);
00082      newDir.setY(kCarTolerance);
00083   };
00084   
00085   G4Point3D newPnt= tr*pnt;
00086   newDir.setZ(0);
00087   newPnt.setZ(0);
00088   
00089   G4Line* r= new G4Line();
00090 
00091   // L. Broglia : terrible mistake !!!!
00092   //r->Init(newDir, newPnt);
00093   r->Init(newPnt, newDir);
00094 
00095   r->SetBounds(GetPStart(), GetPEnd());
00096   
00097   return r;
00098 }

G4bool G4Line::Tangent ( G4CurvePoint cp,
G4Vector3D vec 
) [virtual]

Implements G4Curve.

Definition at line 102 of file G4Line.cc.

References G4Curve::GetSameSense().

00103 {
00104   if(GetSameSense())
00105     vec = -dir;
00106   else
00107     vec = dir;
00108 
00109   return true;
00110 }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:52:25 2013 for Geant4 by  doxygen 1.4.7