G4Hyperbola Class Reference

#include <G4Hyperbola.hh>

Inheritance diagram for G4Hyperbola:

G4Conic G4Curve

Public Member Functions

 G4Hyperbola ()
virtual ~G4Hyperbola ()
 G4Hyperbola (const G4Hyperbola &right)
G4Hyperbolaoperator= (const G4Hyperbola &right)
G4CurveProject (const G4Transform3D &tr=G4Transform3D::Identity)
G4bool Tangent (G4CurvePoint &cp, G4Vector3D &v)
G4double GetPMax () const
G4Point3D GetPoint (G4double param) const
G4double GetPPoint (const G4Point3D &p) const
G4double GetSemiAxis () const
G4double GetSemiImagAxis () const
void Init (const G4Axis2Placement3D &position0, G4double semiAxis0, G4double semiImagAxis0)
G4int IntersectRay2D (const G4Ray &ray)

Protected Member Functions

void InitBounded ()

Detailed Description

Definition at line 44 of file G4Hyperbola.hh.


Constructor & Destructor Documentation

G4Hyperbola::G4Hyperbola (  ) 

Definition at line 41 of file G4Hyperbola.cc.

00042   : semiAxis(0.), semiImagAxis(0.), ratioAxisImagAxis(0.), forTangent(0.)
00043 {
00044 }

G4Hyperbola::~G4Hyperbola (  )  [virtual]

Definition at line 46 of file G4Hyperbola.cc.

00047 {
00048 }

G4Hyperbola::G4Hyperbola ( const G4Hyperbola right  ) 

Definition at line 50 of file G4Hyperbola.cc.

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

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 }


Member Function Documentation

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

Implements G4Curve.

Definition at line 69 of file G4Hyperbola.icc.

00070 {
00071   return -1;
00072 }

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

Implements G4Curve.

Definition at line 75 of file G4Hyperbola.icc.

References G4Axis2Placement3D::GetLocation(), G4Axis2Placement3D::GetPX(), G4Axis2Placement3D::GetPY(), and G4Conic::position.

Referenced by InitBounded().

00076 {
00077   return G4Point3D( position.GetLocation()
00078                     + semiAxis*std::cosh(param)*position.GetPX()
00079                     + semiImagAxis*std::sinh(param)*position.GetPY() );
00080 }

G4double G4Hyperbola::GetPPoint ( const G4Point3D p  )  const [inline, virtual]

Implements G4Curve.

Definition at line 83 of file G4Hyperbola.icc.

References G4Axis2Placement3D::GetToPlacementCoordinates(), and G4Conic::position.

00084 {
00085   G4Point3D ptLocal= position.GetToPlacementCoordinates()*pt;
00086   G4double xval= ptLocal.y()/ptLocal.x()*ratioAxisImagAxis;
00087   return 0.5*std::log((1+xval)/(1-xval));  // atanh(xval)
00088 }

G4double G4Hyperbola::GetSemiAxis (  )  const [inline]

Definition at line 55 of file G4Hyperbola.icc.

00056 {
00057   return semiAxis;
00058 }

G4double G4Hyperbola::GetSemiImagAxis (  )  const [inline]

Definition at line 61 of file G4Hyperbola.icc.

00062 {
00063   return semiImagAxis;
00064 }

void G4Hyperbola::Init ( const G4Axis2Placement3D position0,
G4double  semiAxis0,
G4double  semiImagAxis0 
) [inline]

Definition at line 38 of file G4Hyperbola.icc.

References G4Axis2Placement3D::GetToPlacementCoordinates(), and G4Conic::position.

Referenced by Project().

00040 {
00041   position= position0;
00042   semiAxis= semiAxis0;
00043   semiImagAxis= semiImagAxis0;
00044 
00045   ratioAxisImagAxis= semiAxis/semiImagAxis;
00046 
00047   // needed only for 2D hyperbolas
00048   toUnitHyperbola = G4Scale3D(1/semiAxis, 1/semiImagAxis, 0)
00049                     * position.GetToPlacementCoordinates();
00050 
00051   forTangent= semiAxis*semiAxis/(semiImagAxis*semiImagAxis);
00052 }

void G4Hyperbola::InitBounded (  )  [protected, virtual]

Implements G4Curve.

Definition at line 157 of file G4Hyperbola.cc.

References G4Curve::bBox, G4BoundingBox3D::Extend(), G4Curve::GetEnd(), G4GeometryTolerance::GetInstance(), GetPoint(), G4Axis2Placement3D::GetPX(), G4Axis2Placement3D::GetPY(), G4Curve::GetStart(), G4BoundingBox3D::Init(), G4Curve::IsPOn(), and G4Conic::position.

