Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JGEOMETRY3D::JVersor3Z Class Reference

Data structure for normalised vector in positive z-direction. More...

#include <JVersor3Z.hh>

Inheritance diagram for JGEOMETRY3D::JVersor3Z:
JMATH::JMath< JFirst_t, JSecond_t > JFIT::JLine3Z JFIT::JShower3Z JSIRENE::JVertex JFIT::JLine3EZ JFIT::JShower3EZ JFIT::JShowerEH

Public Member Functions

 JVersor3Z ()
 Default constructor.
 
 JVersor3Z (const JVersor2D &dir)
 Constructor.
 
 JVersor3Z (const double dx, const double dy)
 Constructor.
 
const JVersor3ZgetDirection () const
 Get direction.
 
JVersor3ZgetDirection ()
 Get direction.
 
void setDirection (const JVersor3Z &direction)
 Set direction.
 
 operator JAngle3D () const
 Get angle.
 
 operator JVector3D () const
 Type conversion operator.
 
 operator JVersor3D () const
 Type conversion operator.
 
double getDX () const
 Get x direction.
 
double getDY () const
 Get y direction.
 
double getDZ () const
 Get z direction.
 
JVersor3Znegate ()
 Prefix unary minus.
 
JVersor3Zadd (const JVersor3Z &value)
 Addition operator.
 
JVersor3Zsub (const JVersor3Z &value)
 Subtraction operator.
 
JVersor3Zmul (const double value)
 Multiplication operator.
 
JVersor3Zdiv (const double value)
 Division operator.
 
bool equals (const JVersor3D &versor, const double precision=std::numeric_limits< double >::min()) const
 Check equality.
 
double getDot (const JVersor3Z &dir) const
 Get dot product.
 
double getDot (const JAngle3D &angle) const
 Get dot product.
 
double getDot (const JVector3D &pos) const
 Get dot product.
 
double getDot (const JVersor3D &dir) const
 Get dot product.
 
JFirst_t & mul (const JSecond_t &object)
 Multiply with object.
 

Protected Attributes

double __dx
 
double __dy
 

Friends

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

Detailed Description

Data structure for normalised vector in positive z-direction.

The member methods getDX() and getDY() refer to the corresponding direction cosines. Note that the direction cosines may have any value. The method getDZ() will simply return 0 if the sum of the squares of the direction cosines is larger than 1.

Definition at line 39 of file JVersor3Z.hh.

Constructor & Destructor Documentation

◆ JVersor3Z() [1/3]

JGEOMETRY3D::JVersor3Z::JVersor3Z ( )
inline

Default constructor.

Definition at line 46 of file JVersor3Z.hh.

46 :
47 __dx(0.0),
48 __dy(0.0)
49 {}

◆ JVersor3Z() [2/3]

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

Constructor.

Parameters
dirdirection cosines

Definition at line 57 of file JVersor3Z.hh.

57 :
58 __dx(dir.getDX()),
59 __dy(dir.getDY())
60 {}

◆ JVersor3Z() [3/3]

JGEOMETRY3D::JVersor3Z::JVersor3Z ( const double dx,
const double dy )
inline

Constructor.

Parameters
dxdirection cosine dx/dz
dydirection cosine dy/dz

Definition at line 69 of file JVersor3Z.hh.

70 :
71 __dx(dx),
72 __dy(dy)
73 {}

Member Function Documentation

◆ getDirection() [1/2]

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

Get direction.

Returns
direction

Definition at line 81 of file JVersor3Z.hh.

82 {
83 return static_cast<const JVersor3Z&>(*this);
84 }
JVersor3Z()
Default constructor.
Definition JVersor3Z.hh:46

◆ getDirection() [2/2]

JVersor3Z & JGEOMETRY3D::JVersor3Z::getDirection ( )
inline

Get direction.

Returns
direction

Definition at line 92 of file JVersor3Z.hh.

93 {
94 return static_cast<JVersor3Z&>(*this);
95 }

◆ setDirection()

void JGEOMETRY3D::JVersor3Z::setDirection ( const JVersor3Z & direction)
inline

Set direction.

Parameters
directiondirection

Definition at line 103 of file JVersor3Z.hh.

104 {
105 static_cast<JVersor3Z&>(*this) = direction;
106 }

◆ operator JAngle3D()

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

Get angle.

Returns
angle

Definition at line 114 of file JVersor3Z.hh.

115 {
116 return JAngle3D(getDX(), getDY(), getDZ());
117 }
double getDZ() const
Get z direction.
Definition JVersor3Z.hh:169
double getDY() const
Get y direction.
Definition JVersor3Z.hh:158
double getDX() const
Get x direction.
Definition JVersor3Z.hh:147

◆ operator JVector3D()

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

Type conversion operator.

Returns
position

Definition at line 125 of file JVersor3Z.hh.

126 {
127 return JVector3D(getDX(), getDY(), getDZ());
128 }

◆ operator JVersor3D()

JGEOMETRY3D::JVersor3Z::operator JVersor3D ( ) const
inline

Type conversion operator.

Returns
direction

Definition at line 136 of file JVersor3Z.hh.

137 {
138 return JVersor3D(getDX(), getDY(), getDZ());
139 }

◆ getDX()

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

Get x direction.

Returns
x direction

Definition at line 147 of file JVersor3Z.hh.

148 {
149 return __dx;
150 }

