00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
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
00102 G4Axis2Placement3D newPosition;
00103 newPosition.Init(newRefDirection, newAxis, newLocation);
00104 G4Parabola* r= new G4Parabola;
00105 r->Init(newPosition, newFocalDist);
00106
00107
00108
00109 r->SetPShift(u);
00110
00111
00112 if (IsBounded())
00113 r->SetBounds(GetPStart(), GetPEnd());
00114
00115 return r;
00116 }
00117
00118
00119 void G4Parabola::InitBounded()
00120 {
00121
00122
00123 bBox.Init(GetStart(), GetEnd());
00124
00125
00126
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
00145
00146
00147
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 }