Jpp
Public Member Functions | Protected Attributes | List of all members
JGEOMETRY3D::JVector3D Class Reference

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

#include <JVector3D.hh>

Inheritance diagram for JGEOMETRY3D::JVector3D:
JMATH::JMath< JVector3D > JGEOMETRY3D::JEigenValues3D JGEOMETRY3D::JPosition3D JDETECTOR::JModule JDETECTOR::JModuleGeometry JDETECTOR::JModulePosition_t JFIT::JPoint3D JGEOMETRY3D::JAxis3D JGEOMETRY3D::JCenter3D JGEOMETRY3D::JSphere3D JGEOMETRY3D::JTransformation3D JGEOMETRY3D::JVertex3D JGEOMETRY3D::JWeighedCenter3D JTRIGGER::JHitR1 JTRIGGER::JModuleHeader

Public Member Functions

 JVector3D ()
 Default constructor. More...
 
 JVector3D (const double x, const double y, const double z)
 Constructor. More...
 
 JVector3D (const JVector2D &vector, const double z)
 Constructor. More...
 
 operator JVector2D () const
 Type conversion operator. More...
 
double getX () const
 Get x position. More...
 
double getY () const
 Get y position. More...
 
double getZ () const
 Get z position. More...
 
JVector3Dnegate ()
 Negate vector. More...
 
JVector3Dadd (const JVector3D &vector)
 Add vector. More...
 
JVector3Dsub (const JVector3D &vector)
 Subtract vector. More...
 
JVector3Dmul (const double factor)
 Scale vector. More...
 
JVector3Ddiv (const double factor)
 Scale vector. More...
 
JVector3Dtransform (const JMatrix3D &T)
 Transform. More...
 
bool equals (const JVector3D &vector, const double precision=std::numeric_limits< double >::min()) const
 Check equality. More...
 
double getLengthSquared () const
 Get length squared. More...
 
double getLength () const
 Get length. More...
 
double getDistanceSquared (const JVector3D &pos) const
 Get squared of distance to point. More...
 
double getDistance (const JVector3D &pos) const
 Get distance to point. More...
 
double getDot (const JVector3D &vector) const
 Get dot product. More...
 
JVector3Dcross (const JVector3D &first, const JVector3D &second)
 Get cross product. More...
 
JVector3Dmul (const JSecond_t &object)
 Multiply with object. More...
 

Protected Attributes

double __x
 
double __y
 
double __z
 

Detailed Description

Data structure for vector in three dimensions.

This class implements the JMATH::JMath interface.

Definition at line 33 of file JVector3D.hh.

Constructor & Destructor Documentation

◆ JVector3D() [1/3]

JGEOMETRY3D::JVector3D::JVector3D ( )
inline

Default constructor.

Definition at line 40 of file JVector3D.hh.

40  :
41  __x(0.0),
42  __y(0.0),
43  __z(0.0)
44  {}

◆ JVector3D() [2/3]

JGEOMETRY3D::JVector3D::JVector3D ( const double  x,
const double  y,
const double  z 
)
inline

Constructor.

Parameters
xx value
yy value
zz value

Definition at line 54 of file JVector3D.hh.

56  :
57  __x(x),
58  __y(y),
59  __z(z)
60  {}

◆ JVector3D() [3/3]

JGEOMETRY3D::JVector3D::JVector3D ( const JVector2D vector,
const double  z 
)
inline

Constructor.

Parameters
vector(x,y) values
zz value

Definition at line 69 of file JVector3D.hh.

70  :
71  __x(vector.getX()),
72  __y(vector.getY()),
73  __z(z)
74  {}

Member Function Documentation

◆ operator JVector2D()

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

Type conversion operator.

Returns
JVector2D

Definition at line 82 of file JVector3D.hh.

83  {
84  return JVector2D(this->getX(), this->getY());
85  }

◆ getX()

double JGEOMETRY3D::JVector3D::getX ( ) const
inline

Get x position.

Returns
x position

Definition at line 93 of file JVector3D.hh.

94  {
95  return __x;
96  }

◆ getY()

double JGEOMETRY3D::JVector3D::getY ( ) const
inline

Get y position.

Returns
y position

Definition at line 103 of file JVector3D.hh.

104  {
105  return __y;
106  }

◆ getZ()

double JGEOMETRY3D::JVector3D::getZ ( ) const
inline

Get z position.

Returns
z position

Definition at line 114 of file JVector3D.hh.

115  {
116  return __z;
117  }

◆ negate()

JVector3D& JGEOMETRY3D::JVector3D::negate ( )
inline

Negate vector.

Returns
this vector

Definition at line 125 of file JVector3D.hh.

126  {
127  __x = -__x;
128  __y = -__y;
129  __z = -__z;
130 
131  return *this;
132  }

◆ add()

JVector3D& JGEOMETRY3D::JVector3D::add ( const JVector3D vector)
inline

Add vector.

Parameters
vectorvector
Returns
this vector

Definition at line 141 of file JVector3D.hh.

142  {
143  __x += vector.getX();
144  __y += vector.getY();
145  __z += vector.getZ();
146 
147  return *this;
148  }

◆ sub()

JVector3D& JGEOMETRY3D::JVector3D::sub ( const JVector3D vector)
inline

Subtract vector.

Parameters
vectorvector
Returns
this vector

Definition at line 157 of file JVector3D.hh.

158  {
159  __x -= vector.getX();
160  __y -= vector.getY();
161  __z -= vector.getZ();
162 
163  return *this;
164  }

