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 JDETECTOR::JModule JDETECTOR::JModuleGeometry 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
 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 32 of file JVector3D.hh.

Constructor & Destructor Documentation

JGEOMETRY3D::JVector3D::JVector3D ( )
inline

Default constructor.

Definition at line 39 of file JVector3D.hh.

39  :
40  __x(0.0),
41  __y(0.0),
42  __z(0.0)
43  {}
JGEOMETRY3D::JVector3D::JVector3D ( const double  x,
const double  y,
const double  z 
)
inline

Constructor.

Parameters
xx value
yy value
zz value

Definition at line 53 of file JVector3D.hh.

55  :
56  __x(x),
57  __y(y),
58  __z(z)
59  {}
JGEOMETRY3D::JVector3D::JVector3D ( const JVector2D vector,
const double  z 
)
inline

Constructor.

Parameters
vector(x,y) values
zz value

Definition at line 68 of file JVector3D.hh.

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

Member Function Documentation

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

Type conversion operator.

Returns
JVector2D

Definition at line 81 of file JVector3D.hh.

82  {
83  return JVector2D(this->getX(), this->getY());
84  }
double getY() const
Get y position.
Definition: JVector3D.hh:102
double getX() const
Get x position.
Definition: JVector3D.hh:92
double JGEOMETRY3D::JVector3D::getX ( ) const
inline

Get x position.

Returns
x position

Definition at line 92 of file JVector3D.hh.

93  {
94  return __x;
95  }
double JGEOMETRY3D::JVector3D::getY ( ) const
inline

Get y position.

Returns
y position

Definition at line 102 of file JVector3D.hh.

103  {
104  return __y;
105  }
double JGEOMETRY3D::JVector3D::getZ ( ) const
inline

Get z position.

Returns
z position

Definition at line 113 of file JVector3D.hh.

114  {
115  return __z;
116  }
JVector3D& JGEOMETRY3D::JVector3D::negate ( )
inline

Negate vector.

Returns
this vector

Definition at line 124 of file JVector3D.hh.

125  {
126  __x = -__x;
127  __y = -__y;
128  __z = -__z;
129 
130  return *this;
131  }
JVector3D& JGEOMETRY3D::JVector3D::add ( const JVector3D vector)
inline

Add vector.

Parameters
vectorvector
Returns
this vector

Definition at line 140 of file JVector3D.hh.

141  {
142  __x += vector.getX();
143  __y += vector.getY();
144  __z += vector.getZ();
145 
146  return *this;
147  }
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
JVector3D& JGEOMETRY3D::JVector3D::sub ( const JVector3D vector)
inline

Subtract vector.

Parameters
vectorvector
Returns
this vector

Definition at line 156 of file JVector3D.hh.

157  {
158  __x -= vector.getX();
159  __y -= vector.getY();
160  __z -= vector.getZ();
161 
162  return *this;
163  }
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
JVector3D& JGEOMETRY3D::JVector3D::mul ( const double  factor)
inline

Scale vector.

Parameters
factormultiplication factor
Returns
this vector

Definition at line 172 of file JVector3D.hh.

173  {
174  __x *= factor;
175  __y *= factor;
176  __z *= factor;
177 
178  return *this;
179  }
JVector3D& JGEOMETRY3D::JVector3D::div ( const double  factor)
inline

Scale vector.

Parameters
factordivision factor
Returns
this vector

Definition at line 188 of file JVector3D.hh.

189  {
190  __x /= factor;
191  __y /= factor;
192  __z /= factor;
193 
194  return *this;
195  }
JVector3D& JGEOMETRY3D::JVector3D::transform ( const JMatrix3D T)
inline

Transform.

Parameters
Tmatrix
Returns
this vector

Definition at line 204 of file JVector3D.hh.

205  {
206  T.transform(__x, __y, __z);
207 
208  return *this;
209  }
bool JGEOMETRY3D::JVector3D::equals ( const JVector3D vector) const
inline

Check equality.

Parameters
vectorvector
Returns
true if vectors are equal; else false

Definition at line 218 of file JVector3D.hh.

219  {
220  return (getX() == vector.getX() &&
221  getY() == vector.getY() &&
222  getZ() == vector.getZ());
223  }
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 JGEOMETRY3D::JVector3D::getLengthSquared ( ) const
inline

Get length squared.

Returns
square of length

Definition at line 231 of file JVector3D.hh.

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

Get length.

Returns
length

Definition at line 242 of file JVector3D.hh.

243  {
244  return sqrt(getLengthSquared());
245  }
double getLengthSquared() const
Get length squared.
Definition: JVector3D.hh:231
double JGEOMETRY3D::JVector3D::getDistanceSquared ( const JVector3D pos) const
inline

Get squared of distance to point.

Parameters
posposition
Returns
square of distance

Definition at line 254 of file JVector3D.hh.

255  {
256  return JVector3D(pos).sub(*this).getLengthSquared();
257  }
JVector3D()
Default constructor.
Definition: JVector3D.hh:39
double JGEOMETRY3D::JVector3D::getDistance ( const JVector3D pos) const
inline

Get distance to point.

Parameters
posposition
Returns
distance

Definition at line 266 of file JVector3D.hh.

267  {
268  return sqrt(getDistanceSquared(pos));
269  }
double getDistanceSquared(const JVector3D &pos) const
Get squared of distance to point.
Definition: JVector3D.hh:254
double JGEOMETRY3D::JVector3D::getDot ( const JVector3D vector) const
inline

Get dot product.

Parameters
vectorvector
Returns
dot product

Definition at line 278 of file JVector3D.hh.

279  {
280  return
281  getX() * vector.getX() +
282  getY() * vector.getY() +
283  getZ() * vector.getZ();
284  }
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
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 295 of file JVector3D.hh.

297  {
298  __x = first .getY() * second.getZ() - second.getY() * first .getZ();
299  __y = second.getX() * first .getZ() - first .getX() * second.getZ();
300  __z = first .getX() * second.getY() - second.getX() * first .getY();
301 
302  return *this;
303  }
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
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 product evaluation of objects.
Definition: JCalculator.hh:18

Member Data Documentation

double JGEOMETRY3D::JVector3D::__x
protected

Definition at line 306 of file JVector3D.hh.

double JGEOMETRY3D::JVector3D::__y
protected

Definition at line 307 of file JVector3D.hh.

double JGEOMETRY3D::JVector3D::__z
protected

Definition at line 308 of file JVector3D.hh.


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