Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Attributes | Friends | List of all members
JGEOMETRY3D::JDirection3D Class Reference

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

#include <JDirection3D.hh>

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

Public Member Functions

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

Protected Attributes

double __dx
 
double __dy
 
double __dz
 

Friends

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

Detailed Description

Data structure for direction in three dimensions.

Definition at line 32 of file JDirection3D.hh.

Constructor & Destructor Documentation

JGEOMETRY3D::JDirection3D::JDirection3D ( )
inline

Default constructor.

Definition at line 42 of file JDirection3D.hh.

42  :
43  JVersor3D()
44  {}
JVersor3D()
Default constructor.
Definition: JVersor3D.hh:31
JGEOMETRY3D::JDirection3D::JDirection3D ( const JVersor3D dir)
inline

Constructor.

Parameters
dirdirection

Definition at line 52 of file JDirection3D.hh.

52  :
53  JVersor3D(dir)
54  {}
JVersor3D()
Default constructor.
Definition: JVersor3D.hh:31
JGEOMETRY3D::JDirection3D::JDirection3D ( const JAngle3D angle)
inline

Constructor.

Parameters
angleangle

Definition at line 62 of file JDirection3D.hh.

62  :
63  JVersor3D(angle.getDX(), angle.getDY(), angle.getDZ())
64  {}
JVersor3D()
Default constructor.
Definition: JVersor3D.hh:31
double getDX() const
Get x direction.
Definition: JAngle3D.hh:105
double getDZ() const
Get z direction.
Definition: JAngle3D.hh:127
double getDY() const
Get y direction.
Definition: JAngle3D.hh:116
JGEOMETRY3D::JDirection3D::JDirection3D ( const JVector3D pos)
inline

Constructor.

Parameters
posposition

Definition at line 72 of file JDirection3D.hh.

72  :
73  JVersor3D(pos.getX(), pos.getY(), pos.getZ())
74  {}
double getY() const
Get y position.
Definition: JVector3D.hh:102
JVersor3D()
Default constructor.
Definition: JVersor3D.hh:31
double getX() const
Get x position.
Definition: JVector3D.hh:92
double getZ() const
Get z position.
Definition: JVector3D.hh:113
JGEOMETRY3D::JDirection3D::JDirection3D ( const JVersor3Z dir)
inline

Constructor.

Parameters
dirdirection

Definition at line 82 of file JDirection3D.hh.

82  :
83  JVersor3D(dir.getDX(), dir.getDY(), dir.getDZ())
84  {}
double getDY() const
Get y direction.
Definition: JVersor3Z.hh:155
JVersor3D()
Default constructor.
Definition: JVersor3D.hh:31
double getDX() const
Get x direction.
Definition: JVersor3Z.hh:144
double getDZ() const
Get z direction.
Definition: JVersor3Z.hh:166
JGEOMETRY3D::JDirection3D::JDirection3D ( const double  dx,
const double  dy,
const double  dz 
)
inline

Constructor.

Parameters
dxdx value
dydy value
dzdz value

Definition at line 94 of file JDirection3D.hh.

96  :
97  JVersor3D(dx, dy, dz)
98  {}
JVersor3D()
Default constructor.
Definition: JVersor3D.hh:31

Member Function Documentation

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

Get direction.

Returns
direction

Definition at line 106 of file JDirection3D.hh.

107  {
108  return static_cast<const JDirection3D&>(*this);
109  }
Data structure for direction in three dimensions.
Definition: JDirection3D.hh:32
JDirection3D& JGEOMETRY3D::JDirection3D::getDirection ( )
inline

Get direction.

Returns
direction

Definition at line 117 of file JDirection3D.hh.

118  {
119  return static_cast<JDirection3D&>(*this);
120  }
Data structure for direction in three dimensions.
Definition: JDirection3D.hh:32
void JGEOMETRY3D::JDirection3D::setDirection ( const JDirection3D dir)
inline

Set direction.

Parameters
dirdirection

Definition at line 128 of file JDirection3D.hh.

129  {
130  static_cast<JDirection3D&>(*this) = dir;
131  }
Data structure for direction in three dimensions.
Definition: JDirection3D.hh:32
JGEOMETRY3D::JDirection3D::operator JAngle3D ( ) const
inline

Type conversion operator.

Returns
angle

Definition at line 138 of file JDirection3D.hh.

139  {
140  return JAngle3D(getDX(), getDY(), getDZ());
141  }
Data structure for angles in three dimensions.
Definition: JAngle3D.hh:30
double getDY() const
Get y direction.
Definition: JVersor3D.hh:101
double getDX() const
Get x direction.
Definition: JVersor3D.hh:90
double getDZ() const
Get z direction.
Definition: JVersor3D.hh:112
JGEOMETRY3D::JDirection3D::operator JVector3D ( ) const
inline

