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, JAllocator_t > JTRIGGER::JFrameClone< JElement_t, JAllocator_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...
 
JDirection3Drotate_back (const JQuaternion3D &Q)
 Rotate back. 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 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 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:106
double getDZ() const
Get z direction.
Definition: JAngle3D.hh:128
double getDY() const
Get y direction.
Definition: JAngle3D.hh:117
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:103
JVersor3D()
Default constructor.
Definition: JVersor3D.hh:31
double getX() const
Get x position.
Definition: JVector3D.hh:93
double getZ() const
Get z position.
Definition: JVector3D.hh:114
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:156
JVersor3D()
Default constructor.
Definition: JVersor3D.hh:31
double getDX() const
Get x direction.
Definition: JVersor3Z.hh:145
double getDZ() const
Get z direction.
Definition: JVersor3Z.hh:167
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:31
double getDY() const
Get y direction.
Definition: JVersor3D.hh:103
double getDX() const
Get x direction.
Definition: JVersor3D.hh:92
double getDZ() const
Get z direction.
Definition: JVersor3D.hh:114
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:33
double getDY() const
Get y direction.
Definition: JVersor3D.hh:103
double getDX() const
Get x direction.
Definition: JVersor3D.hh:92
double getDZ() const
Get z direction.
Definition: JVersor3D.hh:114
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:168
do set_variable OUTPUT_DIRECTORY $WORKDIR T
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:336
JVersor3D & normalise()
Normalise versor.
Definition: JVersor3D.hh:168
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:355
JVersor3D & normalise()
Normalise versor.
Definition: JVersor3D.hh:168
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:168
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:168
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:168
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:168
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:168
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:168
JDirection3D& JGEOMETRY3D::JDirection3D::rotate ( const JQuaternion3D Q)
inline

Rotate.

Parameters
Qquaternion
Returns
this position

Definition at line 305 of file JDirection3D.hh.

306  {
307  Q.rotate(__dx, __dy, __dz);
308 
309  return *this;
310  }
void rotate(double &__x, double &__y, double &__z) const
Rotate.
JDirection3D& JGEOMETRY3D::JDirection3D::rotate_back ( const JQuaternion3D Q)
inline

Rotate back.

Parameters
Qquaternion
Returns
this position

Definition at line 319 of file JDirection3D.hh.

320  {
321  Q.rotate_back(__dx, __dy, __dz);
322 
323  return *this;
324  }
void rotate_back(double &__x, double &__y, double &__z) const
Rotate back.
double JGEOMETRY3D::JDirection3D::getDot ( const JAngle3D angle) const
inline

Get dot product.

Parameters
angleangle
Returns
dot product

Definition at line 333 of file JDirection3D.hh.

334  {
335  return
336  getDX() * angle.getDX() +
337  getDY() * angle.getDY() +
338  getDZ() * angle.getDZ();
339  }
double getDY() const
Get y direction.
Definition: JVersor3D.hh:103
double getDX() const
Get x direction.
Definition: JVersor3D.hh:92
double getDZ() const
Get z direction.
Definition: JVersor3D.hh:114
double getDX() const
Get x direction.
Definition: JAngle3D.hh:106
double getDZ() const
Get z direction.
Definition: JAngle3D.hh:128
double getDY() const
Get y direction.
Definition: JAngle3D.hh:117
double JGEOMETRY3D::JDirection3D::getDot ( const JVector3D pos) const
inline

Get dot product.

Parameters
posposition
Returns
dot product

Definition at line 348 of file JDirection3D.hh.

349  {
350  return
351  getDX() * pos.getX() +
352  getDY() * pos.getY() +
353  getDZ() * pos.getZ();
354  }
double getDY() const
Get y direction.
Definition: JVersor3D.hh:103
double getDX() const
Get x direction.
Definition: JVersor3D.hh:92
double getY() const
Get y position.
Definition: JVector3D.hh:103
double getX() const
Get x position.
Definition: JVector3D.hh:93
double getZ() const
Get z position.
Definition: JVector3D.hh:114
double getDZ() const
Get z direction.
Definition: JVersor3D.hh:114
double JGEOMETRY3D::JDirection3D::getDot ( const JVersor3Z dir) const
inline

Get dot product.

Parameters
dirdirection
Returns
dot product

Definition at line 363 of file JDirection3D.hh.

