89 const double precision = std::numeric_limits<double>::epsilon()) :
94 if (__begin != __end) {
96 zmin = std::numeric_limits<double>::max();
97 zmax = std::numeric_limits<double>::lowest();
99 for (T i = __begin; i != __end; ++i) {
100 if (i->getZ() <
zmin)
zmin = i->getZ();
101 if (i->getZ() >
zmax)
zmax = i->getZ();
237 if (pos.
getZ() > this->getZmax())
239 else if (pos.
getZ() < this->getZmin())
244 return sqrt(R*R + dz*dz);
248 if (pos.
getZ() > this->getZmax())
250 else if (pos.
getZ() < this->getZmin())
280 double path[] = { 0.0, 0.0 };
282 if (fabs(axis.
getDZ()) != 0.0) {
291 for (
int i = 0; i != 2; ++i) {
293 const double u = (Z[i] - axis.
getZ()) / axis.
getDZ();
294 const double x = axis.
getX() + u * axis.
getDX() - this->
getX();
295 const double y = axis.
getY() + u * axis.
getDY() - this->
getY();
303 if (fabs(axis.
getDZ()) != 1.0) {
307 const double x = axis.
getX() - this->
getX();
308 const double y = axis.
getY() - this->
getY();
309 const double dx = axis.
getDX();
310 const double dy = axis.
getDY();
313 const double a = (dx * dx + dy * dy);
314 const double b = 2*(dx * x + dy * y);
315 const double c = (x * x + y * y) - R * R;
317 const double q = b*b - 4*a*c;
322 (-b - sqrt(q)) / (2*a),
323 (-b + sqrt(q)) / (2*a)
326 for (
int i = 0; i != 2; ++i) {
328 const double z = axis.
getZ() + u[i] * axis.
getDZ();
337 return std::minmax(path[0], path[1]);
351 in >> cylinder.
zmin >> cylinder.
zmax;
368 out << static_cast<const JCircle2D&>(cylinder);
370 out << format << cylinder.
zmin;
372 out << format << cylinder.
zmax;
388 in >> cylinder.
zmin >> cylinder.
zmax;
403 out << static_cast<const JCircle2D&>(cylinder);
404 out << cylinder.
zmin << cylinder.
zmax;
JFormat_t & getFormat()
Get format for given type.
Data structure for circle in two dimensions.
bool is_inside(const JVector2D &pos, const double precision=std::numeric_limits< double >::min()) const
Check whether given point is inside circle.
double getRadius() const
Get radius.
const JPosition2D & getPosition() const
Get position.
JPosition2D()
Default constructor.
Data structure for vector in two dimensions.
double getY() const
Get y position.
double getX() const
Get x position.
JVector2D()
Default constructor.
JVector2D & sub(const JVector2D &vector)
Subtract vector.
double getLength() const
Get length.
JCylinder3D(const JCircle2D &circle, const double zmin, const double zmax)
Constructor.
JCylinder3D(T __begin, T __end, const double precision=std::numeric_limits< double >::epsilon())
Constructor.
double getDistanceSquared(const JVector3D &pos) const
Get square of distance between cylinder wall and given position.
std::pair< double, double > intersection_type
Type definition of intersection.
friend std::istream & operator>>(std::istream &in, JCylinder3D &cylinder)
Read cylinder from input stream.
double getZmin() const
Get minimal z position.
double getVolume() const
Get volume.
bool is_inside(const JVector3D &pos) const
Check whether given point is inside cylinder.
friend std::ostream & operator<<(std::ostream &out, const JCylinder3D &cylinder)
Write cylinder to output stream.
intersection_type getIntersection(const JAxis3D &axis) const
Get intersection points of axis with cylinder.
friend JReader & operator>>(JReader &in, JCylinder3D &cylinder)
Read cylinder from input.
void setZmax(const double zmax)
Set maximal z position.
void setZmin(const double zmin)
Set minimal z position.
void addMargin(const double D)
Add (safety) margin.
friend JWriter & operator<<(JWriter &out, const JCylinder3D &cylinder)
Write cylinder to output.
JCylinder3D()
Default constructor.
double getDistance(const JVector3D &pos) const
Get distance between cylinder wall and given position.
JPosition3D getCenter() const
Get centre.
double getZmax() const
Get maximal z position.
JCylinder3D & add(const JVector3D &pos)
Add position.
Data structure for position in three dimensions.
Data structure for vector in three dimensions.
double getY() const
Get y position.
double getZ() const
Get z position.
double getX() const
Get x position.
double getDY() const
Get y direction.
double getDX() const
Get x direction.
double getDZ() const
Get z direction.
Interface for binary input.
Interface for binary output.
Auxiliary classes and methods for 3D geometrical objects and operations.
static const double PI
Mathematical constants.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).