Type conversion operator.

Returns
position

Definition at line 149 of file JDirection3D.hh.

150  {
151  return JVector3D(getDX(), getDY(), getDZ());
152  }
Data structure for vector in three dimensions.
Definition: JVector3D.hh:32
double getDY() const
Get y direction.
Definition: JVersor3D.hh:101
double getDX() const
Get x direction.
Definition: JVersor3D.hh:90
double getDZ() const
Get z direction.
Definition: JVersor3D.hh:112
JDirection3D& JGEOMETRY3D::JDirection3D::transform ( const JMatrix3D T)
inline

Transform.

Parameters
Tmatrix
Returns
this direction

Definition at line 161 of file JDirection3D.hh.

162  {
163  T.transform(__dx, __dy, __dz);
164 
165  normalise();
166 
167  return *this;
168  }
JVersor3D & normalise()
Normalise versor.
Definition: JVersor3D.hh:166
JDirection3D& JGEOMETRY3D::JDirection3D::rotate ( const JRotation3D R)
inline

Rotate.

Parameters
Rrotation matrix
Returns
this direction

Definition at line 177 of file JDirection3D.hh.

178  {
179  R.rotate(__dx, __dy, __dz);
180 
181  normalise();
182 
183  return *this;
184  }
void rotate(double &__x, double &__y, double &__z) const
Rotate.
Definition: JRotation3D.hh:277
JVersor3D & normalise()
Normalise versor.
Definition: JVersor3D.hh:166
JDirection3D& JGEOMETRY3D::JDirection3D::rotate_back ( const JRotation3D R)
inline

Rotate back.

Parameters
Rrotation matrix
Returns
this direction

Definition at line 193 of file JDirection3D.hh.

194  {
195  R.rotate_back(__dx, __dy, __dz);
196 
197  normalise();
198 
199  return *this;
200  }
void rotate_back(double &__x, double &__y, double &__z) const
Rotate back.
Definition: JRotation3D.hh:296
JVersor3D & normalise()
Normalise versor.
Definition: JVersor3D.hh:166
JDirection3D& JGEOMETRY3D::JDirection3D::rotate ( const JRotation3X R)
inline

Rotate around X-axis.

Parameters
Rrotation matrix
Returns
this direction

Definition at line 209 of file JDirection3D.hh.

210  {
211  R.rotate(__dy, __dz);
212 
213  normalise();
214 
215  return *this;
216  }
void rotate(double &__x, double &__y) const
Rotate.
Definition: JRotation2D.hh:96
JVersor3D & normalise()
Normalise versor.
Definition: JVersor3D.hh:166
JDirection3D& JGEOMETRY3D::JDirection3D::rotate_back ( const JRotation3X R)
inline

Rotate back around X-axis.

Parameters
Rrotation matrix
Returns
this direction

Definition at line 225 of file JDirection3D.hh.

226  {
227  R.rotate_back(__dy, __dz);
228 
229  normalise();
230 
231  return *this;
232  }
void rotate_back(double &__x, double &__y) const
Rotate back.
Definition: JRotation2D.hh:112
JVersor3D & normalise()
Normalise versor.
Definition: JVersor3D.hh:166
JDirection3D& JGEOMETRY3D::JDirection3D::rotate ( const JRotation3Y R)
inline

Rotate around Y-axis.

Parameters
Rrotation matrix
Returns
this direction

Definition at line 241 of file JDirection3D.hh.

242  {
243  R.rotate(__dx, __dz);
244 
245  normalise();
246 
247  return *this;
248  }
void rotate(double &__x, double &__y) const
Rotate.
Definition: JRotation2D.hh:96
JVersor3D & normalise()
Normalise versor.
Definition: JVersor3D.hh:166
JDirection3D& JGEOMETRY3D::JDirection3D::rotate_back ( const JRotation3Y R)
inline

Rotate back around Y-axis.

Parameters
Rrotation matrix
Returns
this direction

Definition at line 257 of file JDirection3D.hh.

258  {
259  R.rotate_back(__dx, __dz);
260 
261  normalise();
262 
263  return *this;
264  }
void rotate_back(double &__x, double &__y) const
Rotate back.
Definition: JRotation2D.hh:112
JVersor3D & normalise()
Normalise versor.
Definition: JVersor3D.hh:166
JDirection3D& JGEOMETRY3D::JDirection3D::rotate ( const JRotation3Z R)
inline

Rotate around Z-axis.

Parameters
Rrotation matrix
Returns
this direction

Definition at line 273 of file JDirection3D.hh.

274  {
275  R.rotate(__dx, __dy);
276 
277  normalise();
278 
279  return *this;
280  }
void rotate(double &__x, double &__y) const
Rotate.
Definition: JRotation2D.hh:96
JVersor3D & normalise()
Normalise versor.
Definition: JVersor3D.hh:166
JDirection3D& JGEOMETRY3D::JDirection3D::rotate_back ( const JRotation3Z R)
inline