364  {
365  return
366  getDX() * dir.getDX() +
367  getDY() * dir.getDY() +
368  getDZ() * dir.getDZ();
369  }
double getDY() const
Get y direction.
Definition: JVersor3Z.hh:156
double getDY() const
Get y direction.
Definition: JVersor3D.hh:103
double getDX() const
Get x direction.
Definition: JVersor3D.hh:92
double getDX() const
Get x direction.
Definition: JVersor3Z.hh:145
double getDZ() const
Get z direction.
Definition: JVersor3Z.hh:167
double getDZ() const
Get z direction.
Definition: JVersor3D.hh:114
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 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 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  }
double getDY() const
Get y direction.
Definition: JVersor3D.hh:103
double getDX() const
Get x direction.
Definition: JVersor3D.hh:92
double getDZ() const
Get z direction.
Definition: JVersor3D.hh:114
double JGEOMETRY3D::JVersor3D::getDX ( ) const
inlineinherited

Get x direction.

Returns
x direction

Definition at line 92 of file JVersor3D.hh.

93  {
94  return __dx;
95  }
double JGEOMETRY3D::JVersor3D::getDY ( ) const
inlineinherited

Get y direction.

Returns
y direction

Definition at line 103 of file JVersor3D.hh.

104  {
105  return __dy;
106  }
double JGEOMETRY3D::JVersor3D::getDZ ( ) const
inlineinherited

Get z direction.

Returns
z direction

Definition at line 114 of file JVersor3D.hh.

115  {
116  return __dz;
117  }
double JGEOMETRY3D::JVersor3D::getTheta ( ) const
inlineinherited

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  }
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 141 of file JVersor3D.hh.

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

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  }
double getDY() const
Get y direction.
Definition: JVersor3D.hh:103
double getDX() const
Get x direction.
Definition: JVersor3D.hh:92
double getDZ() const
Get z direction.
Definition: JVersor3D.hh:114
JVersor3D& JGEOMETRY3D::JVersor3D::normalise ( )
inlineinherited

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  }
double getDY() const
Get y direction.
Definition: JVersor3D.hh:103
double getDX() const
Get x direction.
Definition: JVersor3D.hh:92
data_type v[N+1][M+1]
Definition: JPolint.hh:707
double getDZ() const
Get z direction.
Definition: JVersor3D.hh:114
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 arithmetic operations on 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 379 of file JDirection3D.hh.

380  {
381  in >> direction.__dx >> direction.__dy >> direction.__dz;
382 
383  return in;
384  }
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition: JSirene.sh:45
std::ostream& operator<< ( std::ostream &  out,
const JDirection3D direction 
)
friend

Write direction to output.

Parameters
outoutput stream
directiondirection
Returns
output stream

Definition at line 394 of file JDirection3D.hh.

395  {
396  out << direction.getDX() << ' ' << direction.getDY() << ' ' << direction.getDZ();
397 
398  return out;
399  }
double getDY() const
Get y direction.
Definition: JVersor3D.hh:103
double getDX() const
Get x direction.
Definition: JVersor3D.hh:92
double getDZ() const
Get z direction.
Definition: JVersor3D.hh:114
JReader& operator>> ( JReader in,
JDirection3D direction 
)
friend

Read direction from input.

Parameters
inreader
directiondirection
Returns
reader

Definition at line 409 of file JDirection3D.hh.

410  {
411  return in >> direction.__dx >> direction.__dy >> direction.__dz;
412  }
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition: JSirene.sh:45
JWriter& operator<< ( JWriter out,
const JDirection3D direction 
)
friend

Write direction to output.

Parameters
outwriter
directiondirection
Returns
writer

Definition at line 422 of file JDirection3D.hh.

423  {
424  return out << direction.getDX() << direction.getDY() << direction.getDZ();
425  }
double getDY() const
Get y direction.
Definition: JVersor3D.hh:103
double getDX() const
Get x direction.
Definition: JVersor3D.hh:92
double getDZ() const
Get z direction.
Definition: JVersor3D.hh:114

Member Data Documentation

double JGEOMETRY3D::JVersor3D::__dx
protectedinherited

Definition at line 182 of file JVersor3D.hh.

double JGEOMETRY3D::JVersor3D::__dy
protectedinherited

Definition at line 183 of file JVersor3D.hh.

double JGEOMETRY3D::JVersor3D::__dz
protectedinherited

Definition at line 184 of file JVersor3D.hh.


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