Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4Parabola.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 // G4Parabola.cc
33 //
34 // ----------------------------------------------------------------------
35 
36 #include "G4Parabola.hh"
37 #include "G4CurvePoint.hh"
38 #include "G4GeometryTolerance.hh"
39 
40 G4Parabola::G4Parabola() : focalDist(0.) {}
42 
44  : G4Conic(), focalDist(right.focalDist), F(right.F), L0(right.L0)
45 {
46  pShift = right.pShift;
47  position = right.position;
48  bBox = right.bBox;
49  start = right.start;
50  end = right.end;
51  pStart = right.pStart;
52  pEnd = right.pEnd;
53  pRange = right.pRange;
54  bounded = right.bounded;
55  sameSense = right.sameSense;
56 }
57 
59 {
60  if (&right == this) return *this;
61 
62  F = right.F;
63  L0 = right.L0;
64  focalDist = right.focalDist;
65  pShift = right.pShift;
66  position = right.position;
67  bBox = right.bBox;
68  start = right.start;
69  end = right.end;
70  pStart = right.pStart;
71  pEnd = right.pEnd;
72  pRange = right.pRange;
73  bounded = right.bounded;
74  sameSense = right.sameSense;
75 
76  return *this;
77 }
78 
80 {
81  G4double axisZ= (tr*position.GetPZ()).unit().z();
82 
83  if (std::abs(axisZ)<G4GeometryTolerance::GetInstance()->GetAngularTolerance())
84  { return 0; }
85 
86 
87  G4Vector3D newAxis(0, 0, axisZ>0? +1: -1);
88 
89  G4Vector3D xPrime= tr*position.GetPX();
90  xPrime.setZ(0);
91  G4Vector3D yPrime= tr*position.GetPY();
92  yPrime.setZ(0);
93  G4double u= -(xPrime*yPrime)/xPrime.mag2();
94 
95  G4Point3D newLocation= G4Point3D( tr*position.GetLocation()+
96  focalDist*(u*u*xPrime+2*u*yPrime) );
97  newLocation.setZ(0);
98  G4Vector3D newRefDirection= xPrime;
99  G4double newFocalDist= (focalDist*((2*u+1)*xPrime+2*yPrime)).mag()/std::sqrt(5.);
100 
101  // create the new parabola
102  G4Axis2Placement3D newPosition;
103  newPosition.Init(newRefDirection, newAxis, newLocation);
104  G4Parabola* r= new G4Parabola;
105  r->Init(newPosition, newFocalDist);
106 
107  // introduce the shift in the parametrization
108  // maybe the Sign must be changed?
109  r->SetPShift(u);
110 
111  // set the bounds when necessary
112  if (IsBounded())
113  r->SetBounds(GetPStart(), GetPEnd());
114 
115  return r;
116 }
117 
118 
120 {
121  // the bbox must include the start and endpoints as well as the
122  // extreme points if they lie on the curve
123  bBox.Init(GetStart(), GetEnd());
124 
125  // the parameter values
126  // belonging to the points with an extreme x, y and z coordinate
127  for (G4int i=0; i<3; i++)
128  {
129  G4double x_i= position.GetPX()(i);
130 
131  if (std::abs(x_i) <=
133  {
134  G4double u= - position.GetPY()(i) / x_i;
135  if (IsPOn(u))
136  bBox.Extend(GetPoint(u));
137  }
138  }
139 }
140 
141 
143 {
144  // The tangent is computed from the 3D point representation
145  // for all conics. An alternaive implementation (based on
146  // the parametric point) might be worthwhile adding
147  // for efficiency.
148 
149  const G4Axis2Placement3D& pos= *(GetPosition());
151 
152  v= p.y()*pos.GetPX() + (2*focalDist)*pos.GetPY();
153  return true;
154 }