Jpp
Public Member Functions | Protected Attributes | List of all members
JGEOMETRY3D::JVersor3D Class Reference

Data structure for normalised vector in three dimensions. More...

#include <JVersor3D.hh>

Inheritance diagram for JGEOMETRY3D::JVersor3D:
JMATH::JMath< JVersor3D > JGEOMETRY3D::JDirection3D JGEOMETRY3D::JAxis3D JDETECTOR::JPMT JGEOMETRY3D::JTrack3D JTRIGGER::JHitL0 JTRIGGER::JPMTHeader JFIT::JPMTW0 JGEOMETRY3D::JTrack3E JFIT::JHitW0 JTRIGGER::JFrame< JElement_t, JAllocator_t > JTRIGGER::JFrameClone< JElement_t, JAllocator_t >

Public Member Functions

 JVersor3D ()
 Default constructor. More...
 
 JVersor3D (const double dx, const double dy, const double dz)
 Constructor. More...
 
JVersor3Dnegate ()
 Negate versor. More...
 
bool equals (const JVersor3D &versor, const double precision=std::numeric_limits< double >::min()) const
 Check equality. More...
 
double getDX () const
 Get x direction. More...
 
double getDY () const
 Get y direction. More...
 
double getDZ () const
 Get z direction. More...
 
double getTheta () const
 Get theta angle. More...
 
double getPhi () const
 Get phi angle. More...
 
double getDot (const JVersor3D &versor) const
 Get dot product. More...
 
JVersor3Dnormalise ()
 Normalise versor. More...
 
JVersor3Dmul (const JSecond_t &object)
 Multiply with object. More...
 

Protected Attributes

double __dx
 
double __dy
 
double __dz
 

Detailed Description

Data structure for normalised vector in three dimensions.

Definition at line 23 of file JVersor3D.hh.

Constructor & Destructor Documentation

◆ JVersor3D() [1/2]

JGEOMETRY3D::JVersor3D::JVersor3D ( )
inline

Default constructor.

This constructor yields a unit z-vector.

Definition at line 31 of file JVersor3D.hh.

31  :
32  __dx(0.0),
33  __dy(0.0),
34  __dz(1.0)
35  {}

◆ JVersor3D() [2/2]

JGEOMETRY3D::JVersor3D::JVersor3D ( const double  dx,
const double  dy,
const double  dz 
)
inline

Constructor.

Parameters
dxdx value
dydy value
dzdz value

Definition at line 45 of file JVersor3D.hh.

47  :
48  __dx(dx),
49  __dy(dy),
50  __dz(dz)
51  {
52  normalise();
53  }

Member Function Documentation

◆ negate()

JVersor3D& JGEOMETRY3D::JVersor3D::negate ( )
inline

Negate versor.

Returns
this versor

Definition at line 61 of file JVersor3D.hh.

62  {
63  __dx = -__dx;
64  __dy = -__dy;
65  __dz = -__dz;
66 
67  return *this;
68  }

◆ equals()

bool JGEOMETRY3D::JVersor3D::equals ( const JVersor3D versor,
const double  precision = std::numeric_limits<double>::min() 
) const
inline

Check equality.

Parameters
versorversor
Returns
true if versors are equal; else false

Definition at line 77 of file JVersor3D.hh.

79  {
80  return (fabs(getDX() - versor.getDX()) <= precision &&
81  fabs(getDY() - versor.getDY()) <= precision &&
82  fabs(getDZ() - versor.getDZ()) <= precision);
83  }

◆ getDX()

double JGEOMETRY3D::JVersor3D::getDX ( ) const
inline

Get x direction.

Returns
x direction

Definition at line 91 of file JVersor3D.hh.

92  {
93  return __dx;
94  }

◆ getDY()

double JGEOMETRY3D::JVersor3D::getDY ( ) const
inline

Get y direction.

Returns
y direction

Definition at line 102 of file JVersor3D.hh.

