Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 JACOUSTICS::JEmitter JACOUSTICS::JGeometry::JString JACOUSTICS::JReceiver JDETECTOR::JBase 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 JNullType &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

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  {}
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  {}
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

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  }
double getY() const
Get y position.
Definition: JVector3D.hh:103
double getX() const
Get x position.
Definition: JVector3D.hh:93
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  }
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  }
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  }
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  }
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  }
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
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  }
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
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  }
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  }
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  }
do set_variable OUTPUT_DIRECTORY $WORKDIR T
bool JGEOMETRY3D::JVector3D::equals ( const JVector3D vector,
const double  precision = std::numeric_limits<double>::min() 
) const
inline

Check equality.

Parameters
vectorvector
precisionprecision
Returns
true if vectors are equal; else false

Definition at line 220 of file JVector3D.hh.

222  {
223  return (fabs(getX() - vector.getX()) <= precision &&
224  fabs(getY() - vector.getY()) <= precision &&
225  fabs(getZ() - vector.getZ()) <= precision);
226  }
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 JGEOMETRY3D::JVector3D::getLengthSquared ( ) const
inline

Get length squared.

Returns
square of length

Definition at line 234 of file JVector3D.hh.

235  {
236  return getX()*getX() + getY()*getY() + getZ()*getZ();
237  }
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 JGEOMETRY3D::JVector3D::getLength ( ) const
inline

Get length.

Returns
length

Definition at line 245 of file JVector3D.hh.

246  {
247  return sqrt(getLengthSquared());
248  }
double getLengthSquared() const
Get length squared.
Definition: JVector3D.hh:234
double JGEOMETRY3D::JVector3D::getDistanceSquared ( const JVector3D pos) const
inline

Get squared of distance to point.

Parameters
posposition
Returns
square of distance

Definition at line 257 of file JVector3D.hh.

258  {
259  return JVector3D(pos).sub(*this).getLengthSquared();
260  }
JVector3D()
Default constructor.
Definition: JVector3D.hh:40
double JGEOMETRY3D::JVector3D::getDistance ( const JVector3D pos) const
inline

Get distance to point.

Parameters
posposition
Returns
distance

Definition at line 269 of file JVector3D.hh.

270  {
271  return sqrt(getDistanceSquared(pos));
272  }
double getDistanceSquared(const JVector3D &pos) const
Get squared of distance to point.
Definition: JVector3D.hh:257
double JGEOMETRY3D::JVector3D::getDot ( const JVector3D vector) const
inline

Get dot product.

Parameters
vectorvector
Returns
dot product

Definition at line 281 of file JVector3D.hh.

282  {
283  return
284  getX() * vector.getX() +
285  getY() * vector.getY() +
286  getZ() * vector.getZ();
287  }
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
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 298 of file JVector3D.hh.

300  {
301  __x = first .getY() * second.getZ() - second.getY() * first .getZ();
302  __y = second.getX() * first .getZ() - first .getX() * second.getZ();
303  __z = first .getX() * second.getY() - second.getX() * first .getY();
304 
305  return *this;
306  }
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
JVector3D & JMATH::JMath< JVector3D , 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

Member Data Documentation

double JGEOMETRY3D::JVector3D::__x
protected

Definition at line 309 of file JVector3D.hh.

double JGEOMETRY3D::JVector3D::__y
protected

Definition at line 310 of file JVector3D.hh.

double JGEOMETRY3D::JVector3D::__z
protected

Definition at line 311 of file JVector3D.hh.


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