Rotate back around Z-axis.

Parameters
Rrotation matrix
Returns
this direction

Definition at line 289 of file JDirection3D.hh.

290  {
291  R.rotate_back(__dx, __dy);
292 
293  normalise();
294 
295  return *this;
296  }
void rotate_back(double &__x, double &__y) const
Rotate back.
Definition: JRotation2D.hh:112
JVersor3D & normalise()
Normalise versor.
Definition: JVersor3D.hh:166
JDirection3D& JGEOMETRY3D::JDirection3D::rotate ( const JQuaternion3D Q)
inline

Rotate.

Parameters
Qquaternion
Returns
this position

Definition at line 305 of file JDirection3D.hh.

306  {
307  JQuaternion3D b(Q);
308  JQuaternion3D a;
309 
310  a.mul(*this, b.conjugate());
311 
312  static_cast<JVersor3D&>(*this) = b.mul(Q,a);
313 
314  return *this;
315  }
JQuaternion3D & mul(const double factor)
Scale quaternion.
JFirst_t & mul(const JSecond_t &object)
Multiply with object.
Definition: JMath.hh:273
Data structure for quaternion in three dimensions.
Data structure for normalised vector in three dimensions.
Definition: JVersor3D.hh:23
double JGEOMETRY3D::JDirection3D::getDot ( const JAngle3D angle) const
inline

Get dot product.

Parameters
angleangle
Returns
dot product

Definition at line 324 of file JDirection3D.hh.

325  {
326  return
327  getDX() * angle.getDX() +
328  getDY() * angle.getDY() +
329  getDZ() * angle.getDZ();
330  }
double getDY() const
Get y direction.
Definition: JVersor3D.hh:101
double getDX() const
Get x direction.
Definition: JVersor3D.hh:90
double getDZ() const
Get z direction.
Definition: JVersor3D.hh:112
double getDX() const
Get x direction.
Definition: JAngle3D.hh:105
double getDZ() const
Get z direction.
Definition: JAngle3D.hh:127
double getDY() const
Get y direction.
Definition: JAngle3D.hh:116
double JGEOMETRY3D::JDirection3D::getDot ( const JVector3D pos) const
inline

Get dot product.

Parameters
posposition
Returns
dot product

Definition at line 339 of file JDirection3D.hh.

340  {
341  return
342  getDX() * pos.getX() +
343  getDY() * pos.getY() +
344  getDZ() * pos.getZ();
345  }
double getDY() const
Get y direction.
Definition: JVersor3D.hh:101
double getDX() const
Get x direction.
Definition: JVersor3D.hh:90
double getY() const
Get y position.
Definition: JVector3D.hh:102
double getX() const
Get x position.
Definition: JVector3D.hh:92
double getZ() const
Get z position.
Definition: JVector3D.hh:113
double getDZ() const
Get z direction.
Definition: JVersor3D.hh:112
double JGEOMETRY3D::JDirection3D::getDot ( const JVersor3Z dir) const
inline

Get dot product.

Parameters
dirdirection
Returns
dot product

Definition at line 354 of file JDirection3D.hh.

355  {
356  return
357  getDX() * dir.getDX() +
358  getDY() * dir.getDY() +
359  getDZ() * dir.getDZ();
360  }
double getDY() const
Get y direction.
Definition: JVersor3Z.hh:155
double getDY() const
Get y direction.
Definition: JVersor3D.hh:101
double getDX() const
Get x direction.
Definition: JVersor3D.hh:90
double getDX() const
Get x direction.
Definition: JVersor3Z.hh:144
double getDZ() const
Get z direction.
Definition: JVersor3Z.hh:166
double getDZ() const
Get z direction.
Definition: JVersor3D.hh:112
JVersor3D& JGEOMETRY3D::JVersor3D::negate ( )
inlineinherited

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  }
bool JGEOMETRY3D::JVersor3D::equals ( const JVersor3D versor) const
inlineinherited

Check equality.

Parameters
versorversor
Returns
true if versors are equal; else false

Definition at line 77 of file JVersor3D.hh.

78  {
79  return (getDX() == versor.getDX() &&
80  getDY() == versor.getDY() &&
81  getDZ() == versor.getDZ());
82  }
double getDY() const
Get y direction.
Definition: JVersor3D.hh:101
double getDX() const
Get x direction.
Definition: JVersor3D.hh:90
double getDZ() const
Get z direction.
Definition: JVersor3D.hh:112
double JGEOMETRY3D::JVersor3D::getDX ( ) const
inlineinherited

Get x direction.

Returns
x direction

Definition at line 90 of file JVersor3D.hh.