103  {
104  return __dy;
105  }

◆ getDZ()

double JGEOMETRY3D::JVersor3D::getDZ ( ) const
inline

Get z direction.

Returns
z direction

Definition at line 113 of file JVersor3D.hh.

114  {
115  return __dz;
116  }

◆ getTheta()

double JGEOMETRY3D::JVersor3D::getTheta ( ) const
inline

Get theta angle.

Returns
theta angle [rad]

Definition at line 124 of file JVersor3D.hh.

125  {
126  if (__dz > +1.0)
127  return 0.0;
128  else if (__dz < -1.0)
129  return JTOOLS::PI;
130  else
131  return acos(__dz);
132  }

◆ getPhi()

double JGEOMETRY3D::JVersor3D::getPhi ( ) const
inline

Get phi angle.

Returns
phi angle [rad]

Definition at line 140 of file JVersor3D.hh.

141  {
142  return atan2(__dy, __dx);
143  }

◆ getDot()

double JGEOMETRY3D::JVersor3D::getDot ( const JVersor3D versor) const
inline

Get dot product.

Parameters
versorversor
Returns
dot product

Definition at line 152 of file JVersor3D.hh.

153  {
154  return
155  getDX() * versor.getDX() +
156  getDY() * versor.getDY() +
157  getDZ() * versor.getDZ();
158  }

◆ normalise()

JVersor3D& JGEOMETRY3D::JVersor3D::normalise ( )
inline

Normalise versor.

This operation may set the result to the unit z-vector.

Returns
this versor

Definition at line 167 of file JVersor3D.hh.

168  {
169  const double v = sqrt(getDX()*getDX() + getDY()*getDY() + getDZ()*getDZ());
170 
171  if (v != 0.0) {
172  __dx /= v;
173  __dy /= v;
174  __dz /= v;
175  }
176 
177  return *this;
178  }

◆ mul()

JVersor3D & JMATH::JMath< JVersor3D , JSecond_t >::mul ( const JSecond_t &  object)
inlineinherited

Multiply with object.

Parameters
objectobject
Returns
result object

Definition at line 273 of file JMath.hh.

274  {
275  return static_cast<JFirst_t&>(*this) = JCalculator<JFirst_t>::calculator.mul(static_cast<const JFirst_t&>(*this), object);
276  }

Member Data Documentation

◆ __dx

double JGEOMETRY3D::JVersor3D::__dx
protected

Definition at line 181 of file JVersor3D.hh.

◆ __dy

double JGEOMETRY3D::JVersor3D::__dy
protected

Definition at line 182 of file JVersor3D.hh.

◆ __dz

double JGEOMETRY3D::JVersor3D::__dz
protected

Definition at line 183 of file JVersor3D.hh.


The documentation for this class was generated from the following file:
JGEOMETRY3D::JVersor3D::getDZ
double getDZ() const
Get z direction.
Definition: JVersor3D.hh:113
JGEOMETRY3D::JVersor3D::__dz
double __dz
Definition: JVersor3D.hh:183
JGEOMETRY3D::JVersor3D::__dx
double __dx
Definition: JVersor3D.hh:181
JGEOMETRY3D::JVersor3D::getDX
double getDX() const
Get x direction.
Definition: JVersor3D.hh:91
JGEOMETRY3D::JVersor3D::getDY
double getDY() const
Get y direction.
Definition: JVersor3D.hh:102
JGEOMETRY3D::JVersor3D::__dy
double __dy
Definition: JVersor3D.hh:182
JTOOLS::v
data_type v[N+1][M+1]
Definition: JPolint.hh:707
JGEOMETRY3D::JVersor3D::normalise
JVersor3D & normalise()
Normalise versor.
Definition: JVersor3D.hh:167
JTOOLS::PI
static const double PI
Constants.
Definition: JConstants.hh:20
JMATH::JCalculator
Auxiliary class for arithmetic operations on objects.
Definition: JCalculator.hh:18