Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4CircularCurve.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 // G4CircularCurve.cc
33 //
34 // ----------------------------------------------------------------------
35 
36 #include "G4CircularCurve.hh"
37 #include "G4PhysicalConstants.hh"
38 #include "G4Ellipse.hh"
39 
40 // G4CircularCurve
43 
45  : G4Conic(), radius(right.radius)
46 {
47  pShift = right.pShift;
48  position = right.position;
49  bBox = right.bBox;
50  start = right.start;
51  end = right.end;
52  pStart = right.pStart;
53  pEnd = right.pEnd;
54  pRange = right.pRange;
55  bounded = right.bounded;
56  sameSense = right.sameSense;
57 }
58 
61 {
62  if (&right == this) return *this;
63 
64  radius = right.radius;
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 
82 {
83  // the bbox must include the start and endpoints as well as the
84  // extreme points if they lie on the curve
85  bBox.Init(GetStart(), GetEnd());
86 
87  // the parameter values
88  // belonging to the points with an extreme x, y and z coordinate
89  for (G4int i=0; i<3; i++)
90  {
91  G4double u = std::atan2(position.GetPY()(i), position.GetPX()(i));
92 
93  if (IsPOn(u))
94  bBox.Extend(GetPoint(u));
95 
96  if (IsPOn(u+pi))
97  bBox.Extend(GetPoint(u+pi));
98  }
99 }
100 
102 
104 {
105  G4Ellipse e;
106  e.Init(position, radius, radius);
107  e.SetBounds(GetPStart(), GetPEnd());
108 
109  return e.Project(tr);
110 }
111 
113 
115 {
116  // The tangent is computed from the 3D point representation
117  // for all conics. An alternaive implementation (based on
118  // the parametric point) might be worthwhile adding
119  // for efficiency.
120 
121  const G4Axis2Placement3D& pos= *(GetPosition());
123 
124  v= -p.y()*pos.GetPX() + p.x()*pos.GetPY();
125  return true;
126 }
127 
129 {
130  return twopi;
131 }
132 
134 {
135  return G4Point3D( position.GetLocation()+radius*
136  ( std::cos(param)*position.GetPX() + std::sin(param)*position.GetPY() ) );
137 }
138 
140 {
141  G4Point3D ptLocal= position.GetToPlacementCoordinates()*pt;
142  G4double angle= std::atan2(ptLocal.y(), ptLocal.x());
143  return (angle<0)? angle+twopi: angle;
144 }
145 
147 
148 /*
149 #include "G4CurveRayIntersection.hh"
150 
151 void G4CircularCurve::IntersectRay2D(const G4Ray&,
152  G4CurveRayIntersection&)
153 {
154  G4Exception("G4CircularCurve::IntersectRay2D()",
155  "NotApplicable", FatalException,
156  "G4CircularCurve is always 3D!");
157 }
158 */
159 
161 {
162  G4Exception("G4CircularCurve::IntersectRay2D()", "GeomSolids0002",
163  FatalException,"G4CircularCurve is always 3D!");
164  return 0;
165 }