G4Parabola.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 // ----------------------------------------------------------------------
00030 // GEANT 4 class source file
00031 //
00032 // G4Parabola.cc
00033 //
00034 // ----------------------------------------------------------------------
00035 
00036 #include "G4Parabola.hh"
00037 #include "G4CurvePoint.hh"
00038 #include "G4GeometryTolerance.hh"
00039 
00040 G4Parabola::G4Parabola() : focalDist(0.) {}
00041 G4Parabola::~G4Parabola(){}
00042 
00043 G4Parabola::G4Parabola(const G4Parabola& right)
00044   : G4Conic(), focalDist(right.focalDist), F(right.F), L0(right.L0)
00045 {
00046   pShift    = right.pShift;
00047   position  = right.position;
00048   bBox      = right.bBox;
00049   start     = right.start;
00050   end       = right.end;
00051   pStart    = right.pStart;
00052   pEnd      = right.pEnd;
00053   pRange    = right.pRange;
00054   bounded   = right.bounded;
00055   sameSense = right.sameSense;
00056 }
00057 
00058 G4Parabola& G4Parabola::operator=(const G4Parabola& right)
00059 {
00060   if (&right == this) return *this;
00061 
00062   F  = right.F;
00063   L0 = right.L0;
00064   focalDist = right.focalDist;
00065   pShift    = right.pShift;
00066   position  = right.position;
00067   bBox      = right.bBox;
00068   start     = right.start;
00069   end       = right.end;
00070   pStart    = right.pStart;
00071   pEnd      = right.pEnd;
00072   pRange    = right.pRange;
00073   bounded   = right.bounded;
00074   sameSense = right.sameSense;
00075 
00076   return *this;
00077 }
00078 
00079 G4Curve* G4Parabola::Project(const G4Transform3D& tr)
00080 {
00081   G4double axisZ= (tr*position.GetPZ()).unit().z();
00082 
00083   if (std::abs(axisZ)<G4GeometryTolerance::GetInstance()->GetAngularTolerance()) 
00084     { return 0; }
00085   
00086   
00087   G4Vector3D newAxis(0, 0, axisZ>0? +1: -1);
00088 
00089   G4Vector3D xPrime= tr*position.GetPX();
00090   xPrime.setZ(0);
00091   G4Vector3D yPrime= tr*position.GetPY();
00092   yPrime.setZ(0);
00093   G4double u= -(xPrime*yPrime)/xPrime.mag2();
00094 
00095   G4Point3D newLocation= G4Point3D( tr*position.GetLocation()+
00096                                     focalDist*(u*u*xPrime+2*u*yPrime) );
00097   newLocation.setZ(0);
00098   G4Vector3D newRefDirection= xPrime;
00099   G4double newFocalDist= (focalDist*((2*u+1)*xPrime+2*yPrime)).mag()/std::sqrt(5.);
00100                           
00101   // create the new parabola
00102   G4Axis2Placement3D newPosition;
00103   newPosition.Init(newRefDirection, newAxis, newLocation);
00104   G4Parabola* r= new G4Parabola;
00105   r->Init(newPosition, newFocalDist);
00106 
00107   // introduce the shift in the parametrization
00108   // maybe the Sign must be changed?
00109   r->SetPShift(u);
00110 
00111   // set the bounds when necessary
00112   if (IsBounded()) 
00113     r->SetBounds(GetPStart(), GetPEnd());
00114   
00115   return r;
00116 }
00117 
00118 
00119 void G4Parabola::InitBounded()
00120 {
00121   // the bbox must include the start and endpoints as well as the
00122   // extreme points if they lie on the curve
00123   bBox.Init(GetStart(), GetEnd());
00124 
00125   // the parameter values
00126   // belonging to the points with an extreme x, y and z coordinate
00127   for (G4int i=0; i<3; i++) 
00128   {
00129     G4double x_i= position.GetPX()(i);
00130     
00131     if (std::abs(x_i) <= 
00132         G4GeometryTolerance::GetInstance()->GetAngularTolerance()) 
00133     {
00134       G4double u= - position.GetPY()(i) / x_i;
00135       if (IsPOn(u)) 
00136         bBox.Extend(GetPoint(u));
00137     }
00138   }
00139 }
00140 
00141 
00142 G4bool G4Parabola::Tangent(G4CurvePoint& cp, G4Vector3D& v)
00143 {
00144   // The tangent is computed from the 3D point representation
00145   // for all conics. An alternaive implementation (based on
00146   // the parametric point) might be worthwhile adding
00147   // for efficiency.
00148   
00149   const G4Axis2Placement3D& pos= *(GetPosition());
00150   G4Point3D p= pos.GetToPlacementCoordinates() * cp.GetPoint();
00151 
00152   v= p.y()*pos.GetPX() + (2*focalDist)*pos.GetPY();
00153   return true;
00154 }

Generated on Mon May 27 17:49:14 2013 for Geant4 by  doxygen 1.4.7