Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4Ellipse Class Reference

#include <G4Ellipse.hh>

+ Inheritance diagram for G4Ellipse:

Public Member Functions

 G4Ellipse ()
 
virtual ~G4Ellipse ()
 
 G4Ellipse (const G4Ellipse &right)
 
G4Ellipseoperator= (const G4Ellipse &right)
 
G4CurveProject (const G4Transform3D &tr=G4Transform3D::Identity)
 
G4bool Tangent (G4CurvePoint &cp, G4Vector3D &v)
 
G4double GetPMax () const
 
G4Point3D GetPoint (G4double param) const
 
G4double GetPPoint (const G4Point3D &p) const
 
G4double GetSemiAxis1 () const
 
G4double GetSemiAxis2 () const
 
void Init (const G4Axis2Placement3D &position0, G4double semiAxis10, G4double semiAxis20)
 
G4int IntersectRay2D (const G4Ray &ray)
 
- Public Member Functions inherited from G4Conic
 G4Conic ()
 
virtual ~G4Conic ()
 
 G4Conic (const G4Conic &right)
 
G4Conicoperator= (const G4Conic &right)
 
const G4Axis2Placement3DGetPosition () const
 
G4double GetPShift () const
 
void SetPShift (G4double pShift0)
 
- Public Member Functions inherited from G4Curve
 G4Curve ()
 
virtual ~G4Curve ()
 
 G4Curve (const G4Curve &c)
 
G4Curveoperator= (const G4Curve &c)
 
G4bool operator== (const G4Curve &right) const
 
virtual G4String GetEntityType () const
 
virtual G4CurveProject (const G4Transform3D &tr=G4Transform3D::Identity)=0
 
virtual G4bool Tangent (G4CurvePoint &cp, G4Vector3D &v)=0
 
virtual G4int IntersectRay2D (const G4Ray &ray)=0
 
const G4Point3DGetStart () const
 
const G4Point3DGetEnd () const
 
G4double GetPStart () const
 
G4double GetPEnd () const
 
void SetBounds (G4double p1, G4double p2)
 
void SetBounds (G4double p1, const G4Point3D &p2)
 
void SetBounds (const G4Point3D &p1, G4double p2)
 
void SetBounds (const G4Point3D &p1, const G4Point3D &p2)
 
G4bool IsBounded () const
 
G4bool IsPOn (G4double param) const
 
void SetSameSense (G4int sameSense0)
 
G4int GetSameSense () const
 
virtual G4double GetPMax () const =0
 
virtual G4Point3D GetPoint (G4double param) const =0
 
virtual G4double GetPPoint (const G4Point3D &p) const =0
 
const G4BoundingBox3DBBox () const
 
virtual const char * Name () const
 
virtual void SetParentSrfPtr (const G4Surface *)
 

Protected Member Functions

void InitBounded ()
 
virtual void InitBounded ()=0
 

Additional Inherited Members

- Protected Attributes inherited from G4Conic
G4Axis2Placement3D position
 
G4double pShift
 
- Protected Attributes inherited from G4Curve
G4BoundingBox3D bBox
 
G4Point3D start
 
G4Point3D end
 
G4double pStart
 
G4double pEnd
 
G4double pRange
 
G4bool bounded
 
G4int sameSense
 
G4double kCarTolerance
 

Detailed Description

Definition at line 46 of file G4Ellipse.hh.

Constructor & Destructor Documentation

◆ G4Ellipse() [1/2]

G4Ellipse::G4Ellipse ( )

Definition at line 42 of file G4Ellipse.cc.

43 : semiAxis1(0.), semiAxis2(0.), ratioAxis2Axis1(0.), forTangent(.0)
44{
45}

Referenced by Project().

◆ ~G4Ellipse()

G4Ellipse::~G4Ellipse ( )
virtual

Definition at line 47 of file G4Ellipse.cc.

48{
49}

◆ G4Ellipse() [2/2]

G4Ellipse::G4Ellipse ( const G4Ellipse right)

Definition at line 51 of file G4Ellipse.cc.

