Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JGEOMETRY3D::JVersor3D Class Reference

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

#include <JVersor3D.hh>

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

Public Member Functions

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

Protected Attributes

double __dx
 
double __dy
 
double __dz
 

Detailed Description

Data structure for normalised vector in three dimensions.

Definition at line 26 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 34 of file JVersor3D.hh.

34 :
35 __dx(0.0),
36 __dy(0.0),
37 __dz(1.0)
38 {}

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

50 :
51 __dx(dx),
52 __dy(dy),
53 __dz(dz)
54 {
55 normalise();
56 }
JVersor3D & normalise()
Normalise versor.
Definition JVersor3D.hh:192

Member Function Documentation

◆ negate()

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

Negate versor.

Returns
this versor

Definition at line 64 of file JVersor3D.hh.

65 {
66 __dx = -__dx;
67 __dy = -__dy;
68 __dz = -__dz;
69
70 return *this;
71 }

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

83 {
84 return (fabs(getDX() - versor.getDX()) <= precision &&
85 fabs(getDY() - versor.getDY()) <= precision &&
86 fabs(getDZ() - versor.getDZ()) <= precision);
87 }
double getDY() const
Get y direction.
Definition JVersor3D.hh:106
double getDX() const
Get x direction.
Definition JVersor3D.hh:95
double getDZ() const
Get z direction.
Definition JVersor3D.hh:117

◆ getDX()

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

Get x direction.

Returns
x direction

Definition at line 95 of file JVersor3D.hh.

96 {
97 return __dx;
98 }

◆ getDY()

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

Get y direction.

Returns
y direction

Definition at line 106 of file JVersor3D.hh.

107 {
108 return __dy;
109 }

◆ getDZ()

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

Get z direction.

Returns
z direction

Definition at line 117 of file JVersor3D.hh.

118 {
119 return __dz;
120 }

◆ getTheta()

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

Get theta angle.

Returns
theta angle [rad]

Definition at line 128 of file JVersor3D.hh.

129 {
130 if (__dz > +1.0)
131 return 0.0;
132 else if (__dz < -1.0)
133 return JMATH::PI;
134 else
135 return acos(__dz);
136 }
static const double PI
Mathematical constants.

◆ getPhi()

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

Get phi angle.

Returns
phi angle [rad]

Definition at line 144 of file JVersor3D.hh.

145 {
146 return atan2(__dy, __dx);
147 }

◆ getDot()

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

Get dot product.

Parameters
versorversor
Returns
dot product

Definition at line 156 of file JVersor3D.hh.

157 {
158 return
159 getDX() * versor.getDX() +
160 getDY() * versor.getDY() +
161 getDZ() * versor.getDZ();
162 }

◆ getCross()

JVersor3D & JGEOMETRY3D::JVersor3D::getCross ( const JVersor3D & first,
const JVersor3D & second )
inline

Get cross product.

Note that this versor should not overlap with the first or second versor,

Parameters
firstfirst versor
secondsecond versor
Returns
this versor

Definition at line 173 of file JVersor3D.hh.

175 {
176 __dx = first .getDY() * second.getDZ() - second.getDY() * first .getDZ();
177 __dy = second.getDX() * first .getDZ() - first .getDX() * second.getDZ();
178 __dz = first .getDX() * second.getDY() - second.getDX() * first .getDY();
179
180 normalise();
181
182 return *this;
183 }

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

193 {
194 const double v = sqrt(getDX()*getDX() + getDY()*getDY() + getDZ()*getDZ());
195
196 if (v != 0.0) {
197 __dx /= v;
198 __dy /= v;
199 __dz /= v;
200 }
201
202 return *this;
203 }

◆ mul()

template<class JFirst_t , class JSecond_t >
JFirst_t & JMATH::JMath< JFirst_t, JSecond_t >::mul ( const JSecond_t & object)
inlineinherited

Multiply with object.

Parameters
objectobject
Returns
result object

Definition at line 354 of file JMath.hh.

355 {
356 return static_cast<JFirst_t&>(*this) = JFirst_t().mul(static_cast<const JFirst_t&>(*this), object);
357 }

Member Data Documentation

◆ __dx

double JGEOMETRY3D::JVersor3D::__dx
protected

Definition at line 206 of file JVersor3D.hh.

◆ __dy

double JGEOMETRY3D::JVersor3D::__dy
protected

Definition at line 207 of file JVersor3D.hh.

◆ __dz

double JGEOMETRY3D::JVersor3D::__dz
protected

Definition at line 208 of file JVersor3D.hh.


The documentation for this class was generated from the following file: