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 #include "G4ErrorPlaneSurfaceTarget.hh"
00035
00036 #ifdef G4VERBOSE
00037 #include "G4ErrorPropagatorData.hh"
00038 #endif
00039
00040 #include "G4Point3D.hh"
00041 #include "G4ThreeVector.hh"
00042
00043
00044
00045 G4ErrorPlaneSurfaceTarget::
00046 G4ErrorPlaneSurfaceTarget(G4double aa, G4double ab, G4double ac, G4double ad)
00047 : G4Plane3D( aa, ab, ac, ad )
00048 {
00049 theType = G4ErrorTarget_PlaneSurface;
00050
00051 #ifdef G4VERBOSE
00052 if(G4ErrorPropagatorData::verbose() >= 2 )
00053 {
00054 Dump( " $$$ creating G4ErrorPlaneSurfaceTarget from parameters");
00055 }
00056 #endif
00057 }
00058
00059
00060
00061 G4ErrorPlaneSurfaceTarget::
00062 G4ErrorPlaneSurfaceTarget(const G4Normal3D &norm, const G4Point3D &pt)
00063 : G4Plane3D( norm, pt )
00064 {
00065 theType = G4ErrorTarget_PlaneSurface;
00066
00067 #ifdef G4VERBOSE
00068 if(G4ErrorPropagatorData::verbose() >= 2 )
00069 {
00070 Dump( " $$$ creating G4ErrorPlaneSurfaceTarget from point and normal");
00071 }
00072 #endif
00073 }
00074
00075
00076
00077 G4ErrorPlaneSurfaceTarget::
00078 G4ErrorPlaneSurfaceTarget(const G4Point3D &p1,
00079 const G4Point3D &p2,
00080 const G4Point3D &p3)
00081 : G4Plane3D( p1, p2, p3 )
00082 {
00083 theType = G4ErrorTarget_PlaneSurface;
00084
00085 #ifdef G4VERBOSE
00086 if(G4ErrorPropagatorData::verbose() >= 2 )
00087 {
00088 Dump( " $$$ creating G4ErrorPlaneSurfaceTarget from three points");
00089 }
00090 #endif
00091 }
00092
00093
00094
00095 G4ErrorPlaneSurfaceTarget::~G4ErrorPlaneSurfaceTarget()
00096 {
00097 }
00098
00099
00100
00101 G4ThreeVector G4ErrorPlaneSurfaceTarget::
00102 Intersect( const G4ThreeVector& pt, const G4ThreeVector& dir ) const
00103 {
00104 G4double lam = GetDistanceFromPoint( pt, dir );
00105 G4Point3D inters = pt + lam * dir;
00106
00107 #ifdef G4VERBOSE
00108 if(G4ErrorPropagatorData::verbose() >= 4 )
00109 {
00110 G4cout << " $$$ creating G4ErrorPlaneSurfaceTarget::Intersect "
00111 << inters << G4endl;
00112 }
00113 #endif
00114
00115 return inters;
00116 }
00117
00118
00119
00120 G4double G4ErrorPlaneSurfaceTarget::
00121 GetDistanceFromPoint( const G4ThreeVector& pt, const G4ThreeVector& dir ) const
00122 {
00123 if( std::fabs( dir.mag() -1. ) > 1.E-6 )
00124 {
00125 std::ostringstream message;
00126 message << "Direction is not a unit vector: " << dir << " !";
00127 G4Exception("G4ErrorPlaneSurfaceTarget::GetDistanceFromPoint()",
00128 "GeomMgt1002", JustWarning, message);
00129 }
00130 G4double dist = -(a_ * pt.x() + b_ * pt.y() + c_ * pt.z() + d_)
00131 / (a_ * dir.x() + b_ * dir.y() + c_ * dir.z() );
00132
00133 #ifdef G4VERBOSE
00134 if(G4ErrorPropagatorData::verbose() >= 3 )
00135 {
00136 G4cout << " G4ErrorPlaneSurfaceTarget::GetDistanceFromPoint()" << G4endl
00137 << " Point: " << pt << ", Direction: " << dir << G4endl
00138 << " Distance: " << dist << G4endl;
00139 }
00140 #endif
00141
00142 return dist;
00143 }
00144
00145
00146
00147 G4double G4ErrorPlaneSurfaceTarget::
00148 GetDistanceFromPoint( const G4ThreeVector& pt ) const
00149 {
00150 G4ThreeVector vec = point() - pt;
00151 G4double alpha = std::acos( vec * normal() / vec.mag() / normal().mag() );
00152 G4double dist = std::fabs(vec.mag() * std::cos( alpha ));
00153
00154 #ifdef G4VERBOSE
00155 if(G4ErrorPropagatorData::verbose() >= 3 )
00156 {
00157 G4cout << " G4ErrorPlaneSurfaceTarget::GetDistanceFromPoint()" << G4endl
00158 << " Point: " << pt << G4endl
00159 << " Distance: " << dist << G4endl;
00160 }
00161 #endif
00162
00163 return dist;
00164 }
00165
00166
00167
00168 G4Plane3D G4ErrorPlaneSurfaceTarget::
00169 GetTangentPlane( const G4ThreeVector& ) const
00170 {
00171 return *this;
00172 }
00173
00174
00175 void G4ErrorPlaneSurfaceTarget::Dump( const G4String& msg ) const
00176 {
00177 G4cout << msg << " point = " << point()
00178 << " normal = " << normal() << G4endl;
00179 }