52 : G4Conic(), semiAxis1(right.semiAxis1), semiAxis2(right.semiAxis2),
53 ratioAxis2Axis1(right.ratioAxis2Axis1), toUnitCircle(right.toUnitCircle),
54 forTangent(right.forTangent)
55{
56 pShift = right.pShift;
57 position = right.position;
58 bBox = right.bBox;
59 start = right.start;
60 end = right.end;
61 pStart = right.pStart;
62 pEnd = right.pEnd;
63 pRange = right.pRange;
64 bounded = right.bounded;
65 sameSense = right.sameSense;
66}
G4Axis2Placement3D position
Definition: G4Conic.hh:74
G4double pShift
Definition: G4Conic.hh:77
G4Conic()
Definition: G4Conic.cc:38
G4bool bounded
Definition: G4Curve.hh:166
G4double pStart
Definition: G4Curve.hh:163
G4int sameSense
Definition: G4Curve.hh:167
G4Point3D end
Definition: G4Curve.hh:162
G4BoundingBox3D bBox
Definition: G4Curve.hh:160
G4double pRange
Definition: G4Curve.hh:165
G4Point3D start
Definition: G4Curve.hh:161
G4double pEnd
Definition: G4Curve.hh:164

Member Function Documentation

◆ GetPMax()

G4double G4Ellipse::GetPMax ( ) const
inlinevirtual

Implements G4Curve.

◆ GetPoint()

G4Point3D G4Ellipse::GetPoint ( G4double  param) const
inlinevirtual

Implements G4Curve.

Referenced by InitBounded().

◆ GetPPoint()

G4double G4Ellipse::GetPPoint ( const G4Point3D p) const
inlinevirtual

Implements G4Curve.

◆ GetSemiAxis1()

G4double G4Ellipse::GetSemiAxis1 ( ) const
inline

◆ GetSemiAxis2()

G4double G4Ellipse::GetSemiAxis2 ( ) const
inline

◆ Init()

void G4Ellipse::Init ( const G4Axis2Placement3D position0,
G4double  semiAxis10,
G4double  semiAxis20 
)
inline

◆ InitBounded()

void G4Ellipse::InitBounded ( )
protectedvirtual

Implements G4Curve.

Definition at line 155 of file G4Ellipse.cc.

156{
157 // original implementation
158 // const G4Point3D& center = position.GetLocation();
159 // G4double maxEntent = std::max(semiAxis1, semiAxis2);
160 // G4Vector3D halfExtent(maxEntent, maxEntent, maxEntent);
161 // bBox.Init(center+halfExtent, center-halfExtent);
162
163 // the bbox must include the start and endpoints as well as the
164 // extreme points if they lie on the curve
165 bBox.Init(GetStart(), GetEnd());
166
167 // the parameter values
168 // belonging to the points with an extreme x, y and z coordinate
169 for (G4int i=0; i<3; i++)
170 {
171 G4double u= std::atan2(position.GetPY()(i)*semiAxis2,
172 position.GetPX()(i)*semiAxis1);
173 if (IsPOn(u))
174 bBox.Extend(GetPoint(u));
175
176 if (IsPOn(u+pi))
177 bBox.Extend(GetPoint(u+pi));
178 }
179}
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
void Init(const G4Point3D &)
void Extend(const G4Point3D &)
G4bool IsPOn(G4double param) const
const G4Point3D & GetStart() const
const G4Point3D & GetEnd() const
G4Point3D GetPoint(G4double param) const

◆ IntersectRay2D()

G4int G4Ellipse::IntersectRay2D ( const G4Ray ray)
inlinevirtual

Implements G4Curve.

◆ operator=()

G4Ellipse & G4Ellipse::operator= ( const G4Ellipse right)

Definition at line 68 of file G4Ellipse.cc.

69{
70 if (&right == this) return *this;
71
72 semiAxis1 = right.semiAxis1;
73 semiAxis2 = right.semiAxis2;
74 ratioAxis2Axis1 = right.ratioAxis2Axis1;
75 toUnitCircle = right.toUnitCircle;
76 forTangent = right.forTangent;
77 pShift = right.pShift;
78 position = right.position;
79 bBox = right.bBox;
80 start = right.start;
81 end = right.end;
82 pStart = right.pStart;
83 pEnd = right.pEnd;
84 pRange = right.pRange;
85 bounded = right.bounded;
86 sameSense = right.sameSense;
87
88 return *this;
89}

◆ Project()

G4Curve * G4Ellipse::Project ( const G4Transform3D tr = G4Transform3D::Identity)
virtual

