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

Data structure for direction in three dimensions. More...

#include <JDirection3D.hh>

Inheritance diagram for JGEOMETRY3D::JDirection3D:
JGEOMETRY3D::JVersor3D JMATH::JMath< JFirst_t, JSecond_t > 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

 JDirection3D ()
 Default constructor.
 
 JDirection3D (const JVersor3D &dir)
 Constructor.
 
 JDirection3D (const JAngle3D &angle)
 Constructor.
 
 JDirection3D (const JVector3D &pos)
 Constructor.
 
 JDirection3D (const JVersor3Z &dir)
 Constructor.
 
 JDirection3D (const double dx, const double dy, const double dz)
 Constructor.
 
const JDirection3DgetDirection () const
 Get direction.
 
JDirection3DgetDirection ()
 Get direction.
 
void setDirection (const JDirection3D &dir)
 Set direction.
 
 operator JAngle3D () const
 Type conversion operator.
 
 operator JVector3D () const
 Type conversion operator.
 
JDirection3Dtransform (const JMatrix3D &T)
 Transform.
 
JDirection3Drotate (const JRotation3D &R)
 Rotate.
 
JDirection3Drotate_back (const JRotation3D &R)
 Rotate back.
 
JDirection3Drotate (const JRotation3X &R)
 Rotate around X-axis.
 
JDirection3Drotate_back (const JRotation3X &R)
 Rotate back around X-axis.
 
JDirection3Drotate (const JRotation3Y &R)
 Rotate around Y-axis.
 
JDirection3Drotate_back (const JRotation3Y &R)
 Rotate back around Y-axis.
 
JDirection3Drotate (const JRotation3Z &R)
 Rotate around Z-axis.
 
JDirection3Drotate_back (const JRotation3Z &R)
 Rotate back around Z-axis.
 
JDirection3Drotate (const JQuaternion3D &Q)
 Rotate.
 
JDirection3Drotate_back (const JQuaternion3D &Q)
 Rotate back.
 
double getDot (const JAngle3D &angle) const
 Get dot product.
 
double getDot (const JVector3D &pos) const
 Get dot product.
 
double getDot (const JVersor3Z &dir) const
 Get dot product.
 
double getDot (const JVersor3D &versor) const
 Get dot product.
 
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.
 
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
 

Friends

std::istream & operator>> (std::istream &in, JDirection3D &direction)
 Read direction from input.
 
std::ostream & operator<< (std::ostream &out, const JDirection3D &direction)
 Write direction to output.
 
JReaderoperator>> (JReader &in, JDirection3D &direction)
 Read direction from input.
 
JWriteroperator<< (JWriter &out, const JDirection3D &direction)
 Write direction to output.
 

Detailed Description

Data structure for direction in three dimensions.

Definition at line 33 of file JDirection3D.hh.

Constructor & Destructor Documentation

◆ JDirection3D() [1/6]

JGEOMETRY3D::JDirection3D::JDirection3D ( )
inline

Default constructor.

Definition at line 43 of file JDirection3D.hh.

43 :
44 JVersor3D()
45 {}
JVersor3D()
Default constructor.
Definition JVersor3D.hh:34

◆ JDirection3D() [2/6]

JGEOMETRY3D::JDirection3D::JDirection3D ( const JVersor3D & dir)
inline

Constructor.

Parameters
dirdirection

Definition at line 53 of file JDirection3D.hh.

53 :
54 JVersor3D(dir)
55 {}

◆ JDirection3D() [3/6]

JGEOMETRY3D::JDirection3D::JDirection3D ( const JAngle3D & angle)
inline

Constructor.

Parameters
angleangle

Definition at line 63 of file JDirection3D.hh.

63 :
64 JVersor3D(angle.getDX(), angle.getDY(), angle.getDZ())
65 {}

◆ JDirection3D() [4/6]

JGEOMETRY3D::JDirection3D::JDirection3D ( const JVector3D & pos)
inline

Constructor.

Parameters
posposition

Definition at line 73 of file JDirection3D.hh.

73 :
74 JVersor3D(pos.getX(), pos.getY(), pos.getZ())
75 {}

◆ JDirection3D() [5/6]

JGEOMETRY3D::JDirection3D::JDirection3D ( const JVersor3Z & dir)
inline

Constructor.

Parameters
dirdirection

Definition at line 83 of file JDirection3D.hh.

83 :
84 JVersor3D(dir.getDX(), dir.getDY(), dir.getDZ())
85 {}

◆ JDirection3D() [6/6]

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

Constructor.

Parameters
dxdx value
dydy value
dzdz value

Definition at line 95 of file JDirection3D.hh.

97 :
98 JVersor3D(dx, dy, dz)
99 {}

Member Function Documentation

◆ getDirection() [1/2]

const JDirection3D & JGEOMETRY3D::JDirection3D::getDirection ( ) const
inline

Get direction.

Returns
direction

