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 "G4Hyperbola.hh"
00037 #include "G4PhysicalConstants.hh"
00038 #include "G4CurvePoint.hh"
00039 #include "G4GeometryTolerance.hh"
00040
00041 G4Hyperbola::G4Hyperbola()
00042 : semiAxis(0.), semiImagAxis(0.), ratioAxisImagAxis(0.), forTangent(0.)
00043 {
00044 }
00045
00046 G4Hyperbola::~G4Hyperbola()
00047 {
00048 }
00049
00050 G4Hyperbola::G4Hyperbola(const G4Hyperbola& right)
00051 : G4Conic(), Focus1(right.Focus1), Focus2(right.Focus2),
00052 ProjFocus1(right.ProjFocus1), ProjFocus2(right.ProjFocus2),
00053 semiAxis(right.semiAxis), semiImagAxis(right.semiImagAxis),
00054 ratioAxisImagAxis(right.ratioAxisImagAxis),
00055 toUnitHyperbola(right.toUnitHyperbola), forTangent(right.forTangent)
00056 {
00057 pShift = right.pShift;
00058 position = right.position;
00059 bBox = right.bBox;
00060 start = right.start;
00061 end = right.end;
00062 pStart = right.pStart;
00063 pEnd = right.pEnd;
00064 pRange = right.pRange;
00065 bounded = right.bounded;
00066 sameSense = right.sameSense;
00067 }
00068
00069 G4Hyperbola& G4Hyperbola::operator=(const G4Hyperbola& right)
00070 {
00071 if (&right == this) return *this;
00072
00073 Focus1 = right.Focus1;
00074 Focus2 = right.Focus2;
00075 ProjFocus1 = right.ProjFocus1;
00076 ProjFocus2 = right.ProjFocus2;
00077 semiAxis = right.semiAxis;
00078 semiImagAxis = right.semiImagAxis;
00079 ratioAxisImagAxis = right.ratioAxisImagAxis;
00080 toUnitHyperbola = right.toUnitHyperbola;
00081 forTangent = right.forTangent;
00082 pShift = right.pShift;
00083 position = right.position;
00084 bBox = right.bBox;
00085 start = right.start;
00086 end = right.end;
00087 pStart = right.pStart;
00088 pEnd = right.pEnd;
00089 pRange = right.pRange;
00090 bounded = right.bounded;
00091 sameSense = right.sameSense;
00092
00093 return *this;
00094 }
00095
00096 G4Curve* G4Hyperbola::Project(const G4Transform3D& tr)
00097 {
00098 G4Exception("G4Hyperbola::Project()", "GeomSolids0001",
00099 FatalException, "Sorry, not yet implemented.");
00100
00101 G4Point3D newLocation= tr*position.GetLocation();
00102 newLocation.setZ(0);
00103 G4double axisZ= (tr*position.GetPZ()).unit().z();
00104
00105 if (std::abs(axisZ)<G4GeometryTolerance::GetInstance()->GetAngularTolerance())
00106 {
00107 return 0;
00108 }
00109
00110 G4Vector3D newAxis(0, 0, axisZ>0? +1: -1);
00111
00112
00113
00114 G4Vector3D xPrime = tr*position.GetPX();
00115 xPrime.setZ(0);
00116
00117 G4Vector3D yPrime = tr*position.GetPY();
00118 yPrime.setZ(0);
00119
00120 G4Vector3D a = G4Vector3D( semiAxis*xPrime );
00121 G4Vector3D b = G4Vector3D( semiImagAxis*yPrime );
00122
00123 G4double xval = -2*a*b/(a.mag2()+b.mag2());
00124
00125 G4double u= (0.5*std::log((1+xval)/(1-xval)))/2;
00126
00127
00128 G4Vector3D sAxis= G4Vector3D( a*std::cosh(u)+b*std::sinh(u) );
00129
00131 G4Vector3D sImagAxis= G4Vector3D( a*std::cosh(u+pi/2)+b*std::sinh(u+pi/2) );
00132
00134 G4double newSemiAxis = sAxis.mag();
00135 G4double newSemiImagAxis = sImagAxis.mag();
00136 G4Vector3D newRefDirection = sAxis;
00137
00138
00139 G4Axis2Placement3D newPosition;
00140 newPosition.Init(newRefDirection, newAxis, newLocation);
00141
00142 G4Hyperbola* r= new G4Hyperbola;
00143 r->Init(newPosition, newSemiAxis, newSemiImagAxis);
00144
00145
00146
00147 r->SetPShift(u);
00148
00149
00150 if (IsBounded())
00151 r->SetBounds(GetPStart(), GetPEnd());
00152
00153 return r;
00154 }
00155
00156
00157 void G4Hyperbola::InitBounded()
00158 {
00159
00160
00161 bBox.Init(GetStart(), GetEnd());
00162
00163
00164
00165 for (G4int i=0; i<3; i++)
00166 {
00167 G4double x_i= position.GetPX()(i);
00168
00169 if (std::abs(x_i) <=
00170 G4GeometryTolerance::GetInstance()->GetAngularTolerance())
00171 {
00172 G4double tanhu= - (semiImagAxis*position.GetPY()(i)) / (semiAxis*x_i);
00173
00174 if (std::abs(tanhu)<=1)
00175 {
00176 G4double u= 0.5*std::log((1+tanhu)/(1-tanhu));
00177 if (IsPOn(u))
00178 bBox.Extend(GetPoint(u));
00179 }
00180 }
00181 }
00182 }
00183
00184 G4bool G4Hyperbola::Tangent(G4CurvePoint& cp, G4Vector3D& v)
00185 {
00186
00187
00188
00189
00190
00191 const G4Axis2Placement3D& pos= *(GetPosition());
00192 G4Point3D p= pos.GetToPlacementCoordinates() * cp.GetPoint();
00193
00194 v= forTangent*p.y()*pos.GetPX() + p.x()*pos.GetPY();
00195
00196 return true;
00197 }