Implements G4Curve.

Definition at line 91 of file G4Ellipse.cc.

92{
93 G4Point3D newLocation = tr*position.GetLocation();
94 newLocation.setZ(0);
95 G4double axisZ = ( tr*position.GetPZ() ).unit().z();
96
98 { return 0; }
99
100 G4Vector3D newAxis(0, 0, axisZ>0? +1: -1);
101
102 // get the parameter of an endpoint of an axis
103 // (this is a point the distance of which from the center is extreme)
104 G4Vector3D xPrime= tr*position.GetPX();
105 xPrime.setZ(0);
106 G4Vector3D yPrime= tr*position.GetPY();
107 yPrime.setZ(0);
108
109 G4Vector3D a = G4Vector3D( semiAxis1*xPrime );
110 G4Vector3D b = G4Vector3D( semiAxis2*yPrime );
111
112 G4double u;
113 G4double abmag = a.mag2()-b.mag2();
114 G4double prod = 2*a*b;
115
116 if ((abmag > FLT_MAX) && (prod < -FLT_MAX))
117 u = -pi/8;
118 else if ((abmag < -FLT_MAX) && (prod > FLT_MAX))
119 u = 3*pi/8;
120 else if ((abmag < -FLT_MAX) && (prod < -FLT_MAX))
121 u = -3*pi/8;
122 else if ((std::abs(abmag) < perMillion) && (std::abs(prod) < perMillion))
123 u = 0.;
124 else
125 u = std::atan2(prod,abmag) / 2;
126
127 // get the coordinate axis directions and the semiaxis lengths
128 G4Vector3D sAxis1 = G4Vector3D( a*std::cos(u)+b*std::sin(u) );
129 G4Vector3D sAxis2 = G4Vector3D( a*std::cos(u+pi/2)+b*std::sin(u+pi/2) );
130 G4double newSemiAxis1 = sAxis1.mag();
131 G4double newSemiAxis2 = sAxis2.mag();
132 G4Vector3D newRefDirection = sAxis1;
133
134 // create the new ellipse
135 G4Axis2Placement3D newPosition;
136 newPosition.Init(newRefDirection, newAxis, newLocation);
137 G4Ellipse* r= new G4Ellipse;
138 r->Init(newPosition, newSemiAxis1, newSemiAxis2);
139
140 // introduce the shift in the parametrization
141 // maybe the Sign must be changed?
142 r->SetPShift(u);
143
144 // set the bounds when necessary
145 if (IsBounded())
146 r->SetBounds(GetPStart(), GetPEnd());
147
148 // L. Broglia
149 // copy sense of the curve
151
152 return r;
153}
HepGeom::Vector3D< G4double > G4Vector3D
Definition: G4Vector3D.hh:35
void Init(const G4Vector3D &refDirection0, const G4Vector3D &axis0, const G4Point3D &location0)
void SetPShift(G4double pShift0)
void SetSameSense(G4int sameSense0)
G4bool IsBounded() const
void SetBounds(G4double p1, G4double p2)
G4int GetSameSense() const
G4double GetPEnd() const
G4double GetPStart() const
void Init(const G4Axis2Placement3D &position0, G4double semiAxis10, G4double semiAxis20)
static G4GeometryTolerance * GetInstance()
G4double GetAngularTolerance() const
const G4double pi
#define FLT_MAX
Definition: templates.hh:99

Referenced by G4CircularCurve::Project().

◆ Tangent()

G4bool G4Ellipse::Tangent ( G4CurvePoint cp,
G4Vector3D v 
)
virtual

Implements G4Curve.

Definition at line 182 of file G4Ellipse.cc.

183{
184 // The tangent is computed from the 3D point representation
185 // for all conics. An alternaive implementation (based on
186 // the parametric point) might be worthwhile adding
187 // for efficiency.
188
189 const G4Axis2Placement3D& pos = *(GetPosition());
191
192 v=forTangent*p.y()*pos.GetPX() + p.x()*pos.GetPY();
193 if(GetSameSense())
194 v = -v;
195
196 return true;
197}
G4Vector3D GetPY() const
G4Vector3D GetPX() const
const G4Transform3D & GetToPlacementCoordinates() const
const G4Axis2Placement3D * GetPosition() const
const G4Point3D & GetPoint()

The documentation for this class was generated from the following files: