LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
GeoCone.cxx
Go to the documentation of this file.
2 #include "larcorealg/GeoAlgo/GeoAlgoException.h" // for GeoAlgoException
3 
4 #include <math.h>
5 #include <sstream>
6 
7 namespace geoalgo {
8 
10  {
11  _length = 1;
12  _radius = 1;
13  _angle = atan(_radius / _length);
14  }
15 
16  Cone::Cone(const double x,
17  const double y,
18  const double z,
19  const double dirx,
20  const double diry,
21  const double dirz,
22  const double length,
23  const double radius)
24  : HalfLine(x, y, z, dirx, diry, dirz)
25  {
26  if (length == 0) {
27  std::ostringstream msg;
28  msg << "<<" << __FUNCTION__ << ">>"
29  << " Cone Length cannot be 0." << std::endl;
30  throw GeoAlgoException(msg.str());
31  }
32  _length = length;
33  _radius = radius;
34  _angle = atan(_radius / _length);
35  }
36 
37  Cone::Cone(const Point_t& start, const Vector_t& dir, const double length, const double radius)
38  : HalfLine(start, dir)
39  {
40  if (length == 0) {
41  std::ostringstream msg;
42  msg << "<<" << __FUNCTION__ << ">>"
43  << " Cone Length cannot be 0." << std::endl;
44  throw GeoAlgoException(msg.str());
45  }
46  _length = length;
47  _radius = radius;
48  _angle = atan(_radius / _length);
49  }
50 
51  double Cone::Length() const
52  {
53  return _length;
54  }
55 
56  double Cone::Radius() const
57  {
58  return _radius;
59  }
60 
61  double Cone::Angle() const
62  {
63  return _angle;
64  }
65 
66  void Cone::Length(const double l)
67  {
68  if (l == 0) {
69  std::ostringstream msg;
70  msg << "<<" << __FUNCTION__ << ">>"
71  << " Cone Length cannot be 0." << std::endl;
72  throw GeoAlgoException(msg.str());
73  }
74  _length = l;
75  _angle = atan(_radius / _length);
76  }
77 
78  void Cone::Radius(const double r)
79  {
80  _radius = r;
81  _angle = atan(_radius / _length);
82  }
83 }
Float_t x
Definition: compare.C:6
TRandom r
Definition: spectrum.C:23
double _radius
Radius of the cone at the base.
Definition: GeoCone.h:64
double _angle
Opening Angle.
Definition: GeoCone.h:65
double _length
Helight (length) of the cone.
Definition: GeoCone.h:63
Float_t y
Definition: compare.C:6
Class def header for a class GeoAlgoException.
Double_t z
Definition: plot.C:276
double Length() const
Length getter.
Definition: GeoCone.cxx:51
Class def header for a class HalfLine.
Cone()
Default constructor.
Definition: GeoCone.cxx:9
Float_t radius
Definition: plot.C:23
Representation of a 3D semi-infinite line. Defines a semi-infinite 3D line by having a start point (P...
Definition: GeoHalfLine.h:30
TDirectory * dir
Definition: macro.C:5
double Angle() const
Angle getter.
Definition: GeoCone.cxx:61
double Radius() const
Length getter.
Definition: GeoCone.cxx:56