◆ mul() [1/2]

JVector3D& JGEOMETRY3D::JVector3D::mul ( const double  factor)
inline

Scale vector.

Parameters
factormultiplication factor
Returns
this vector

Definition at line 173 of file JVector3D.hh.

174  {
175  __x *= factor;
176  __y *= factor;
177  __z *= factor;
178 
179  return *this;
180  }

◆ div()

JVector3D& JGEOMETRY3D::JVector3D::div ( const double  factor)
inline

Scale vector.

Parameters
factordivision factor
Returns
this vector

Definition at line 189 of file JVector3D.hh.

190  {
191  __x /= factor;
192  __y /= factor;
193  __z /= factor;
194 
195  return *this;
196  }

◆ transform()

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

Transform.

Parameters
Tmatrix
Returns
this vector

Definition at line 205 of file JVector3D.hh.

206  {
207  T.transform(__x, __y, __z);
208 
209  return *this;
210  }

◆ equals()

bool JGEOMETRY3D::JVector3D::equals ( const JVector3D vector,
const double  precision = std::numeric_limits<double>::min() 
) const
inline

Check equality.

Parameters
vectorvector
Returns
true if vectors are equal; else false

Definition at line 219 of file JVector3D.hh.

221  {
222  return (fabs(getX() - vector.getX()) <= precision &&
223  fabs(getY() - vector.getY()) <= precision &&
224  fabs(getZ() - vector.getZ()) <= precision);
225  }

◆ getLengthSquared()

double JGEOMETRY3D::JVector3D::getLengthSquared ( ) const
inline

Get length squared.

Returns
square of length

Definition at line 233 of file JVector3D.hh.

234  {
235  return getX()*getX() + getY()*getY() + getZ()*getZ();
236  }

◆ getLength()

double JGEOMETRY3D::JVector3D::getLength ( ) const
inline

Get length.

Returns
length

Definition at line 244 of file JVector3D.hh.

245  {
246  return sqrt(getLengthSquared());
247  }

◆ getDistanceSquared()

double JGEOMETRY3D::JVector3D::getDistanceSquared ( const JVector3D pos) const
inline

Get squared of distance to point.

Parameters
posposition
Returns
square of distance

Definition at line 256 of file JVector3D.hh.

257  {
258  return JVector3D(pos).sub(*this).getLengthSquared();
259  }

◆ getDistance()

double JGEOMETRY3D::JVector3D::getDistance ( const JVector3D pos) const
inline

Get distance to point.

Parameters
posposition
Returns
distance

Definition at line 268 of file JVector3D.hh.

269  {
270  return sqrt(getDistanceSquared(pos));
271  }

◆ getDot()

double JGEOMETRY3D::JVector3D::getDot ( const JVector3D vector) const
inline

Get dot product.

Parameters
vectorvector
Returns
dot product

Definition at line 280 of file JVector3D.hh.

281  {
282  return
283  getX() * vector.getX() +
284  getY() * vector.getY() +
285  getZ() * vector.getZ();
286  }

◆ cross()

JVector3D& JGEOMETRY3D::JVector3D::cross ( const JVector3D first,
const JVector3D second 
)
inline

Get cross product.

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

Parameters
firstfirst vector
secondsecond vector
Returns
this vector

Definition at line 297 of file JVector3D.hh.

299  {
300  __x = first .getY() * second.getZ() - second.getY() * first .getZ();
301  __y = second.getX() * first .getZ() - first .getX() * second.getZ();
302  __z = first .getX() * second.getY() - second.getX() * first .getY();
303 
304  return *this;
305  }

◆ mul() [2/2]

JVector3D & JMATH::JMath< JVector3D , JSecond_t >::mul ( const JSecond_t &  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  }

Member Data Documentation

◆ __x

double JGEOMETRY3D::JVector3D::__x
protected

Definition at line 308 of file JVector3D.hh.

◆ __y

double JGEOMETRY3D::JVector3D::__y
protected

Definition at line 309 of file JVector3D.hh.

◆ __z

double JGEOMETRY3D::JVector3D::__z
protected

Definition at line 310 of file JVector3D.hh.


The documentation for this class was generated from the following file:
JGEOMETRY3D::JVector3D::JVector3D
JVector3D()
Default constructor.
Definition: JVector3D.hh:40
JGEOMETRY3D::JVector3D::__y
double __y
Definition: JVector3D.hh:309
JGEOMETRY3D::JVector3D::getLengthSquared
double getLengthSquared() const
Get length squared.
Definition: JVector3D.hh:233
JGEOMETRY3D::JVector3D::getZ
double getZ() const
Get z position.
Definition: JVector3D.hh:114
JGEOMETRY3D::JVector3D::getDistanceSquared
double getDistanceSquared(const JVector3D &pos) const
Get squared of distance to point.
Definition: JVector3D.hh:256
JGEOMETRY3D::JVector3D::getY
double getY() const
Get y position.
Definition: JVector3D.hh:103
JGEOMETRY3D::JVector3D::__z
double __z
Definition: JVector3D.hh:310
JMATH::JCalculator
Auxiliary class for arithmetic operations on objects.
Definition: JCalculator.hh:18
JGEOMETRY3D::JVector3D::__x
double __x
Definition: JVector3D.hh:308
JGEOMETRY3D::JVector3D::getX
double getX() const
Get x position.
Definition: JVector3D.hh:93