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

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

#include <JVector3D.hh>

Inheritance diagram for JGEOMETRY3D::JVector3D:
JMATH::JMath< JFirst_t, JSecond_t > JGEOMETRY3D::JPosition3D JACOUSTICS::JEmitter JACOUSTICS::JGEOMETRY::JDetector::module_type JACOUSTICS::JGEOMETRY::JString JACOUSTICS::JReceiver JACOUSTICS::hit_type JACOUSTICS::hit_type JDETECTOR::JHydrophone JDETECTOR::JModule JDETECTOR::JModuleGeometry JDETECTOR::JModulePosition_t JDETECTOR::JTransmitter JFIT::JPoint3D JGEOMETRY3D::JAxis3D JGEOMETRY3D::JCenter3D JGEOMETRY3D::JSphere3D JGEOMETRY3D::JTransformation3D JGEOMETRY3D::JVertex3D JGEOMETRY3D::JWeighedCenter3D JSIRENE::JPoint JTRIGGER::JHitR1 JTRIGGER::JModuleHeader

Public Member Functions

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

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 34 of file JVector3D.hh.

Constructor & Destructor Documentation

◆ JVector3D() [1/3]

JGEOMETRY3D::JVector3D::JVector3D ( )
inline

Default constructor.

Definition at line 41 of file JVector3D.hh.

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

◆ 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 55 of file JVector3D.hh.

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

◆ JVector3D() [3/3]

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

Constructor.

Parameters
vector(x,y) values
zz value

Definition at line 70 of file JVector3D.hh.

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

Member Function Documentation

◆ operator JVector2D()

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

Type conversion operator.

Returns
JVector2D

Definition at line 83 of file JVector3D.hh.

84 {
85 return JVector2D(this->getX(), this->getY());
86 }
double getY() const
Get y position.
Definition JVector3D.hh:104
double getX() const
Get x position.
Definition JVector3D.hh:94

◆ getX()

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

Get x position.

Returns
x position

Definition at line 94 of file JVector3D.hh.

95 {
96 return __x;
97 }

◆ getY()

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

Get y position.

Returns
y position

Definition at line 104 of file JVector3D.hh.

105 {
106 return __y;
107 }

◆ getZ()

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

Get z position.

Returns
z position

Definition at line 115 of file JVector3D.hh.

116 {
117 return __z;
118 }

◆ negate()

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

Negate vector.

Returns
this vector

Definition at line 126 of file JVector3D.hh.

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

◆ add()

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

Add vector.

Parameters
vectorvector
Returns
this vector

Definition at line 142 of file JVector3D.hh.

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

◆ sub()

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

Subtract vector.

Parameters
vectorvector
Returns
this vector

Definition at line 158 of file JVector3D.hh.

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

◆ mul() [1/2]

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

Scale vector.

Parameters
factormultiplication factor
Returns
this vector

Definition at line 174 of file JVector3D.hh.

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

◆ div()

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

Scale vector.

Parameters
factordivision factor
Returns
this vector

Definition at line 190 of file JVector3D.hh.

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

◆ transform()

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

Transform.

Parameters
Tmatrix
Returns
this vector

Definition at line 206 of file JVector3D.hh.

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

◆ equals()

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 221 of file JVector3D.hh.

223 {
224 return (fabs(getX() - vector.getX()) <= precision &&
225 fabs(getY() - vector.getY()) <= precision &&
226 fabs(getZ() - vector.getZ()) <= precision);
227 }
double getZ() const
Get z position.
Definition JVector3D.hh:115

◆ getLengthSquared()

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

Get length squared.

Returns
square of length

Definition at line 235 of file JVector3D.hh.

236 {
237 return getX()*getX() + getY()*getY() + getZ()*getZ();
238 }

◆ getLength()

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

Get length.

Returns
length

Definition at line 246 of file JVector3D.hh.

247 {
248 return sqrt(getLengthSquared());
249 }
double getLengthSquared() const
Get length squared.
Definition JVector3D.hh:235

◆ 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 258 of file JVector3D.hh.

259 {
260 return JVector3D(pos).sub(*this).getLengthSquared();
261 }
JVector3D()
Default constructor.
Definition JVector3D.hh:41

◆ getDistance()

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

Get distance to point.

Parameters
posposition
Returns
distance

Definition at line 270 of file JVector3D.hh.

271 {
272 return sqrt(getDistanceSquared(pos));
273 }
double getDistanceSquared(const JVector3D &pos) const
Get squared of distance to point.
Definition JVector3D.hh:258

◆ getDot()

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

Get dot product.

Parameters
vectorvector
Returns
dot product

Definition at line 282 of file JVector3D.hh.

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

◆ getCross()

JVector3D & JGEOMETRY3D::JVector3D::getCross ( 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 299 of file JVector3D.hh.

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

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

Member Data Documentation

◆ __x

double JGEOMETRY3D::JVector3D::__x
protected

Definition at line 310 of file JVector3D.hh.

◆ __y

double JGEOMETRY3D::JVector3D::__y
protected

Definition at line 311 of file JVector3D.hh.

◆ __z

double JGEOMETRY3D::JVector3D::__z
protected

Definition at line 312 of file JVector3D.hh.


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