Definition at line 107 of file JDirection3D.hh.

108 {
109 return static_cast<const JDirection3D&>(*this);
110 }
JDirection3D()
Default constructor.

◆ getDirection() [2/2]

JDirection3D & JGEOMETRY3D::JDirection3D::getDirection ( )
inline

Get direction.

Returns
direction

Definition at line 118 of file JDirection3D.hh.

119 {
120 return static_cast<JDirection3D&>(*this);
121 }

◆ setDirection()

void JGEOMETRY3D::JDirection3D::setDirection ( const JDirection3D & dir)
inline

Set direction.

Parameters
dirdirection

Definition at line 129 of file JDirection3D.hh.

130 {
131 static_cast<JDirection3D&>(*this) = dir;
132 }

◆ operator JAngle3D()

JGEOMETRY3D::JDirection3D::operator JAngle3D ( ) const
inline

Type conversion operator.

Returns
angle

Definition at line 140 of file JDirection3D.hh.

141 {
142 return JAngle3D(getDX(), getDY(), getDZ());
143 }
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

◆ operator JVector3D()

JGEOMETRY3D::JDirection3D::operator JVector3D ( ) const
inline

Type conversion operator.

Returns
position

Definition at line 151 of file JDirection3D.hh.

152 {
153 return JVector3D(getDX(), getDY(), getDZ());
154 }

◆ transform()

JDirection3D & JGEOMETRY3D::JDirection3D::transform ( const JMatrix3D & T)
inline

Transform.

Parameters
Tmatrix
Returns
this direction

Definition at line 163 of file JDirection3D.hh.

164 {
165 T.transform(__dx, __dy, __dz);
166
167 normalise();
168
169 return *this;
170 }
JVersor3D & normalise()
Normalise versor.
Definition JVersor3D.hh:192

◆ rotate() [1/5]

JDirection3D & JGEOMETRY3D::JDirection3D::rotate ( const JRotation3D & R)
inline

Rotate.

Parameters
Rrotation matrix
Returns
this direction

Definition at line 179 of file JDirection3D.hh.

180 {
181 R.rotate(__dx, __dy, __dz);
182
183 normalise();
184
185 return *this;
186 }

◆ rotate_back() [1/5]

JDirection3D & JGEOMETRY3D::JDirection3D::rotate_back ( const JRotation3D & R)
inline

Rotate back.

Parameters
Rrotation matrix
Returns
this direction

Definition at line 195 of file JDirection3D.hh.

196 {
197 R.rotate_back(__dx, __dy, __dz);
198
199 normalise();
200
201 return *this;
202 }

◆ rotate() [2/5]

JDirection3D & JGEOMETRY3D::JDirection3D::rotate ( const JRotation3X & R)
inline

Rotate around X-axis.

Parameters
Rrotation matrix
Returns
this direction

Definition at line 211 of file JDirection3D.hh.

212 {
213 R.rotate(__dy, __dz);
214
215 normalise();
216
217 return *this;
218 }

◆ rotate_back() [2/5]

JDirection3D & JGEOMETRY3D::JDirection3D::rotate_back ( const JRotation3X & R)
inline

Rotate back around X-axis.

Parameters
Rrotation matrix
Returns
this direction

Definition at line 227 of file JDirection3D.hh.

228 {
229 R.rotate_back(__dy, __dz);
230
231 normalise();
232
233 return *this;
234 }

◆ rotate() [3/5]

JDirection3D & JGEOMETRY3D::JDirection3D::rotate ( const JRotation3Y & R)
inline

Rotate around Y-axis.

Parameters
Rrotation matrix
Returns
this direction

Definition at line 243 of file JDirection3D.hh.

244 {
245 R.rotate(__dx, __dz);
246
247 normalise();
248
249 return *this;
250 }

◆ rotate_back() [3/5]

JDirection3D & JGEOMETRY3D::JDirection3D::rotate_back ( const JRotation3Y & R)
inline

Rotate back around Y-axis.

Parameters
Rrotation matrix
Returns
this direction

Definition at line 259 of file JDirection3D.hh.

260 {
261 R.rotate_back(__dx, __dz);
262
263 normalise();
264
265 return *this;
266 }

◆ rotate() [4/5]

JDirection3D & JGEOMETRY3D::JDirection3D::rotate ( const JRotation3Z & R)
inline

Rotate around Z-axis.

Parameters
Rrotation matrix
Returns
this direction

Definition at line 275 of file JDirection3D.hh.

276 {
277 R.rotate(__dx, __dy);
278
279 normalise();
280
281 return *this;
282 }

◆ rotate_back() [4/5]

JDirection3D & JGEOMETRY3D::JDirection3D::rotate_back ( const JRotation3Z & R)
inline

Rotate back around Z-axis.

Parameters
Rrotation matrix
Returns
this direction

Definition at line 291 of file JDirection3D.hh.

