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