G4CircularCurve.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 // G4CircularCurve.cc
00033 //
00034 // ----------------------------------------------------------------------
00035 
00036 #include "G4CircularCurve.hh"
00037 #include "G4PhysicalConstants.hh"
00038 #include "G4Ellipse.hh"
00039 
00040 // G4CircularCurve
00041 G4CircularCurve::G4CircularCurve() : radius(0.) {}
00042 G4CircularCurve::~G4CircularCurve() {}
00043 
00044 G4CircularCurve::G4CircularCurve(const G4CircularCurve& right)
00045   : G4Conic(), radius(right.radius)
00046 {
00047   pShift    = right.pShift;
00048   position  = right.position;
00049   bBox      = right.bBox;
00050   start     = right.start;
00051   end       = right.end;
00052   pStart    = right.pStart;
00053   pEnd      = right.pEnd;
00054   pRange    = right.pRange;
00055   bounded   = right.bounded;
00056   sameSense = right.sameSense;
00057 }
00058 
00059 G4CircularCurve&
00060 G4CircularCurve::operator=(const G4CircularCurve& right)
00061 {
00062   if (&right == this) return *this;
00063 
00064   radius    = right.radius;
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 
00080 
00081 void G4CircularCurve::InitBounded() 
00082 {  
00083   // the bbox must include the start and endpoints as well as the
00084   // extreme points if they lie on the curve
00085   bBox.Init(GetStart(), GetEnd());
00086   
00087   // the parameter values
00088   // belonging to the points with an extreme x, y and z coordinate
00089   for (G4int i=0; i<3; i++) 
00090   {
00091     G4double u = std::atan2(position.GetPY()(i), position.GetPX()(i));
00092     
00093     if (IsPOn(u)) 
00094       bBox.Extend(GetPoint(u));
00095     
00096     if (IsPOn(u+pi)) 
00097       bBox.Extend(GetPoint(u+pi));
00098   }
00099 }
00100 
00102 
00103 G4Curve* G4CircularCurve::Project(const G4Transform3D& tr)
00104 {
00105   G4Ellipse e;
00106   e.Init(position, radius, radius);
00107   e.SetBounds(GetPStart(), GetPEnd());
00108  
00109   return e.Project(tr);
00110 }
00111 
00113 
00114 G4bool G4CircularCurve::Tangent(G4CurvePoint& cp, G4Vector3D& v)
00115 {
00116   // The tangent is computed from the 3D point representation
00117   // for all conics. An alternaive implementation (based on
00118   // the parametric point) might be worthwhile adding
00119   // for efficiency.
00120   
00121   const G4Axis2Placement3D& pos= *(GetPosition());
00122   G4Point3D p= pos.GetToPlacementCoordinates() * cp.GetPoint();
00123   
00124   v= -p.y()*pos.GetPX() + p.x()*pos.GetPY();
00125   return true;
00126 }
00127 
00128 G4double G4CircularCurve::GetPMax() const
00129 {
00130   return twopi;
00131 }
00132 
00133 G4Point3D G4CircularCurve::GetPoint(G4double param) const
00134 {
00135   return G4Point3D( position.GetLocation()+radius*
00136     ( std::cos(param)*position.GetPX() + std::sin(param)*position.GetPY() ) );
00137 }
00138 
00139 G4double G4CircularCurve::GetPPoint(const G4Point3D& pt) const
00140 {
00141   G4Point3D ptLocal= position.GetToPlacementCoordinates()*pt;
00142   G4double angle= std::atan2(ptLocal.y(), ptLocal.x());
00143   return (angle<0)? angle+twopi: angle;
00144 }
00145 
00147 
00148 /*
00149 #include "G4CurveRayIntersection.hh"
00150 
00151 void G4CircularCurve::IntersectRay2D(const G4Ray&,
00152                                      G4CurveRayIntersection&)
00153 {
00154   G4Exception("G4CircularCurve::IntersectRay2D()",
00155               "NotApplicable", FatalException,
00156               "G4CircularCurve is always 3D!");
00157 }
00158 */
00159 
00160 G4int G4CircularCurve::IntersectRay2D(const G4Ray&)
00161 {
00162   G4Exception("G4CircularCurve::IntersectRay2D()", "GeomSolids0002",
00163               FatalException,"G4CircularCurve is always 3D!");
00164   return 0;
00165 }

Generated on Mon May 27 17:47:53 2013 for Geant4 by  doxygen 1.4.7