G4Axis2Placement3D.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 // G4Axis2Placement3D.cc
00033 //
00034 // ----------------------------------------------------------------------
00035 
00036 #include "G4Axis2Placement3D.hh"
00037 
00038 //G4Axis2Placement3D
00039 G4Axis2Placement3D::G4Axis2Placement3D(){}
00040 G4Axis2Placement3D::~G4Axis2Placement3D(){}
00041 
00042 // copy constructor (used in STEPinterface module)
00043 //
00044 G4Axis2Placement3D::G4Axis2Placement3D(const G4Axis2Placement3D& place)
00045   : location(place.location), axis(place.axis),
00046     refDirection(place.refDirection), 
00047     pX(place.pX), pY(place.pY), pZ(place.pZ),
00048     toPlacementCoordinates(place.toPlacementCoordinates),
00049     fromPlacementCoordinates(place.fromPlacementCoordinates)
00050 {
00051 }
00052 
00053 // assignment operator
00054 //
00055 G4Axis2Placement3D&
00056 G4Axis2Placement3D::operator=(const G4Axis2Placement3D& place)
00057 {
00058   if (&place == this) return *this;
00059   
00060   refDirection             = place.refDirection; 
00061   axis                     = place.axis;
00062   location                 = place.location;
00063   pX                       = place.pX;
00064   pY                       = place.pY;
00065   pZ                       = place.pZ;
00066   toPlacementCoordinates   = place.toPlacementCoordinates;
00067   fromPlacementCoordinates = place.fromPlacementCoordinates; 
00068 
00069   return *this;
00070 }
00071 
00072 /* everything below here is commented-out ...
00073 
00074 G4Axis2Placement3D::G4Axis2Placement3D(const G4ThreeVec Dir, 
00075                                        const G4ThreeVec Axis, 
00076                                        const G4Point3d Pt    )
00077 {
00078   dir=Dir;
00079   axis=Axis;
00080   srf_point=Pt;
00081   ComputeNormal();
00082   G4Point3d Pt2 = Pt+Dir;
00083   G4Point3d Pt3 = Pt+Axis;  
00084   G4Ray::CalcPlane3Pts(Pl, Pt, Pt2, Pt3);  
00085 }
00086 
00087 G4Axis2Placement3D::G4Axis2Placement3D(const G4ThreeVec Dir,
00088                                        const G4ThreeVec Axis,
00089                                        const G4Point3d Pt1,
00090                                        const G4Point3d Pt2,
00091                                        const G4Point3d Pt3)
00092 {
00093   dir=Dir;
00094   axis=Axis;
00095   srf_point=Pt1;
00096   ComputeNormal();
00097   G4Ray::CalcPlane3Pts(Pl, Pt1, Pt2, Pt3);  
00098 }
00099 
00100 void
00101 G4Axis2Placement3D::ProjectPlacement(const G4Plane& Pl1,
00102                                      const G4Plane& Pl2)
00103 {
00104   Project(ProjectedDir, dir, Pl1, Pl2);
00105   Project(ProjectedAxis, axis, Pl1, Pl2);
00106   Project(ProjectedSrfPoint, srf_point, Pl1, Pl2);
00107   Project(ProjectedNormal, Normal, Pl1, Pl2);
00108 }
00109 
00110 void
00111 G4Axis2Placement3D::ComputeNormal()
00112 {
00113 
00114   if(dir == axis)
00115     Normal = dir;
00116   else
00117     {
00118       Normal.X(dir.Y()*axis.Z() - dir.Z()*axis.Y());
00119       Normal.Y(dir.X()*axis.Z()- dir.Z()*axis.X());
00120       Normal.Z(dir.X()*axis.Y() - dir.Y()*axis.X());
00121     }
00122 }
00123 
00124 
00125 G4Point3d
00126 G4Axis2Placement3D::EvaluateIntersection(register const G4Ray& rray)
00127 {
00128 
00129 // s is solution, line is p + tq, n is G4Plane Normal, r is point on G4Plane 
00130 // all parameters are pointers to arrays of three elements 
00131 
00132     register G4double a, b, t;
00133     register const G4ThreeVec& RayDir   = rray.GetDir();
00134     register const G4Point3d& RayStart = rray.GetStart();
00135     G4double dirx =  RayDir.X();
00136     G4double diry =  RayDir.Y();
00137     G4double dirz =  RayDir.Z();
00138     b = Normal.X() * dirx + Normal.Y() * diry + Normal.Z() * dirz;
00139 
00140     if (std::fabs(b) < 0.001)//== 0.0)
00141        // or some better test involving a small positive e     
00142     {
00143 //    G4cout << "\nLine is parallel to G4Plane.No Hit.";
00144       G4Point3d hit_point( kInfinity, kInfinity, kInfinity);
00145       return hit_point;
00146     }
00147     G4double startx =  RayStart.X();
00148     G4double starty =  RayStart.Y();
00149     G4double startz =  RayStart.Z();    
00150     
00151     a = Normal.X() * (srf_point.X() - startx)
00152       + Normal.Y() * (srf_point.Y() - starty)
00153       + Normal.Z() * (srf_point.Z() - startz);
00154 
00155     t = a/b;
00156 
00157     // substitute t into line equation
00158     // to calculate final solution     
00159     G4Point3d hit_point(startx + t * dirx,starty
00160                                + t * diry,startz
00161                                + t * dirz);    
00162     
00163 //  G4cout << "\nPLANE HIT POINT :" << hit_point.X()
00164 //         << "  " << hit_point.Y() << "  " << hit_point.Z();
00165     return hit_point;
00166 }
00167 */

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