Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Data Fields | Protected Attributes
UEnclosingCylinder Class Reference

#include <UEnclosingCylinder.hh>

Public Member Functions

 UEnclosingCylinder (double r, double lo, double hi, bool phiIsOpen, double startPhi, double totalPhi)
 
 ~UEnclosingCylinder ()
 
bool MustBeOutside (const UVector3 &p) const
 
bool ShouldMiss (const UVector3 &p, const UVector3 &v) const
 
double DistanceTo (const UVector3 &p, const UVector3 &v) const
 
double SafetyFromOutside (const UVector3 &p) const
 
void Extent (UVector3 &aMin, UVector3 &aMax) const
 

Data Fields

double radius
 

Protected Attributes

double zLo
 
double zHi
 
bool phiIsOpen
 
double startPhi
 
double totalPhi
 
double rx1
 
double ry1
 
double dx1
 
double dy1
 
double rx2
 
double ry2
 
double dx2
 
double dy2
 
bool concave
 
UTubstube
 

Detailed Description

Definition at line 31 of file UEnclosingCylinder.hh.

Constructor & Destructor Documentation

UEnclosingCylinder::UEnclosingCylinder ( double  r,
double  lo,
double  hi,
bool  phiIsOpen,
double  startPhi,
double  totalPhi 
)

Definition at line 31 of file UEnclosingCylinder.cc.

References dx1, dx2, dy1, dy2, phiIsOpen, radius, rx1, rx2, ry1, ry2, startPhi, VUSolid::Tolerance(), totalPhi, tube, zHi, and zLo.

35  : startPhi(theStartPhi), totalPhi(theTotalPhi),
36  rx1(0.), ry1(0.), dx1(0.), dy1(0.),
37  rx2(0.), ry2(0.), dx2(0.), dy2(0.),
38  concave(theTotalPhi > UUtils::kPi)
39 {
40  //
41  // Obtain largest r and smallest and largest z
42  //
43 
44  /*
45  radius = rz->Amax();
46  zHi = rz->Bmax();
47  zLo = rz->Bmin();
48  */
49 
50  radius = r;
51  zHi = hi;
52  zLo = lo;
53 
54  double fTolerance = VUSolid::Tolerance();
55 
56  tube = new UTubs("", 0, radius + fTolerance, zHi - zLo, theStartPhi, theTotalPhi);
57 
58  //
59  // Save phi info
60  //
61  phiIsOpen = thePhiIsOpen;
62  if (phiIsOpen)
63  {
64  rx1 = std::cos(startPhi);
65  ry1 = std::sin(startPhi);
66  dx1 = +ry1 * 10 * fTolerance;
67  dy1 = -rx1 * 10 * fTolerance;
68 
69  rx2 = std::cos(startPhi + totalPhi);
70  ry2 = std::sin(startPhi + totalPhi);
71  dx2 = -ry2 * 10 * fTolerance;
72  dy2 = +rx2 * 10 * fTolerance;
73  }
74 
75  //
76  // Add safety
77  //
78  radius += 10 * fTolerance;
79  zLo -= 10 * fTolerance;
80  zHi += 10 * fTolerance;
81 }
Definition: UTubs.hh:47
static double Tolerance()
Definition: VUSolid.hh:127
UEnclosingCylinder::~UEnclosingCylinder ( )

Definition at line 87 of file UEnclosingCylinder.cc.

88 {
89 }

Member Function Documentation

double UEnclosingCylinder::DistanceTo ( const UVector3 p,
const UVector3 v 
) const

Definition at line 179 of file UEnclosingCylinder.cc.

References UTubs::DistanceToIn(), and tube.

180 {
181  return tube->DistanceToIn(p, v);
182 }
double DistanceToIn(const UVector3 &p, const UVector3 &v, double aPstep=UUtils::kInfinity) const
Definition: UTubs.cc:614
void UEnclosingCylinder::Extent ( UVector3 aMin,
UVector3 aMax 
) const

Definition at line 173 of file UEnclosingCylinder.cc.

References radius, zHi, and zLo.

Referenced by UGenericPolycone::Extent(), and UPolyhedra::Extent().

174 {
175  aMin = UVector3(-radius, -radius, zLo);
176  aMax = UVector3(radius, radius, zHi);
177 }
bool UEnclosingCylinder::MustBeOutside ( const UVector3 p) const

Definition at line 99 of file UEnclosingCylinder.cc.

References concave, dx1, dx2, dy1, dy2, UVector3::Perp2(), phiIsOpen, radius, rx1, rx2, ry1, ry2, UVector3::x, UVector3::y, UVector3::z, zHi, and zLo.

Referenced by UGenericPolycone::Inside(), UPolyhedra::Inside(), and ShouldMiss().

100 {
101 // if (p.Perp() > radius ) return true;
102  if (p.Perp2() > radius * radius) return true;
103  if (p.z < zLo) return true;
104  if (p.z > zHi) return true;
105 
106  if (phiIsOpen)
107  {
108  if (concave)
109  {
110  if (((p.x - dx1)*ry1 - (p.y - dy1)*rx1) < 0) return false;
111  if (((p.x - dx2)*ry2 - (p.y - dy2)*rx2) > 0) return false;
112  }
113  else
114  {
115  if (((p.x - dx1)*ry1 - (p.y - dy1)*rx1) > 0) return true;
116  if (((p.x - dx2)*ry2 - (p.y - dy2)*rx2) < 0) return true;
117  }
118  }
119 
120  return false;
121 }
double x
Definition: UVector3.hh:136
double Perp2() const
Definition: UVector3.hh:272
double z
Definition: UVector3.hh:138
double y
Definition: UVector3.hh:137
double UEnclosingCylinder::SafetyFromOutside ( const UVector3 p) const

