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: testG4Ellipsoid.cc,v 1.5 2007/02/09 12:05:51 gcosmo Exp $ |
---|
28 | // GEANT4 tag $Name: geant4-09-04-ref-00 $ |
---|
29 | // |
---|
30 | // testG4Ellipsoid |
---|
31 | // |
---|
32 | // Test file for class G4Ellipsoid |
---|
33 | // |
---|
34 | // Ensure asserts are compiled in |
---|
35 | |
---|
36 | #include <assert.h> |
---|
37 | #include <cmath> |
---|
38 | |
---|
39 | #include "globals.hh" |
---|
40 | #include "geomdefs.hh" |
---|
41 | |
---|
42 | #include "G4ThreeVector.hh" |
---|
43 | #include "G4Ellipsoid.hh" |
---|
44 | #include "G4RotationMatrix.hh" |
---|
45 | #include "G4AffineTransform.hh" |
---|
46 | #include "G4VoxelLimits.hh" |
---|
47 | |
---|
48 | |
---|
49 | G4bool testG4Ellipsoid() |
---|
50 | { |
---|
51 | |
---|
52 | //test full ellipsoid |
---|
53 | |
---|
54 | G4ThreeVector pzero(0,0,0); |
---|
55 | G4ThreeVector pout ( 200*cm,200*cm,200*cm) ; |
---|
56 | G4ThreeVector dir = pzero-pout ; |
---|
57 | dir *= 1/dir.mag(); |
---|
58 | |
---|
59 | G4Ellipsoid t1("Solid Ellipsoid #1", |
---|
60 | 20*cm, // xSemiAxis |
---|
61 | 10*cm, // ySemiAxis |
---|
62 | 15*cm) ; // zSemiAxis |
---|
63 | |
---|
64 | |
---|
65 | G4double dist = t1.DistanceToIn(pout,dir) ; |
---|
66 | G4cout << "distance = " << dist << G4endl ; |
---|
67 | |
---|
68 | // Check Inside |
---|
69 | |
---|
70 | G4cout << "Test Inside(p) " << G4endl << G4endl ; |
---|
71 | |
---|
72 | G4cout << "pzero : " << t1.Inside(pzero) << G4endl ; |
---|
73 | |
---|
74 | //test the name |
---|
75 | G4cout << "The name is" << t1.GetName() << G4endl ; |
---|
76 | |
---|
77 | // testing the volume |
---|
78 | |
---|
79 | G4double volume = t1.GetCubicVolume() ; |
---|
80 | G4cout << G4endl << G4endl ; |
---|
81 | G4cout << "Test Ellipsoid #1 Volume = " << volume / cm / cm /cm << " cm^3" << G4endl ; |
---|
82 | |
---|
83 | |
---|
84 | //test cut ellipsoid |
---|
85 | G4ThreeVector onTop(0*cm, 0*cm, 50*cm); |
---|
86 | G4ThreeVector axial = onTop - pzero; |
---|
87 | axial *= 1/axial.mag() ; |
---|
88 | |
---|
89 | G4Ellipsoid t2("Solid Ellipsoid #2", |
---|
90 | 20*cm, |
---|
91 | 10*cm, |
---|
92 | 15*cm, |
---|
93 | -10*cm, |
---|
94 | 8*cm) ; |
---|
95 | |
---|
96 | dist = t2.DistanceToIn(onTop,axial) ; |
---|
97 | G4cout << "distance = " << dist << G4endl ; |
---|
98 | |
---|
99 | // Check Inside |
---|
100 | |
---|
101 | G4cout << "Test Inside(p) " << G4endl << G4endl ; |
---|
102 | |
---|
103 | G4cout << "pzero : " << t2.Inside(pzero) << G4endl ; |
---|
104 | |
---|
105 | //test the name |
---|
106 | G4cout << "The name is" << t2.GetName() << G4endl ; |
---|
107 | |
---|
108 | // testing the volume |
---|
109 | |
---|
110 | volume = t2.GetCubicVolume() ; |
---|
111 | G4cout << G4endl << G4endl ; |
---|
112 | G4cout << "Test Ellipsoid #2 Volume = " << volume / cm / cm /cm << " cm^3" << G4endl ; |
---|
113 | |
---|
114 | return true; |
---|
115 | } |
---|
116 | |
---|
117 | int main() |
---|
118 | { |
---|
119 | #ifdef NDEBUG |
---|
120 | G4Exception("FAIL: *** Assertions must be compiled in! ***"); |
---|
121 | #endif |
---|
122 | assert(testG4Ellipsoid()); |
---|
123 | return 0; |
---|
124 | } |
---|
125 | |
---|