88 const double precision = std::numeric_limits<double>::epsilon()) :
93 if (__begin != __end) {
95 zmin = std::numeric_limits<double>::max();
96 zmax = std::numeric_limits<double>::lowest();
98 for (T i = __begin; i != __end; ++i) {
99 if (i->getZ() <
zmin)
zmin = i->getZ();
100 if (i->getZ() >
zmax)
zmax = i->getZ();
236 if (pos.
getZ() > this->getZmax())
238 else if (pos.
getZ() < this->getZmin())
243 return sqrt(R*R + dz*dz);
247 if (pos.
getZ() > this->getZmax())
249 else if (pos.
getZ() < this->getZmin())
279 double path[] = { 0.0, 0.0 };
281 if (fabs(axis.
getDZ()) != 0.0) {
290 for (
int i = 0; i != 2; ++i) {
292 const double u = (Z[i] - axis.
getZ()) / axis.
getDZ();
293 const double x = axis.
getX() + u * axis.
getDX() - this->
getX();
294 const double y = axis.
getY() + u * axis.
getDY() - this->
getY();
302 if (fabs(axis.
getDZ()) != 1.0) {
306 const double x = axis.
getX() - this->
getX();
307 const double y = axis.
getY() - this->
getY();
308 const double dx = axis.
getDX();
309 const double dy = axis.
getDY();
312 const double a = (dx * dx + dy * dy);
313 const double b = 2*(dx * x + dy * y);
314 const double c = (x * x + y * y) - R * R;
316 const double q = b*b - 4*a*c;
321 (-b - sqrt(q)) / (2*a),
322 (-b + sqrt(q)) / (2*a)
325 for (
int i = 0; i != 2; ++i) {
327 const double z = axis.
getZ() + u[i] * axis.
getDZ();
336 return std::minmax(path[0], path[1]);
350 in >> cylinder.
zmin >> cylinder.
zmax;
367 out << static_cast<const JCircle2D&>(cylinder);
369 out << format << cylinder.
zmin;
371 out << format << cylinder.
zmax;
387 in >> cylinder.
zmin >> cylinder.
zmax;
402 out << static_cast<const JCircle2D&>(cylinder);
403 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).