Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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"
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
79//////////////////////////////////////////////////////////////////////////////
80
82{
83 // the bbox must include the start and endpoints as well as the
84 // extreme points if they lie on the curve
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))
95
96 if (IsPOn(u+pi))
97 bBox.Extend(GetPoint(u+pi));
98 }
99}
100
101//////////////////////////////////////////////////////////////////////////////
102
104{
105 G4Ellipse e;
106 e.Init(position, radius, radius);
108
109 return e.Project(tr);
110}
111
112//////////////////////////////////////////////////////////////////////////////
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
146////////////////////////////////////////////////////////////////////////////
147
148/*
149#include "G4CurveRayIntersection.hh"
150
151void 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}
@ FatalException
HepGeom::Point3D< G4double > G4Point3D
Definition: G4Point3D.hh:35
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
G4Vector3D GetPY() const
G4Vector3D GetPX() const
const G4Transform3D & GetToPlacementCoordinates() const
void Init(const G4Point3D &)
void Extend(const G4Point3D &)
virtual G4int IntersectRay2D(const G4Ray &ray)
virtual G4Curve * Project(const G4Transform3D &tr=G4Transform3D::Identity)
virtual G4double GetPPoint(const G4Point3D &p) const
virtual ~G4CircularCurve()
virtual G4double GetPMax() const
virtual G4Point3D GetPoint(G4double param) const
G4CircularCurve & operator=(const G4CircularCurve &right)
virtual void InitBounded()
virtual G4bool Tangent(G4CurvePoint &cp, G4Vector3D &v)
G4Axis2Placement3D position
Definition: G4Conic.hh:74
const G4Axis2Placement3D * GetPosition() const
G4double pShift
Definition: G4Conic.hh:77
const G4Point3D & GetPoint()
G4bool bounded
Definition: G4Curve.hh:166
G4double pStart
Definition: G4Curve.hh:163
void SetBounds(G4double p1, G4double p2)
G4bool IsPOn(G4double param) const
G4int sameSense
Definition: G4Curve.hh:167
G4Point3D end
Definition: G4Curve.hh:162
G4BoundingBox3D bBox
Definition: G4Curve.hh:160
G4double GetPEnd() const
G4double GetPStart() const
const G4Point3D & GetStart() const
const G4Point3D & GetEnd() const
G4double pRange
Definition: G4Curve.hh:165
G4Point3D start
Definition: G4Curve.hh:161
G4double pEnd
Definition: G4Curve.hh:164
G4Curve * Project(const G4Transform3D &tr=G4Transform3D::Identity)
Definition: G4Ellipse.cc:91
void Init(const G4Axis2Placement3D &position0, G4double semiAxis10, G4double semiAxis20)
Definition: G4Ray.hh:49
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41