00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include "G4CircularCurve.hh"
00037 #include "G4PhysicalConstants.hh"
00038 #include "G4Ellipse.hh"
00039
00040
00041 G4CircularCurve::G4CircularCurve() : radius(0.) {}
00042 G4CircularCurve::~G4CircularCurve() {}
00043
00044 G4CircularCurve::G4CircularCurve(const G4CircularCurve& right)
00045 : G4Conic(), radius(right.radius)
00046 {
00047 pShift = right.pShift;
00048 position = right.position;
00049 bBox = right.bBox;
00050 start = right.start;
00051 end = right.end;
00052 pStart = right.pStart;
00053 pEnd = right.pEnd;
00054 pRange = right.pRange;
00055 bounded = right.bounded;
00056 sameSense = right.sameSense;
00057 }
00058
00059 G4CircularCurve&
00060 G4CircularCurve::operator=(const G4CircularCurve& right)
00061 {
00062 if (&right == this) return *this;
00063
00064 radius = right.radius;
00065 pShift = right.pShift;
00066 position = right.position;
00067 bBox = right.bBox;
00068 start = right.start;
00069 end = right.end;
00070 pStart = right.pStart;
00071 pEnd = right.pEnd;
00072 pRange = right.pRange;
00073 bounded = right.bounded;
00074 sameSense = right.sameSense;
00075
00076 return *this;
00077 }
00078
00080
00081 void G4CircularCurve::InitBounded()
00082 {
00083
00084
00085 bBox.Init(GetStart(), GetEnd());
00086
00087
00088
00089 for (G4int i=0; i<3; i++)
00090 {
00091 G4double u = std::atan2(position.GetPY()(i), position.GetPX()(i));
00092
00093 if (IsPOn(u))
00094 bBox.Extend(GetPoint(u));
00095
00096 if (IsPOn(u+pi))
00097 bBox.Extend(GetPoint(u+pi));
00098 }
00099 }
00100
00102
00103 G4Curve* G4CircularCurve::Project(const G4Transform3D& tr)
00104 {
00105 G4Ellipse e;
00106 e.Init(position, radius, radius);
00107 e.SetBounds(GetPStart(), GetPEnd());
00108
00109 return e.Project(tr);
00110 }
00111
00113
00114 G4bool G4CircularCurve::Tangent(G4CurvePoint& cp, G4Vector3D& v)
00115 {
00116
00117
00118
00119
00120
00121 const G4Axis2Placement3D& pos= *(GetPosition());
00122 G4Point3D p= pos.GetToPlacementCoordinates() * cp.GetPoint();
00123
00124 v= -p.y()*pos.GetPX() + p.x()*pos.GetPY();
00125 return true;
00126 }
00127
00128 G4double G4CircularCurve::GetPMax() const
00129 {
00130 return twopi;
00131 }
00132
00133 G4Point3D G4CircularCurve::GetPoint(G4double param) const
00134 {
00135 return G4Point3D( position.GetLocation()+radius*
00136 ( std::cos(param)*position.GetPX() + std::sin(param)*position.GetPY() ) );
00137 }
00138
00139 G4double G4CircularCurve::GetPPoint(const G4Point3D& pt) const
00140 {
00141 G4Point3D ptLocal= position.GetToPlacementCoordinates()*pt;
00142 G4double angle= std::atan2(ptLocal.y(), ptLocal.x());
00143 return (angle<0)? angle+twopi: angle;
00144 }
00145
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160 G4int G4CircularCurve::IntersectRay2D(const G4Ray&)
00161 {
00162 G4Exception("G4CircularCurve::IntersectRay2D()", "GeomSolids0002",
00163 FatalException,"G4CircularCurve is always 3D!");
00164 return 0;
00165 }