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 // Class G4Ray 00031 // 00032 // Class description: 00033 // 00034 // Definition of a generic ray. 00035 00036 // Authors: J.Sulkimo, P.Urban. 00037 // Revisions by: L.Broglia, G.Cosmo. 00038 // ---------------------------------------------------------------------- 00039 #ifndef __G4Ray_h 00040 #define __G4Ray_h 1 00041 00042 #include "G4Point3D.hh" 00043 #include "G4PointRat.hh" 00044 #include "G4Vector3D.hh" 00045 #include "G4Plane.hh" 00046 00047 00048 class G4Ray 00049 { 00050 00051 public: // with description 00052 00053 G4Ray(); 00054 G4Ray(const G4Point3D& start0, const G4Vector3D& dir0); 00055 ~G4Ray(); 00056 // Contructors and destructor. 00057 00058 inline G4Point3D GetPoint(G4double i) const; 00059 inline G4double GetPPoint(const G4Point3D& p) const; 00060 inline const G4Vector3D& GetDir() const; 00061 inline const G4Point3D& GetStart() const; 00062 inline void SetDir(const G4Vector3D& dir0); 00063 inline void SetStart(const G4Point3D& start0); 00064 const G4Plane& GetPlane(G4int number_of_plane) const; 00065 // Get/Set methods of geometrical data. 00066 00067 void RayCheck(); 00068 // Makes sure that the vector has unit length. 00069 00070 void CreatePlanes(); 00071 // Creates two orthogonal planes (plane1,plane2), the ray (rray) 00072 // being situated in the intersection of the planes. The planes are 00073 // used to project the surface (nurb) in two dimensions. 00074 00075 static G4int CalcPlane3Pts( G4Plane& plane, const G4Point3D& a, 00076 const G4Point3D& b, const G4Point3D& c ); 00077 // Finds the equation of a G4Plane that contains three points. 00078 // Note that Normal vector created is expected to point outside. 00079 // This follows the outward-pointing Normal convention, and the 00080 // right-hand rule for cross products. 00081 /* 00082 00083 C 00084 * 00085 |\ 00086 | \ 00087 ^ N | \ 00088 | \ | \ 00089 | \ | \ 00090 |C-A \ | \ 00091 | \ | \ 00092 | \ | \ 00093 \| \ 00094 *---------* 00095 A B 00096 -----> 00097 B-A 00098 */ 00099 // If the points are given in the order A B C (eg, *counter*-clockwise), 00100 // then the outward pointing surface Normal N = (B-A) x (C-A). 00101 // 00102 // Explicit return value: 00103 // 0 OK 00104 // -1 Failure. At least two of the points were not distinct, 00105 // or all three were colinear. 00106 // 00107 // Implicit return argument: 00108 // plane The G4Plane equation coefficients are stored here. 00109 00110 inline G4double P2(G4double x) const; 00111 inline G4int NearZero(G4double val, G4double epsilon) const; 00112 void MatVecOrtho(register G4Vector3D &out, register const G4Vector3D &in); 00113 // Utility methods. 00114 00115 inline void Vsetall(G4Vector3D &a, G4double s); 00116 // Sets all elements of vector to the same scalar value. 00117 00118 static void Vcross(G4Plane &a, const G4Vector3D &b, 00119 const G4Vector3D &c); 00120 // Cross product of 'b' and 'c'. Stores result in 'a' (G4Plane). 00121 00122 static void Vcross(G4Vector3D &a, const G4Vector3D &b, 00123 const G4Vector3D &c); 00124 // Cross product of 'b' and 'c'. Stores result in 'a' (G4Vector3D). 00125 00126 static void Vmove(G4Point3D &a, const G4Point3D &b); 00127 // Sets 'a' equal to 'b'. 00128 00129 static void Vadd2(G4Point3D &a, const G4Point3D &b, 00130 const G4Vector3D &c ); 00131 // Adds vector 'c' to 'b'. Stores result in 'a'. 00132 00133 static void Vsub2(G4Vector3D &a, const G4Point3D &b, 00134 const G4Point3D &c); 00135 // Subtracts vector 'c' from 'b'. Stores result in 'a'. 00136 00137 static void Vscale(G4Plane& a, const G4Plane& b, G4double c); 00138 // Scales vector at `b' by scalar `c'. Stores result in `a'. 00139 00140 static G4double Vdot(const G4Plane &a, const G4Point3D &b); 00141 // Computes dot product of vectors at `a' and `b'. 00142 00143 static G4double Magsq(const G4Plane &a); 00144 // Returns scalar Magnitude squared of vector at `a'. 00145 00146 static G4double Magnitude(const G4Plane &a); 00147 // Returns scalar Magnitude of vector at `a'. 00148 00149 public: // without description 00150 00151 void Init(const G4Point3D& start0, const G4Vector3D& dir0); 00152 // Initialisation of a G4Ray (called by constructor). 00153 00154 private: 00155 00156 G4Point3D start; 00157 G4Vector3D dir; 00158 00159 G4double r_min; // entry Dist to bounding sphere 00160 G4double r_max; // exit Dist from bounding sphere 00161 00162 G4Plane plane1, plane2; 00163 00164 }; 00165 00166 #include "G4Ray.icc" 00167 00168 #endif