[831] | 1 | // |
---|
| 2 | // ******************************************************************** |
---|
| 3 | // * License and Disclaimer * |
---|
| 4 | // * * |
---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
| 7 | // * conditions of the Geant4 Software License, included in the file * |
---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
| 9 | // * include a list of copyright holders. * |
---|
| 10 | // * * |
---|
| 11 | // * Neither the authors of this software system, nor their employing * |
---|
| 12 | // * institutes,nor the agencies providing financial support for this * |
---|
| 13 | // * work make any representation or warranty, express or implied, * |
---|
| 14 | // * regarding this software system or assume any liability for its * |
---|
| 15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
| 16 | // * for the full disclaimer and the limitation of liability. * |
---|
| 17 | // * * |
---|
| 18 | // * This code implementation is the result of the scientific and * |
---|
| 19 | // * technical work of the GEANT4 collaboration. * |
---|
| 20 | // * By using, copying, modifying or distributing the software (or * |
---|
| 21 | // * any work based on the software) you agree to acknowledge its * |
---|
| 22 | // * use in resulting scientific publications, and indicate your * |
---|
| 23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
| 24 | // ******************************************************************** |
---|
| 25 | // |
---|
| 26 | // |
---|
| 27 | // $Id: G4Ray.hh,v 1.9 2006/06/29 18:40:21 gunter Exp $ |
---|
[1337] | 28 | // GEANT4 tag $Name: geant4-09-04-beta-01 $ |
---|
[831] | 29 | // |
---|
| 30 | // ---------------------------------------------------------------------- |
---|
| 31 | // Class G4Ray |
---|
| 32 | // |
---|
| 33 | // Class description: |
---|
| 34 | // |
---|
| 35 | // Definition of a generic ray. |
---|
| 36 | |
---|
| 37 | // Authors: J.Sulkimo, P.Urban. |
---|
| 38 | // Revisions by: L.Broglia, G.Cosmo. |
---|
| 39 | // ---------------------------------------------------------------------- |
---|
| 40 | #ifndef __G4Ray_h |
---|
| 41 | #define __G4Ray_h 1 |
---|
| 42 | |
---|
| 43 | #include "G4Point3D.hh" |
---|
| 44 | #include "G4PointRat.hh" |
---|
| 45 | #include "G4Vector3D.hh" |
---|
| 46 | #include "G4Plane.hh" |
---|
| 47 | |
---|
| 48 | |
---|
| 49 | class G4Ray |
---|
| 50 | { |
---|
| 51 | |
---|
| 52 | public: // with description |
---|
| 53 | |
---|
| 54 | G4Ray(); |
---|
| 55 | G4Ray(const G4Point3D& start0, const G4Vector3D& dir0); |
---|
| 56 | ~G4Ray(); |
---|
| 57 | // Contructors and destructor. |
---|
| 58 | |
---|
| 59 | inline G4Point3D GetPoint(G4double i) const; |
---|
| 60 | inline G4double GetPPoint(const G4Point3D& p) const; |
---|
| 61 | inline const G4Vector3D& GetDir() const; |
---|
| 62 | inline const G4Point3D& GetStart() const; |
---|
| 63 | inline void SetDir(const G4Vector3D& dir0); |
---|
| 64 | inline void SetStart(const G4Point3D& start0); |
---|
| 65 | const G4Plane& GetPlane(G4int number_of_plane) const; |
---|
| 66 | // Get/Set methods of geometrical data. |
---|
| 67 | |
---|
| 68 | void RayCheck(); |
---|
| 69 | // Makes sure that the vector has unit length. |
---|
| 70 | |
---|
| 71 | void CreatePlanes(); |
---|
| 72 | // Creates two orthogonal planes (plane1,plane2), the ray (rray) |
---|
| 73 | // being situated in the intersection of the planes. The planes are |
---|
| 74 | // used to project the surface (nurb) in two dimensions. |
---|
| 75 | |
---|
| 76 | static G4int CalcPlane3Pts( G4Plane& plane, const G4Point3D& a, |
---|
| 77 | const G4Point3D& b, const G4Point3D& c ); |
---|
| 78 | // Finds the equation of a G4Plane that contains three points. |
---|
| 79 | // Note that Normal vector created is expected to point outside. |
---|
| 80 | // This follows the outward-pointing Normal convention, and the |
---|
| 81 | // right-hand rule for cross products. |
---|
| 82 | /* |
---|
| 83 | |
---|
| 84 | C |
---|
| 85 | * |
---|
| 86 | |\ |
---|
| 87 | | \ |
---|
| 88 | ^ N | \ |
---|
| 89 | | \ | \ |
---|
| 90 | | \ | \ |
---|
| 91 | |C-A \ | \ |
---|
| 92 | | \ | \ |
---|
| 93 | | \ | \ |
---|
| 94 | \| \ |
---|
| 95 | *---------* |
---|
| 96 | A B |
---|
| 97 | -----> |
---|
| 98 | B-A |
---|
| 99 | */ |
---|
| 100 | // If the points are given in the order A B C (eg, *counter*-clockwise), |
---|
| 101 | // then the outward pointing surface Normal N = (B-A) x (C-A). |
---|
| 102 | // |
---|
| 103 | // Explicit return value: |
---|
| 104 | // 0 OK |
---|
| 105 | // -1 Failure. At least two of the points were not distinct, |
---|
| 106 | // or all three were colinear. |
---|
| 107 | // |
---|
| 108 | // Implicit return argument: |
---|
| 109 | // plane The G4Plane equation coefficients are stored here. |
---|
| 110 | |
---|
| 111 | inline G4double P2(G4double x) const; |
---|
| 112 | inline G4int NearZero(G4double val, G4double epsilon) const; |
---|
| 113 | void MatVecOrtho(register G4Vector3D &out, register const G4Vector3D &in); |
---|
| 114 | // Utility methods. |
---|
| 115 | |
---|
| 116 | inline void Vsetall(G4Vector3D &a, G4double s); |
---|
| 117 | // Sets all elements of vector to the same scalar value. |
---|
| 118 | |
---|
| 119 | static void Vcross(G4Plane &a, const G4Vector3D &b, |
---|
| 120 | const G4Vector3D &c); |
---|
| 121 | // Cross product of 'b' and 'c'. Stores result in 'a' (G4Plane). |
---|
| 122 | |
---|
| 123 | static void Vcross(G4Vector3D &a, const G4Vector3D &b, |
---|
| 124 | const G4Vector3D &c); |
---|
| 125 | // Cross product of 'b' and 'c'. Stores result in 'a' (G4Vector3D). |
---|
| 126 | |
---|
| 127 | static void Vmove(G4Point3D &a, const G4Point3D &b); |
---|
| 128 | // Sets 'a' equal to 'b'. |
---|
| 129 | |
---|
| 130 | static void Vadd2(G4Point3D &a, const G4Point3D &b, |
---|
| 131 | const G4Vector3D &c ); |
---|
| 132 | // Adds vector 'c' to 'b'. Stores result in 'a'. |
---|
| 133 | |
---|
| 134 | static void Vsub2(G4Vector3D &a, const G4Point3D &b, |
---|
| 135 | const G4Point3D &c); |
---|
| 136 | // Subtracts vector 'c' from 'b'. Stores result in 'a'. |
---|
| 137 | |
---|
| 138 | static void Vscale(G4Plane& a, const G4Plane& b, G4double c); |
---|
| 139 | // Scales vector at `b' by scalar `c'. Stores result in `a'. |
---|
| 140 | |
---|
| 141 | static G4double Vdot(const G4Plane &a, const G4Point3D &b); |
---|
| 142 | // Computes dot product of vectors at `a' and `b'. |
---|
| 143 | |
---|
| 144 | static G4double Magsq(const G4Plane &a); |
---|
| 145 | // Returns scalar Magnitude squared of vector at `a'. |
---|
| 146 | |
---|
| 147 | static G4double Magnitude(const G4Plane &a); |
---|
| 148 | // Returns scalar Magnitude of vector at `a'. |
---|
| 149 | |
---|
| 150 | public: // without description |
---|
| 151 | |
---|
| 152 | void Init(const G4Point3D& start0, const G4Vector3D& dir0); |
---|
| 153 | // Initialisation of a G4Ray (called by constructor). |
---|
| 154 | |
---|
| 155 | private: |
---|
| 156 | |
---|
| 157 | G4Point3D start; |
---|
| 158 | G4Vector3D dir; |
---|
| 159 | |
---|
| 160 | G4double r_min; // entry Dist to bounding sphere |
---|
| 161 | G4double r_max; // exit Dist from bounding sphere |
---|
| 162 | |
---|
| 163 | G4Plane plane1, plane2; |
---|
| 164 | |
---|
| 165 | }; |
---|
| 166 | |
---|
| 167 | #include "G4Ray.icc" |
---|
| 168 | |
---|
| 169 | #endif |
---|