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: G4Axis2Placement3D.cc,v 1.9 2006/06/29 18:41:09 gunter Exp $ |
---|
28 | // GEANT4 tag $Name: geant4-09-02-ref-02 $ |
---|
29 | // |
---|
30 | // ---------------------------------------------------------------------- |
---|
31 | // GEANT 4 class source file |
---|
32 | // |
---|
33 | // G4Axis2Placement3D.cc |
---|
34 | // |
---|
35 | // ---------------------------------------------------------------------- |
---|
36 | |
---|
37 | #include "G4Axis2Placement3D.hh" |
---|
38 | |
---|
39 | //G4Axis2Placement3D |
---|
40 | G4Axis2Placement3D::G4Axis2Placement3D(){} |
---|
41 | G4Axis2Placement3D::~G4Axis2Placement3D(){} |
---|
42 | |
---|
43 | // copy constructor (used in STEPinterface module) |
---|
44 | // |
---|
45 | G4Axis2Placement3D::G4Axis2Placement3D(const G4Axis2Placement3D& place) |
---|
46 | : location(place.location), axis(place.axis), |
---|
47 | refDirection(place.refDirection), |
---|
48 | pX(place.pX), pY(place.pY), pZ(place.pZ), |
---|
49 | toPlacementCoordinates(place.toPlacementCoordinates), |
---|
50 | fromPlacementCoordinates(place.fromPlacementCoordinates) |
---|
51 | { |
---|
52 | } |
---|
53 | |
---|
54 | // assignment operator |
---|
55 | // |
---|
56 | G4Axis2Placement3D& |
---|
57 | G4Axis2Placement3D::operator=(const G4Axis2Placement3D& place) |
---|
58 | { |
---|
59 | if (&place == this) return *this; |
---|
60 | |
---|
61 | refDirection = place.refDirection; |
---|
62 | axis = place.axis; |
---|
63 | location = place.location; |
---|
64 | pX = place.pX; |
---|
65 | pY = place.pY; |
---|
66 | pZ = place.pZ; |
---|
67 | toPlacementCoordinates = place.toPlacementCoordinates; |
---|
68 | fromPlacementCoordinates = place.fromPlacementCoordinates; |
---|
69 | |
---|
70 | return *this; |
---|
71 | } |
---|
72 | |
---|
73 | /* everything below here is commented-out ... |
---|
74 | |
---|
75 | G4Axis2Placement3D::G4Axis2Placement3D(const G4ThreeVec Dir, |
---|
76 | const G4ThreeVec Axis, |
---|
77 | const G4Point3d Pt ) |
---|
78 | { |
---|
79 | dir=Dir; |
---|
80 | axis=Axis; |
---|
81 | srf_point=Pt; |
---|
82 | ComputeNormal(); |
---|
83 | G4Point3d Pt2 = Pt+Dir; |
---|
84 | G4Point3d Pt3 = Pt+Axis; |
---|
85 | G4Ray::CalcPlane3Pts(Pl, Pt, Pt2, Pt3); |
---|
86 | } |
---|
87 | |
---|
88 | G4Axis2Placement3D::G4Axis2Placement3D(const G4ThreeVec Dir, |
---|
89 | const G4ThreeVec Axis, |
---|
90 | const G4Point3d Pt1, |
---|
91 | const G4Point3d Pt2, |
---|
92 | const G4Point3d Pt3) |
---|
93 | { |
---|
94 | dir=Dir; |
---|
95 | axis=Axis; |
---|
96 | srf_point=Pt1; |
---|
97 | ComputeNormal(); |
---|
98 | G4Ray::CalcPlane3Pts(Pl, Pt1, Pt2, Pt3); |
---|
99 | } |
---|
100 | |
---|
101 | void |
---|
102 | G4Axis2Placement3D::ProjectPlacement(const G4Plane& Pl1, |
---|
103 | const G4Plane& Pl2) |
---|
104 | { |
---|
105 | Project(ProjectedDir, dir, Pl1, Pl2); |
---|
106 | Project(ProjectedAxis, axis, Pl1, Pl2); |
---|
107 | Project(ProjectedSrfPoint, srf_point, Pl1, Pl2); |
---|
108 | Project(ProjectedNormal, Normal, Pl1, Pl2); |
---|
109 | } |
---|
110 | |
---|
111 | void |
---|
112 | G4Axis2Placement3D::ComputeNormal() |
---|
113 | { |
---|
114 | |
---|
115 | if(dir == axis) |
---|
116 | Normal = dir; |
---|
117 | else |
---|
118 | { |
---|
119 | Normal.X(dir.Y()*axis.Z() - dir.Z()*axis.Y()); |
---|
120 | Normal.Y(dir.X()*axis.Z()- dir.Z()*axis.X()); |
---|
121 | Normal.Z(dir.X()*axis.Y() - dir.Y()*axis.X()); |
---|
122 | } |
---|
123 | } |
---|
124 | |
---|
125 | |
---|
126 | G4Point3d |
---|
127 | G4Axis2Placement3D::EvaluateIntersection(register const G4Ray& rray) |
---|
128 | { |
---|
129 | |
---|
130 | // s is solution, line is p + tq, n is G4Plane Normal, r is point on G4Plane |
---|
131 | // all parameters are pointers to arrays of three elements |
---|
132 | |
---|
133 | register G4double a, b, t; |
---|
134 | register const G4ThreeVec& RayDir = rray.GetDir(); |
---|
135 | register const G4Point3d& RayStart = rray.GetStart(); |
---|
136 | G4double dirx = RayDir.X(); |
---|
137 | G4double diry = RayDir.Y(); |
---|
138 | G4double dirz = RayDir.Z(); |
---|
139 | b = Normal.X() * dirx + Normal.Y() * diry + Normal.Z() * dirz; |
---|
140 | |
---|
141 | if (std::fabs(b) < 0.001)//== 0.0) |
---|
142 | // or some better test involving a small positive e |
---|
143 | { |
---|
144 | // G4cout << "\nLine is parallel to G4Plane.No Hit."; |
---|
145 | G4Point3d hit_point( kInfinity, kInfinity, kInfinity); |
---|
146 | return hit_point; |
---|
147 | } |
---|
148 | G4double startx = RayStart.X(); |
---|
149 | G4double starty = RayStart.Y(); |
---|
150 | G4double startz = RayStart.Z(); |
---|
151 | |
---|
152 | a = Normal.X() * (srf_point.X() - startx) |
---|
153 | + Normal.Y() * (srf_point.Y() - starty) |
---|
154 | + Normal.Z() * (srf_point.Z() - startz); |
---|
155 | |
---|
156 | t = a/b; |
---|
157 | |
---|
158 | // substitute t into line equation |
---|
159 | // to calculate final solution |
---|
160 | G4Point3d hit_point(startx + t * dirx,starty |
---|
161 | + t * diry,startz |
---|
162 | + t * dirz); |
---|
163 | |
---|
164 | // G4cout << "\nPLANE HIT POINT :" << hit_point.X() |
---|
165 | // << " " << hit_point.Y() << " " << hit_point.Z(); |
---|
166 | return hit_point; |
---|
167 | } |
---|
168 | */ |
---|