source: trunk/source/geometry/solids/BREPS/src/G4CircularCurve.cc@ 1354

Last change on this file since 1354 was 1337, checked in by garnier, 15 years ago

tag geant4.9.4 beta 1 + modifs locales

File size: 5.3 KB
Line 
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: G4CircularCurve.cc,v 1.10 2006/06/29 18:41:52 gunter Exp $
28// GEANT4 tag $Name: geant4-09-04-beta-01 $
29//
30// ----------------------------------------------------------------------
31// GEANT 4 class source file
32//
33// G4CircularCurve.cc
34//
35// ----------------------------------------------------------------------
36
37#include "G4CircularCurve.hh"
38#include "G4Ellipse.hh"
39
40// G4CircularCurve
41G4CircularCurve::G4CircularCurve() {}
42G4CircularCurve::~G4CircularCurve() {}
43
44G4CircularCurve::G4CircularCurve(const G4CircularCurve& right)
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
59G4CircularCurve&
60G4CircularCurve::operator=(const G4CircularCurve& right)
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
81void G4CircularCurve::InitBounded()
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
101//////////////////////////////////////////////////////////////////////////////
102
103G4Curve* G4CircularCurve::Project(const G4Transform3D& tr)
104{
105 G4Ellipse e;
106 e.Init(position, radius, radius);
107 e.SetBounds(GetPStart(), GetPEnd());
108
109 return e.Project(tr);
110}
111
112//////////////////////////////////////////////////////////////////////////////
113
114G4bool G4CircularCurve::Tangent(G4CurvePoint& cp, G4Vector3D& v)
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());
122 G4Point3D p= pos.GetToPlacementCoordinates() * cp.GetPoint();
123
124 v= -p.y()*pos.GetPX() + p.x()*pos.GetPY();
125 return true;
126}
127
128G4double G4CircularCurve::GetPMax() const
129{
130 return twopi;
131}
132
133G4Point3D G4CircularCurve::GetPoint(G4double param) const
134{
135 return G4Point3D( position.GetLocation()+radius*
136 ( std::cos(param)*position.GetPX() + std::sin(param)*position.GetPY() ) );
137}
138
139G4double G4CircularCurve::GetPPoint(const G4Point3D& pt) const
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
160G4int G4CircularCurve::IntersectRay2D(const G4Ray&)
161{
162 G4Exception("G4CircularCurve::IntersectRay2D()",
163 "NotApplicable", FatalException,
164 "G4CircularCurve is always 3D!");
165 return 0;
166}
Note: See TracBrowser for help on using the repository browser.