Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Attributes | List of all members
JGEOMETRY3D::JEigenValues3D Class Reference

Eigen values in 3D. More...

#include <JEigenValues3D.hh>

Inheritance diagram for JGEOMETRY3D::JEigenValues3D:
JGEOMETRY3D::JVector3D JMATH::JMath< JVector3D >

Public Member Functions

template<class T >
 JEigenValues3D (T __begin, T __end)
 Constructor. More...
 
int getN () const
 Get number of eigen values. More...
 
int getN (double precision) const
 Get number of eigen values with minimal value. 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...
 
JVector3Dmul (const JNullType &object)
 Multiply with object. 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...
 

Protected Attributes

int N
 
double __x
 
double __y
 
double __z
 

Detailed Description

Eigen values in 3D.

Definition at line 24 of file JEigenValues3D.hh.

Constructor & Destructor Documentation

template<class T >
JGEOMETRY3D::JEigenValues3D::JEigenValues3D ( T  __begin,
T  __end 
)
inline

Constructor.

Parameters
__beginbegin of data
__endend of data

Definition at line 35 of file JEigenValues3D.hh.

36  :
37  JVector3D(),
38  N(0)
39  {
40  const JCenter3D center(__begin, __end);
41 
42  // RMS matrix
43 
44  TMatrixDSym A(3);
45 
46  for (int i = 0; i != 3; ++i) {
47  for (int j = 0; j != 3; ++j) {
48  A(i,j) = 0.0;
49  }
50  }
51 
52  for (T i = __begin; i != __end; ++i) {
53 
54  const double dx = center.getX() - i->getX();
55  const double dy = center.getY() - i->getY();
56  const double dz = center.getZ() - i->getZ();
57 
58  A(0,0) += (dx * dx);
59  A(0,1) += (dx * dy);
60  A(0,2) += (dx * dz);
61 
62  A(1,1) += (dy * dy);
63  A(1,2) += (dy * dz);
64 
65  A(2,2) += (dz * dz);
66  }
67 
68  A(1,0) = A(0,1);
69  A(2,0) = A(0,2);
70  A(2,1) = A(1,2);
71 
72  const TVectorD V = TMatrixDSymEigen(A).GetEigenValues(); // copy!
73 
74  N = V.GetNoElements();
75 
76  switch (N) {
77 
78  case 3:
79  __z = V[2];
80 
81  case 2:
82  __y = V[1];
83 
84  case 1:
85  __x = V[0];
86  break;
87 
88  default:
89  break;
90  }
91  }
do set_variable OUTPUT_DIRECTORY $WORKDIR T
int j
Definition: JPolint.hh:634
source $JPP_DIR setenv csh $JPP_DIR eval JShellParser o a A
JVector3D()
Default constructor.
Definition: JVector3D.hh:40

Member Function Documentation

int JGEOMETRY3D::JEigenValues3D::getN ( ) const
inline

Get number of eigen values.

Returns
number of eigen values

Definition at line 99 of file JEigenValues3D.hh.

100  {
101  return N;
102  }
int JGEOMETRY3D::JEigenValues3D::getN ( double  precision) const
inline

Get number of eigen values with minimal value.

Parameters
precisionminimal value
Returns
number of eigen values

Definition at line 111 of file JEigenValues3D.hh.

112  {
113  int n = 0;
114 
115  if (fabs(getX()) >= precision) ++n;
116  if (fabs(getY()) >= precision) ++n;
117  if (fabs(getZ()) >= precision) ++n;
118 
119  if (n > N)
120  return N;
121  else
122  return n;
123  }
double getY() const
Get y position.
Definition: JVector3D.hh:103
alias put_queue eval echo n
Definition: qlib.csh:19
double getX() const
Get x position.
Definition: JVector3D.hh:93
double getZ() const
Get z position.
Definition: JVector3D.hh:114
JGEOMETRY3D::JVector3D::operator JVector2D ( ) const
inlineinherited

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
inlineinherited

Get x position.

Returns
x position

Definition at line 93 of file JVector3D.hh.

94  {
95  return __x;
96  }
double JGEOMETRY3D::JVector3D::getY ( ) const
inlineinherited

Get y position.

Returns
y position

Definition at line 103 of file JVector3D.hh.

104  {
105  return __y;
106  }
double JGEOMETRY3D::JVector3D::getZ ( ) const
inlineinherited

Get z position.

Returns
z position

Definition at line 114 of file JVector3D.hh.

115  {
116  return __z;
117  }
JVector3D& JGEOMETRY3D::JVector3D::negate ( )
inlineinherited

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)
inlineinherited

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)
inlineinherited

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)
inlineinherited

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 & 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
JVector3D& JGEOMETRY3D::JVector3D::div ( const double  factor)
inlineinherited

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)
inlineinherited

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
inlineinherited

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
inlineinherited

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
inlineinherited

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
inlineinherited

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
inlineinherited

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
inlineinherited

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 
)
inlineinherited

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

Member Data Documentation

int JGEOMETRY3D::JEigenValues3D::N
protected

Definition at line 126 of file JEigenValues3D.hh.

double JGEOMETRY3D::JVector3D::__x
protectedinherited

Definition at line 309 of file JVector3D.hh.

double JGEOMETRY3D::JVector3D::__y
protectedinherited

Definition at line 310 of file JVector3D.hh.

double JGEOMETRY3D::JVector3D::__z
protectedinherited

Definition at line 311 of file JVector3D.hh.


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