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 and of QinetiQ Ltd, * 00020 // * subject to DEFCON 705 IPR conditions. * 00021 // * By using, copying, modifying or distributing the software (or * 00022 // * any work based on the software) you agree to acknowledge its * 00023 // * use in resulting scientific publications, and indicate your * 00024 // * acceptance of all terms of the Geant4 Software license. * 00025 // ******************************************************************** 00026 // 00027 // $Id: 00028 // 00029 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00030 // 00031 // Class G4TessellatedGeometryAlgorithms 00032 // 00033 // Class description: 00034 // 00035 // The G4TessellatedGeometryAlgorithms class is used to contain standard 00036 // routines to determine whether (and if so where) simple geometric shapes 00037 // intersect. 00038 // 00039 // The constructor doesn't need to do anything, and neither does the 00040 // destructor. 00041 // 00042 // IntersectLineAndTriangle2D 00043 // Determines whether there is an intersection between a line defined 00044 // by r = p + s.v and a triangle defined by verticies P0, P0+E0 and P0+E1. 00045 // Here: 00046 // p = 2D vector 00047 // s = scaler on [0,infinity) 00048 // v = 2D vector 00049 // P0, E0 and E1 are 2D vectors 00050 // Information about where the intersection occurs is returned in the 00051 // variable location. 00052 // 00053 // IntersectLineAndLineSegment2D 00054 // Determines whether there is an intersection between a line defined 00055 // by r = P0 + s.D0 and a line-segment with endpoints P1 and P1+D1. 00056 // Here: 00057 // P0 = 2D vector 00058 // s = scaler on [0,infinity) 00059 // D0 = 2D vector 00060 // P1 and D1 are 2D vectors 00061 // Information about where the intersection occurs is returned in the 00062 // variable location. 00063 00064 // CHANGE HISTORY 00065 // -------------- 00066 // 00067 // 07 August 2007, P R Truscott, QinetiQ Ltd, UK - Created, with member 00068 // functions based on the work of Rickard Holmberg. 00069 // 12 October 2012, M Gayer, CERN, - Reviewed optimized implementation. 00070 // 00072 #ifndef G4TessellatedGeometryAlgorithms_hh 00073 #define G4TessellatedGeometryAlgorithms_hh 1 00074 00075 #include "G4TwoVector.hh" 00076 00077 class G4TessellatedGeometryAlgorithms 00078 { 00079 public: 00080 00081 static G4bool IntersectLineAndTriangle2D (const G4TwoVector &p, 00082 const G4TwoVector &v, 00083 const G4TwoVector &p0, 00084 const G4TwoVector &e0, 00085 const G4TwoVector &e1, 00086 G4TwoVector location[2]); 00087 static G4int IntersectLineAndLineSegment2D (const G4TwoVector &p0, 00088 const G4TwoVector &d0, 00089 const G4TwoVector &p1, 00090 const G4TwoVector &d1, 00091 G4TwoVector location[2]); 00092 static G4double cross(const G4TwoVector &v1, const G4TwoVector &v2); 00093 }; 00094 00095 #endif