00158 {
00159   // the bbox must include the start and endpoints as well as the
00160   // extreme points if they lie on the curve
00161   bBox.Init(GetStart(), GetEnd());
00162 
00163   // the parameter values
00164   // belonging to the points with an extreme x, y and z coordinate
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));  // atanh(tanhu)
00177         if (IsPOn(u))
00178           bBox.Extend(GetPoint(u));
00179       }
00180     }
00181   }
00182 }

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

Implements G4Curve.

Definition at line 147 of file G4Hyperbola.icc.

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

00148 {
00149   // NOT VERIFIED
00150 
00151   // similar to G4Ellipse::IntersectRay2D
00152 
00153   // 2D operations would be faster
00154   G4Point3D st= toUnitHyperbola*ray.GetStart();
00155   G4Vector3D d= toUnitHyperbola*ray.GetDir();
00156   
00157   // solve (st+i*t)^2 = 1 for i (the distance)
00158 
00159   G4double sd= st.x()*d.x()-st.y()*d.y();
00160   G4double dd= d.x()*d.x()-d.y()*d.y(); // can be 0
00161   G4double ss= st.x()*st.x()-st.y()*st.y();
00162 
00163   if (std::abs(dd) < kCarTolerance*kCarTolerance) {
00164 
00165     // coeff of i^2 == 0
00166     return 0;
00167 
00168   }
00169   
00170   G4int nbinter = 0;
00171 
00172   G4double discr= sd*sd-dd*(ss-1);
00173   if (discr >= 0) 
00174   {
00175     // 2 intersections (maybe 1, but this case is rare)
00176     G4double sqrtdiscr= std::sqrt(discr);
00177     // find the smallest positive i
00178     G4double i= -sd-sqrtdiscr;
00179     if (i > kCarTolerance) 
00180       nbinter++;
00181 
00182     i= -sd+sqrtdiscr;
00183     if (i<kCarTolerance) 
00184       nbinter++;
00185   }
00186     
00187   return nbinter;
00188 }

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

Definition at line 69 of file G4Hyperbola.cc.

References G4Curve::bBox, G4Curve::bounded, G4Curve::end, Focus1, Focus2, forTangent, G4Curve::pEnd, G4Conic::position, G4Curve::pRange, ProjFocus1, ProjFocus2, G4Conic::pShift, G4Curve::pStart, ratioAxisImagAxis, G4Curve::sameSense, semiAxis, semiImagAxis, G4Curve::start, and toUnitHyperbola.

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 }

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

Implements G4Curve.

Definition at line 96 of file G4Hyperbola.cc.

References FatalException, G4Exception(), G4GeometryTolerance::GetInstance(), G4Axis2Placement3D::GetLocation(), G4Curve::GetPEnd(), G4Curve::GetPStart(), G4Axis2Placement3D::GetPX(), G4Axis2Placement3D::GetPY(), G4Axis2Placement3D::GetPZ(), Init(), G4Axis2Placement3D::Init(), G4Curve::IsBounded(), G4INCL::Math::pi, G4Conic::position, G4Curve::SetBounds(), and G4Conic::SetPShift().

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   // get the parameter of an endpoint of an axis
00113   // (this is a point the distance of which from the center is extreme)
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;  // atanh(xval)/2
00126 
00127   // get the coordinate axis directions and the semiaxis lengths
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   // create the new hyperbola
00139   G4Axis2Placement3D newPosition;
00140   newPosition.Init(newRefDirection, newAxis, newLocation);
00141 
00142   G4Hyperbola* r= new G4Hyperbola;
00143   r->Init(newPosition, newSemiAxis, newSemiImagAxis);
00144 
00145   // introduce the shift in the parametrization
00146   // maybe the Sign must be changed?
00147   r->SetPShift(u);
00148   
00149   // set the bounds when necessary
00150   if (IsBounded()) 
00151     r->SetBounds(GetPStart(), GetPEnd());
00152   
00153   return r;
00154 }

G4bool G4Hyperbola::Tangent ( G4CurvePoint cp,
G4Vector3D v 
) [virtual]

Implements G4Curve.

Definition at line 184 of file G4Hyperbola.cc.

References G4CurvePoint::GetPoint(), G4Conic::GetPosition(), G4Axis2Placement3D::GetPX(), G4Axis2Placement3D::GetPY(), and G4Axis2Placement3D::GetToPlacementCoordinates().

00185 {
00186   // The tangent is computed from the 3D point representation
00187   // for all conics. An alternaive implementation (based on
00188   // the parametric point) might be worthwhile adding
00189   // for efficiency.
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 }


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