1 #ifndef __JCYLINDER3D__
2 #define __JCYLINDER3D__
22 namespace JGEOMETRY3D {}
23 namespace JPP {
using namespace JGEOMETRY3D; }
25 namespace JGEOMETRY3D {
82 const double precision = std::numeric_limits<double>::epsilon()) :
87 if (__begin != __end) {
89 zmin = std::numeric_limits<double>::max();
90 zmax = std::numeric_limits<double>::lowest();
92 for (
T i = __begin; i != __end; ++i) {
93 if (i->getZ() <
zmin)
zmin = i->getZ();
94 if (i->getZ() >
zmax)
zmax = i->getZ();
238 return sqrt(R*R + dz*dz);
274 double path[] = { 0.0, 0.0 };
276 if (fabs(axis.
getDZ()) != 0.0) {
285 for (
int i = 0; i != 2; ++i) {
287 const double u = (Z[i] - axis.
getZ()) / axis.
getDZ();
288 const double x = axis.
getX() + u * axis.
getDX() - this->
getX();
289 const double y = axis.
getY() + u * axis.
getDY() - this->
getY();
297 if (fabs(axis.
getDZ()) != 1.0) {
301 const double x = axis.
getX() - this->
getX();
302 const double y = axis.
getY() - this->
getY();
303 const double dx = axis.
getDX();
304 const double dy = axis.
getDY();
307 const double a = (dx * dx + dy * dy);
308 const double b = 2*(dx * x + dy * y);
309 const double c = (x * x + y * y) - R * R;
311 const double q = b*b - 4*a*c;
316 (-b - sqrt(q)) / (2*a),
317 (-b + sqrt(q)) / (2*a)
320 for (
int i = 0; i != 2; ++i) {
322 const double z = axis.
getZ() + u[i] * axis.
getDZ();
331 return std::make_pair(path[0], path[1]);
345 in >> cylinder.
zmin >> cylinder.
zmax;
360 const JFormat format(out, getFormat<JCylinder3D>(
JFormat_t(9, 3, std::ios::fixed | std::ios::showpos)));
362 out << static_cast<const JCircle2D&>(cylinder);
364 out << format << cylinder.
zmin;
366 out << format << cylinder.
zmax;
382 in >> cylinder.
zmin >> cylinder.
zmax;
397 out << static_cast<const JCircle2D&>(cylinder);
398 out << cylinder.
zmin << cylinder.
zmax;
const JPosition2D & getPosition() const
Get position.
Data structure for vector in two dimensions.
JCylinder3D(T __begin, T __end, const double precision=std::numeric_limits< double >::epsilon())
Constructor.
Interface for binary output.
do echo Generating $dir eval D
double getRadius() const
Get radius.
JVector2D()
Default constructor.
JPosition2D()
Default constructor.
Data structure for circle in two dimensions.
void setZmin(const double zmin)
Set minimal z position.
friend JWriter & operator<<(JWriter &out, const JCylinder3D &cylinder)
Write cylinder to output.
double getZmin() const
Get minimal z position.
double getDistanceSquared(const JVector3D &pos) const
Get square of distance between cylinder wall and given position.
JCylinder3D & add(const JVector3D &pos)
Add position.
friend JReader & operator>>(JReader &in, JCylinder3D &cylinder)
Read cylinder from input.
double getY() const
Get y position.
friend std::istream & operator>>(std::istream &in, JCylinder3D &cylinder)
Read cylinder from input stream.
JVector2D & sub(const JVector2D &vector)
Subtract vector.
do cat driver txt<< EOFevent ev_configure{RC_EVT%< ev_configure.txt > RC_DWRT path
bool is_inside(const JVector2D &pos, const double precision=std::numeric_limits< double >::min()) const
Check whether given point is inside circle.
JPosition3D getCenter() const
Get centre.
friend std::ostream & operator<<(std::ostream &out, const JCylinder3D &cylinder)
Write cylinder to output stream.
Data structure for vector in three dimensions.
double getDY() const
Get y direction.
double getDX() const
Get x direction.
double getX() const
Get x position.
do set_variable OUTPUT_DIRECTORY $WORKDIR T
static const double PI
Mathematical constants.
void addMargin(const double D)
Add (safety) margin.
double getY() const
Get y position.
Interface for binary input.
then usage $script[distance] fi case set_variable R
double getVolume() const
Get volume.
double getZmax() const
Get maximal z position.
then JMuonMCEvt f $INPUT_FILE o $INTERMEDIATE_FILE d
JCylinder3D()
Default constructor.
double getX() const
Get x position.
bool is_inside(const JVector3D &pos) const
Check whether given point is inside cylinder.
void setZmax(const double zmax)
Set maximal z position.
Data structure for position in three dimensions.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
std::pair< double, double > getIntersection(const JAxis3D &axis) const
Get intersection points of axis with cylinder.
JCylinder3D(const JCircle2D &circle, const double zmin, const double zmax)
Constructor.
double getDistance(const JVector3D &pos) const
Get distance between cylinder wall and given position.
double getLength() const
Get length.
double getZ() const
Get z position.
double getDZ() const
Get z direction.