◆ getDY()

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

Get y direction.

Returns
y direction

Definition at line 158 of file JVersor3Z.hh.

159 {
160 return __dy;
161 }

◆ getDZ()

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

Get z direction.

Returns
z direction

Definition at line 169 of file JVersor3Z.hh.

170 {
171 const double v = getDX()*getDX() + getDY()*getDY();
172
173 if (v <= 1.0)
174 return sqrt(1.0 - v);
175 else
176 return 0.0;
177 }

◆ negate()

JVersor3Z & JGEOMETRY3D::JVersor3Z::negate ( )
inline

Prefix unary minus.

Returns
this versor

Definition at line 185 of file JVersor3Z.hh.

186 {
187 __dx = -__dx;
188 __dy = -__dy;
189
190 return *this;
191 }

◆ add()

JVersor3Z & JGEOMETRY3D::JVersor3Z::add ( const JVersor3Z & value)
inline

Addition operator.

Parameters
valueversor
Returns
this versor

Definition at line 200 of file JVersor3Z.hh.

201 {
202 __dx += value.getDX();
203 __dy += value.getDY();
204
205 return *this;
206 }

◆ sub()

JVersor3Z & JGEOMETRY3D::JVersor3Z::sub ( const JVersor3Z & value)
inline

Subtraction operator.

Parameters
valueversor
Returns
this versor

Definition at line 215 of file JVersor3Z.hh.

216 {
217 __dx -= value.getDX();
218 __dy -= value.getDY();
219
220 return *this;
221 }

◆ mul() [1/2]

JVersor3Z & JGEOMETRY3D::JVersor3Z::mul ( const double value)
inline

Multiplication operator.

Parameters
valuemultiplication factor
Returns
this versor

Definition at line 230 of file JVersor3Z.hh.

231 {
232 __dx *= value;
233 __dy *= value;
234
235 return *this;
236 }

◆ div()

JVersor3Z & JGEOMETRY3D::JVersor3Z::div ( const double value)
inline

Division operator.

Parameters
valuemultiplication factor
Returns
this versor

Definition at line 245 of file JVersor3Z.hh.

246 {
247 __dx /= value;
248 __dy /= value;
249
250 return *this;
251 }

◆ equals()

bool JGEOMETRY3D::JVersor3Z::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 261 of file JVersor3Z.hh.

263 {
264 return (fabs(getDX() - versor.getDX()) <= precision &&
265 fabs(getDY() - versor.getDY()) <= precision);
266 }

◆ getDot() [1/4]

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

Get dot product.

Parameters
dirdirection
Returns
dot product

Definition at line 275 of file JVersor3Z.hh.

276 {
277 return
278 getDX() * dir.getDX() +
279 getDY() * dir.getDY() +
280 getDZ() * dir.getDZ();
281 }

◆ getDot() [2/4]

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

Get dot product.

Parameters
angleangle
Returns
dot product

Definition at line 290 of file JVersor3Z.hh.

291 {
292 return
293 getDX() * angle.getDX() +
294 getDY() * angle.getDY() +
295 getDZ() * angle.getDZ();
296 }

◆ getDot() [3/4]

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

Get dot product.

Parameters
posposition
Returns
dot product

Definition at line 305 of file JVersor3Z.hh.

306 {
307 return
308 getDX() * pos.getX() +
309 getDY() * pos.getY() +
310 getDZ() * pos.getZ();
311 }

◆ getDot() [4/4]

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

Get dot product.

Parameters
dirdirection
Returns
dot product

Definition at line 320 of file JVersor3Z.hh.

321 {
322 return
323 getDX() * dir.getDX() +
324 getDY() * dir.getDY() +
325 getDZ() * dir.getDZ();
326 }

◆ mul() [2/2]

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,
JVersor3Z & versor )
friend

Read versor from input.

Parameters
ininput stream
versorversor
Returns
input stream

Definition at line 336 of file JVersor3Z.hh.

337 {
338 return in >> versor.__dx >> versor.__dy;
339 }

◆ operator<< [1/2]

std::ostream & operator<< ( std::ostream & out,
const JVersor3Z & versor )
friend

Write versor to output.

Parameters
outoutput stream
versorversor
Returns
output stream

Definition at line 349 of file JVersor3Z.hh.

350 {
351 const JFormat format(out, getFormat<JVersor3Z>(JFormat_t(9, 6, std::ios::fixed | std::ios::showpos)));
352
353 return out << format << versor.getDX() << ' ' << format << versor.getDY();
354 }
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,
JVersor3Z & versor )
friend

Read versor from input.

Parameters
inreader
versorversor
Returns
reader

Definition at line 364 of file JVersor3Z.hh.

365 {
366 return in >> versor.__dx >> versor.__dy;
367 }

◆ operator<< [2/2]

JWriter & operator<< ( JWriter & out,
const JVersor3Z & versor )
friend

Write versor to output.

Parameters
outwriter
versorversor
Returns
writer

Definition at line 377 of file JVersor3Z.hh.

378 {
379 return out << versor.__dx << versor.__dy;
380 }

Member Data Documentation

◆ __dx

double JGEOMETRY3D::JVersor3Z::__dx
protected

Definition at line 383 of file JVersor3Z.hh.

◆ __dy

double JGEOMETRY3D::JVersor3Z::__dy
protected

Definition at line 384 of file JVersor3Z.hh.


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