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
precisionprecision
Returns
true if versors are equal; else false

Definition at line 78 of file JVersor3D.hh.

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

◆ getDX()

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

Get x direction.

Returns
x direction

Definition at line 92 of file JVersor3D.hh.

93  {
94  return __dx;
95  }

◆ getDY()

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

Get y direction.

Returns
y direction

Definition at line 103 of file JVersor3D.hh.

104  {
105  return __dy;
106  }

◆ getDZ()

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

Get z direction.

Returns
z direction

Definition at line 114 of file JVersor3D.hh.

115  {
116  return __dz;
117  }

◆ getTheta()

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

Get theta angle.

Returns
theta angle [rad]

Definition at line 125 of file JVersor3D.hh.

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

◆ getPhi()

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

Get phi angle.

Returns
phi angle [rad]

Definition at line 141 of file JVersor3D.hh.

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

◆ getDot()

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

Get dot product.

Parameters
versorversor
Returns
dot product

Definition at line 153 of file JVersor3D.hh.

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

◆ 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 168 of file JVersor3D.hh.

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

◆ 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 182 of file JVersor3D.hh.

◆ __dy

double JGEOMETRY3D::JVersor3D::__dy
protected

Definition at line 183 of file JVersor3D.hh.

◆ __dz

double JGEOMETRY3D::JVersor3D::__dz
protected

Definition at line 184 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:114
JGEOMETRY3D::JVersor3D::__dz
double __dz
Definition: JVersor3D.hh:184
JGEOMETRY3D::JVersor3D::__dx
double __dx
Definition: JVersor3D.hh:182
JGEOMETRY3D::JVersor3D::getDX
double getDX() const
Get x direction.
Definition: JVersor3D.hh:92
JGEOMETRY3D::JVersor3D::getDY
double getDY() const
Get y direction.
Definition: JVersor3D.hh:103
JGEOMETRY3D::JVersor3D::__dy
double __dy
Definition: JVersor3D.hh:183
JTOOLS::v
data_type v[N+1][M+1]
Definition: JPolint.hh:707
JGEOMETRY3D::JVersor3D::normalise
JVersor3D & normalise()
Normalise versor.
Definition: JVersor3D.hh:168
JTOOLS::PI
static const double PI
Constants.
Definition: JConstants.hh:20
JMATH::JCalculator
Auxiliary class for arithmetic operations on objects.
Definition: JCalculator.hh:18