292 {
293 R.rotate_back(__dx, __dy);
294
295 normalise();
296
297 return *this;
298 }

◆ rotate() [5/5]

JDirection3D & JGEOMETRY3D::JDirection3D::rotate ( const JQuaternion3D & Q)
inline

Rotate.

Parameters
Qquaternion
Returns
this position

Definition at line 307 of file JDirection3D.hh.

308 {
309 Q.rotate(__dx, __dy, __dz);
310
311 return *this;
312 }

◆ rotate_back() [5/5]

JDirection3D & JGEOMETRY3D::JDirection3D::rotate_back ( const JQuaternion3D & Q)
inline

Rotate back.

Parameters
Qquaternion
Returns
this position

Definition at line 321 of file JDirection3D.hh.

322 {
323 Q.rotate_back(__dx, __dy, __dz);
324
325 return *this;
326 }

◆ getDot() [1/4]

double JGEOMETRY3D::JDirection3D::getDot ( const JAngle3D & angle) const
inline

Get dot product.

Parameters
angleangle
Returns
dot product

Definition at line 335 of file JDirection3D.hh.

336 {
337 return
338 getDX() * angle.getDX() +
339 getDY() * angle.getDY() +
340 getDZ() * angle.getDZ();
341 }

◆ getDot() [2/4]

double JGEOMETRY3D::JDirection3D::getDot ( const JVector3D & pos) const
inline

Get dot product.

Parameters
posposition
Returns
dot product

Definition at line 350 of file JDirection3D.hh.

351 {
352 return
353 getDX() * pos.getX() +
354 getDY() * pos.getY() +
355 getDZ() * pos.getZ();
356 }

◆ getDot() [3/4]

double JGEOMETRY3D::JDirection3D::getDot ( const JVersor3Z & dir) const
inline

Get dot product.

Parameters
dirdirection
Returns
dot product

Definition at line 365 of file JDirection3D.hh.

366 {
367 return
368 getDX() * dir.getDX() +
369 getDY() * dir.getDY() +
370 getDZ() * dir.getDZ();
371 }

◆ getDot() [4/4]

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 }

◆ negate()

JVersor3D & JGEOMETRY3D::JVersor3D::negate ( )
inlineinherited

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
inlineinherited

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 }

◆ getDX()

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

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
inlineinherited

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
inlineinherited

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
inlineinherited

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
inlineinherited

Get phi angle.

Returns
phi angle [rad]

Definition at line 144 of file JVersor3D.hh.

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

◆ getCross()

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

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 ( )
inlineinherited

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 }

Friends And Related Symbol Documentation

◆ operator>> [1/2]

std::istream & operator>> ( std::istream & in,
JDirection3D & direction )
friend

Read direction from input.

Parameters
ininput stream
directiondirection
Returns
input stream

Definition at line 381 of file JDirection3D.hh.

382 {
383 in >> direction.__dx >> direction.__dy >> direction.__dz;
384
385 direction.normalise();
386
387 return in;
388 }

◆ operator<< [1/2]

std::ostream & operator<< ( std::ostream & out,
const JDirection3D & direction )
friend

Write direction to output.

Parameters
outoutput stream
directiondirection
Returns
output stream

Definition at line 398 of file JDirection3D.hh.

399 {
400 const JFormat format(out, getFormat<JDirection3D>(JFormat_t(9, 6, std::ios::fixed | std::ios::showpos)));
401
402 out << format << direction.getDX() << ' '
403 << format << direction.getDY() << ' '
404 << format << direction.getDZ();
405
406 return out;
407 }
JFormat_t & getFormat()
Get format for given type.
Definition JManip.hh:682
Data structure for format specifications.
Definition JManip.hh:524
Auxiliary class to temporarily define format specifications.
Definition JManip.hh:636

◆ operator>> [2/2]

JReader & operator>> ( JReader & in,
JDirection3D & direction )
friend

Read direction from input.

Parameters
inreader
directiondirection
Returns
reader

Definition at line 417 of file JDirection3D.hh.

418 {
419 return in >> direction.__dx >> direction.__dy >> direction.__dz;
420 }

◆ operator<< [2/2]

JWriter & operator<< ( JWriter & out,
const JDirection3D & direction )
friend

Write direction to output.

Parameters
outwriter
directiondirection
Returns
writer

Definition at line 430 of file JDirection3D.hh.

431 {
432 return out << direction.__dx << direction.__dy << direction.__dz;
433 }

Member Data Documentation

◆ __dx

double JGEOMETRY3D::JVersor3D::__dx
protectedinherited

Definition at line 206 of file JVersor3D.hh.

◆ __dy

double JGEOMETRY3D::JVersor3D::__dy
protectedinherited

Definition at line 207 of file JVersor3D.hh.

◆ __dz

double JGEOMETRY3D::JVersor3D::__dz
protectedinherited

Definition at line 208 of file JVersor3D.hh.


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