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 inline definitions file 00031 // 00032 // G4Parabola.icc 00033 // 00034 // Implementation of inline methods of G4Parabola 00035 // -------------------------------------------------------------------- 00036 00037 inline 00038 void G4Parabola::Init(const G4Axis2Placement3D& position0, 00039 G4double focalDist0) 00040 { 00041 position= position0; 00042 focalDist= focalDist0; 00043 00044 // focus 00045 F= position.GetLocation()+focalDist*position.GetPX(); 00046 // line 00047 L0= position.GetLocation()-focalDist*position.GetPX(); 00048 //l= position.GetPY(); 00049 } 00050 00051 inline 00052 G4double G4Parabola::GetFocalDist() const 00053 { 00054 return focalDist; 00055 } 00056 00058 00059 inline 00060 G4double G4Parabola::GetPMax() const 00061 { 00062 return -1; 00063 } 00064 00065 inline 00066 G4Point3D G4Parabola::GetPoint(G4double param) const 00067 { 00068 return G4Point3D( position.GetLocation() 00069 + focalDist* (param*param*position.GetPX() 00070 + 2*param*position.GetPY()) ); 00071 } 00072 00073 inline 00074 G4double G4Parabola::GetPPoint(const G4Point3D& pt) const 00075 { 00076 G4Point3D ptLocal= position.GetToPlacementCoordinates()*pt; 00077 return ptLocal.y()/(2*focalDist); 00078 } 00079 00081 00082 /* 00083 #include "G4CurveRayIntersection.hh" 00084 00085 inline 00086 void G4Parabola::IntersectRay2D(const G4Ray& ray, 00087 G4CurveRayIntersection& is) 00088 { 00089 is.Init(*this, ray); 00090 00091 const G4Point3D& S= ray.GetStart(); 00092 const G4Vector3D& d= ray.GetDir(); 00093 00094 const G4Vector3D& l= position.GetPY(); 00095 00096 // a == 1 00097 G4Vector3D SMinusF= S-F; 00098 G4double bHalf= SMinusF*d - (d.x()*l.y()-d.y()*l.x()); 00099 G4double c= SMinusF.mag2() + ( (S.x()-L0.x())*l.y() - (S.y()-L0.y())*l.x() ); 00100 00101 G4double discr= bHalf*bHalf-c; 00102 if (discr >= 0) { 00103 00104 // 2 intersections (maybe 1, but this case is rare) 00105 G4double sqrtdiscr= std::sqrt(discr); 00106 // find the smallest positive i 00107 G4double i= -bHalf-sqrtdiscr; 00108 if (i<kCarTolerance) { 00109 i= -bHalf+sqrtdiscr; 00110 if (i<kCarTolerance) { 00111 return; 00112 } 00113 } 00114 G4CurveRayIntersection isTmp(*this, ray); 00115 isTmp.ResetDistance(i); 00116 is.Update(isTmp); 00117 00118 } 00119 } 00120 */ 00121 00122 inline 00123 G4int G4Parabola::IntersectRay2D(const G4Ray& ray) 00124 { 00125 // NOT VERIFIED 00126 00127 const G4Point3D& S= ray.GetStart(); 00128 const G4Vector3D& d= ray.GetDir(); 00129 const G4Vector3D& l= position.GetPY(); 00130 00131 // a == 1 00132 G4Vector3D SMinusF= G4Vector3D( S-F ); 00133 G4double bHalf= SMinusF*d - (d.x()*l.y()-d.y()*l.x()); 00134 G4double c= SMinusF.mag2() + ( (S.x()-L0.x())*l.y() - (S.y()-L0.y())*l.x() ); 00135 00136 G4int nbinter = 0; 00137 00138 G4double discr= bHalf*bHalf-c; 00139 if (discr >= 0) 00140 { 00141 // 2 intersections (maybe 1, but this case is rare) 00142 G4double sqrtdiscr= std::sqrt(discr); 00143 00144 G4double i= -bHalf-sqrtdiscr; 00145 if (i>kCarTolerance) 00146 nbinter++; 00147 00148 i= -bHalf+sqrtdiscr; 00149 if (i>kCarTolerance) 00150 nbinter++; 00151 } 00152 00153 return nbinter++; 00154 }