91  {
92  return __dx;
93  }
double JGEOMETRY3D::JVersor3D::getDY ( ) const
inlineinherited

Get y direction.

Returns
y direction

Definition at line 101 of file JVersor3D.hh.

102  {
103  return __dy;
104  }
double JGEOMETRY3D::JVersor3D::getDZ ( ) const
inlineinherited

Get z direction.

Returns
z direction

Definition at line 112 of file JVersor3D.hh.

113  {
114  return __dz;
115  }
double JGEOMETRY3D::JVersor3D::getTheta ( ) const
inlineinherited

Get theta angle.

Returns
theta angle [rad]

Definition at line 123 of file JVersor3D.hh.

124  {
125  if (__dz > +1.0)
126  return 0.0;
127  else if (__dz < -1.0)
128  return JTOOLS::PI;
129  else
130  return acos(__dz);
131  }
static const double PI
Constants.
Definition: JConstants.hh:20
double JGEOMETRY3D::JVersor3D::getPhi ( ) const
inlineinherited

Get phi angle.

Returns
phi angle [rad]

Definition at line 139 of file JVersor3D.hh.

140  {
141  return atan2(__dy, __dx);
142  }
double JGEOMETRY3D::JVersor3D::getDot ( const JVersor3D versor) const
inlineinherited

Get dot product.

Parameters
versorversor
Returns
dot product

Definition at line 151 of file JVersor3D.hh.

152  {
153  return
154  getDX() * versor.getDX() +
155  getDY() * versor.getDY() +
156  getDZ() * versor.getDZ();
157  }
double getDY() const
Get y direction.
Definition: JVersor3D.hh:101
double getDX() const
Get x direction.
Definition: JVersor3D.hh:90
double getDZ() const
Get z direction.
Definition: JVersor3D.hh:112
JVersor3D& JGEOMETRY3D::JVersor3D::normalise ( )
inlineinherited

Normalise versor.

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

Returns
this versor

Definition at line 166 of file JVersor3D.hh.

167  {
168  const double v = sqrt(getDX()*getDX() + getDY()*getDY() + getDZ()*getDZ());
169 
170  if (v != 0.0) {
171  __dx /= v;
172  __dy /= v;
173  __dz /= v;
174  }
175 
176  return *this;
177  }
double getDY() const
Get y direction.
Definition: JVersor3D.hh:101
double getDX() const
Get x direction.
Definition: JVersor3D.hh:90
double getDZ() const
Get z direction.
Definition: JVersor3D.hh:112
JVersor3D & JMATH::JMath< JVersor3D , JNullType >::mul ( const JNullType 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  }
Auxiliary class for product evaluation of objects.
Definition: JCalculator.hh:18

Friends And Related Function Documentation

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

Read direction from input.

Parameters
ininput stream
directiondirection
Returns
input stream

Definition at line 370 of file JDirection3D.hh.

371  {
372  in >> direction.__dx >> direction.__dy >> direction.__dz;
373 
374  return in;
375  }
std::ostream& operator<< ( std::ostream &  out,
const JDirection3D direction 
)
friend

Write direction to output.

Parameters
outoutput stream
directiondirection
Returns
output stream

Definition at line 385 of file JDirection3D.hh.

386  {
387  out << direction.getDX() << ' ' << direction.getDY() << ' ' << direction.getDZ();
388 
389  return out;
390  }
double getDY() const
Get y direction.
Definition: JVersor3D.hh:101
double getDX() const
Get x direction.
Definition: JVersor3D.hh:90
double getDZ() const
Get z direction.
Definition: JVersor3D.hh:112
JReader& operator>> ( JReader in,
JDirection3D direction 
)
friend

Read direction from input.

Parameters
inreader
directiondirection
Returns
reader

Definition at line 400 of file JDirection3D.hh.

401  {
402  return in >> direction.__dx >> direction.__dy >> direction.__dz;
403  }
JWriter& operator<< ( JWriter out,
const JDirection3D direction 
)
friend

Write direction to output.

Parameters
outwriter
directiondirection
Returns
writer

Definition at line 413 of file JDirection3D.hh.

414  {
415  return out << direction.getDX() << direction.getDY() << direction.getDZ();
416  }
double getDY() const
Get y direction.
Definition: JVersor3D.hh:101
double getDX() const
Get x direction.
Definition: JVersor3D.hh:90
double getDZ() const
Get z direction.
Definition: JVersor3D.hh:112

Member Data Documentation

double JGEOMETRY3D::JVersor3D::__dx
protectedinherited

Definition at line 180 of file JVersor3D.hh.

double JGEOMETRY3D::JVersor3D::__dy
protectedinherited

Definition at line 181 of file JVersor3D.hh.

double JGEOMETRY3D::JVersor3D::__dz
protectedinherited

Definition at line 182 of file JVersor3D.hh.


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