Definition at line 184 of file UEnclosingCylinder.cc.

References UTubs::SafetyFromOutside(), and tube.

Referenced by UPolycone::SafetyFromOutside().

185 {
186  return tube->SafetyFromOutside(p);
187 }
double SafetyFromOutside(const UVector3 &p, bool precise=false) const
Definition: UTubs.cc:1030
bool UEnclosingCylinder::ShouldMiss ( const UVector3 p,
const UVector3 v 
) const

Definition at line 131 of file UEnclosingCylinder.cc.

References MustBeOutside(), UVector3::Perp2(), radius, UVector3::x, and UVector3::y.

Referenced by UGenericPolycone::DistanceToIn(), and UPolyhedra::DistanceToIn().

133 {
134  if (!MustBeOutside(p)) return false;
135 
136 // if (p.z < zLo - VUSolid::Tolerance() && v.z <= 0) return true;
137 // if (p.z > zHi + VUSolid::Tolerance() && v.z >= 0) return true;
138 
139  double cross = p.x * v.y - p.y * v.x;
140  if (cross > radius) return true;
141 
142  double r2 = p.Perp2();
143  if (r2 > radius * radius)
144  {
145  double dot = p.x * v.x + p.y * v.y;
146  if (dot > 0) return true;
147 
148 // double n = v.Perp2();
149 // if (Dot < std::sqrt(r2 - radius * radius) * n) return true;
150  }
151 
152 
153  /*
154  if (phiIsOpen)
155  {
156  if (concave)
157  {
158  if ( ((p.x-dx1)*ry1 - (p.y-dy1)*rx1) < 0) return false;
159  if ( ((p.x-dx2)*ry2 - (p.y-dy2)*rx2) > 0) return false;
160  }
161  else
162  {
163  if ( ((p.x-dx1)*ry1 - (p.y-dy1)*rx1) > 0) return true;
164  if ( ((p.x-dx2)*ry2 - (p.y-dy2)*rx2) < 0) return true;
165  }
166  return false;
167  }
168  */
169 
170  return false;
171 }
bool MustBeOutside(const UVector3 &p) const
double x
Definition: UVector3.hh:136
double Perp2() const
Definition: UVector3.hh:272
double y
Definition: UVector3.hh:137

Field Documentation

bool UEnclosingCylinder::concave
protected

Definition at line 71 of file UEnclosingCylinder.hh.

Referenced by MustBeOutside().

double UEnclosingCylinder::dx1
protected

Definition at line 66 of file UEnclosingCylinder.hh.

Referenced by MustBeOutside(), and UEnclosingCylinder().

double UEnclosingCylinder::dx2
protected

Definition at line 68 of file UEnclosingCylinder.hh.

Referenced by MustBeOutside(), and UEnclosingCylinder().

double UEnclosingCylinder::dy1
protected

Definition at line 66 of file UEnclosingCylinder.hh.

Referenced by MustBeOutside(), and UEnclosingCylinder().

double UEnclosingCylinder::dy2
protected

Definition at line 68 of file UEnclosingCylinder.hh.

Referenced by MustBeOutside(), and UEnclosingCylinder().

bool UEnclosingCylinder::phiIsOpen
protected

Definition at line 62 of file UEnclosingCylinder.hh.

Referenced by MustBeOutside(), and UEnclosingCylinder().

double UEnclosingCylinder::radius
double UEnclosingCylinder::rx1
protected

Definition at line 66 of file UEnclosingCylinder.hh.

Referenced by MustBeOutside(), and UEnclosingCylinder().

double UEnclosingCylinder::rx2
protected

Definition at line 68 of file UEnclosingCylinder.hh.

Referenced by MustBeOutside(), and UEnclosingCylinder().

double UEnclosingCylinder::ry1
protected

Definition at line 66 of file UEnclosingCylinder.hh.

Referenced by MustBeOutside(), and UEnclosingCylinder().

double UEnclosingCylinder::ry2
protected

Definition at line 68 of file UEnclosingCylinder.hh.

Referenced by MustBeOutside(), and UEnclosingCylinder().

double UEnclosingCylinder::startPhi
protected

Definition at line 63 of file UEnclosingCylinder.hh.

Referenced by UEnclosingCylinder().

double UEnclosingCylinder::totalPhi
protected

Definition at line 63 of file UEnclosingCylinder.hh.

Referenced by UEnclosingCylinder().

UTubs* UEnclosingCylinder::tube
protected

Definition at line 73 of file UEnclosingCylinder.hh.

Referenced by DistanceTo(), SafetyFromOutside(), and UEnclosingCylinder().

double UEnclosingCylinder::zHi
protected

Definition at line 60 of file UEnclosingCylinder.hh.

Referenced by Extent(), MustBeOutside(), and UEnclosingCylinder().

double UEnclosingCylinder::zLo
protected

Definition at line 60 of file UEnclosingCylinder.hh.

Referenced by Extent(), MustBeOutside(), and UEnclosingCylinder().


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