Jpp
Public Member Functions | Protected Attributes | List of all members
JGEOMETRY2D::JEigenValues2D Class Reference

Eigen values in 2D. More...

#include <JEigenValues2D.hh>

Inheritance diagram for JGEOMETRY2D::JEigenValues2D:
JGEOMETRY2D::JVector2D JMATH::JMath< JVector2D >

Public Member Functions

template<class T >
 JEigenValues2D (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...
 
double getX () const
 Get x position. More...
 
double getY () const
 Get y position. More...
 
JVector2Dnegate ()
 Negate vector. More...
 
JVector2Dadd (const JVector2D &vector)
 Add vector. More...
 
JVector2Dsub (const JVector2D &vector)
 Subtract vector. More...
 
JVector2Dmul (const double factor)
 Scale vector. More...
 
JVector2Dmul (const JSecond_t &object)
 Multiply with object. More...
 
JVector2Ddiv (const double factor)
 Scale vector. More...
 
JVector2Dtransform (const JMatrix2D &T)
 Transform. More...
 
bool equals (const JVector2D &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 JVector2D &point) const
 Get squared of distance to point. More...
 
double getDistance (const JVector2D &point) const
 Get distance to point. More...
 
double getDot (const JVector2D &point) const
 Get dot product. More...
 
double getPerpDot (const JVector2D &point) const
 Get perpendicular dot product. More...
 

Protected Attributes

int N
 
double __x
 
double __y
 

Detailed Description

Eigen values in 2D.

Definition at line 24 of file JEigenValues2D.hh.

Constructor & Destructor Documentation

◆ JEigenValues2D()

template<class T >
JGEOMETRY2D::JEigenValues2D::JEigenValues2D ( __begin,
__end 
)
inline

Constructor.

Parameters
__beginbegin of data
__endend of data

Definition at line 35 of file JEigenValues2D.hh.

36  :
37  JVector2D(),
38  N(0)
39  {
40  const JCenter2D center(__begin, __end);
41 
42  // RMS matrix
43 
44  TMatrixDSym A(2);
45 
46  for (int i = 0; i != 2; ++i) {
47  for (int j = 0; j != 2; ++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 
57  A(0,0) += (dx * dx);
58  A(0,1) += (dx * dy);
59 
60  A(1,1) += (dy * dy);
61  }
62 
63  A(1,0) = A(0,1);
64 
65  const TVectorD V = TMatrixDSymEigen(A).GetEigenValues(); // copy!
66 
67  N = V.GetNoElements();
68 
69  switch (N) {
70 
71  case 2:
72  __y = V[1];
73 
74  case 1:
75  __x = V[0];
76  break;
77 
78  default:
79  break;
80  }
81  }

Member Function Documentation

◆ getN() [1/2]

int JGEOMETRY2D::JEigenValues2D::getN ( ) const
inline

Get number of eigen values.

Returns
number of eigen values

Definition at line 89 of file JEigenValues2D.hh.

90  {
91  return N;
92  }

◆ getN() [2/2]

int JGEOMETRY2D::JEigenValues2D::getN ( double  precision) const
inline

Get number of eigen values with minimal value.

Parameters
precisionminimal value
Returns
number of eigen values

Definition at line 101 of file JEigenValues2D.hh.

102  {
103  int n = 0;
104 
105  if (fabs(getX()) >= precision) ++n;
106  if (fabs(getY()) >= precision) ++n;
107 
108  if (n > N)
109  return N;
110  else
111  return n;
112  }

◆ getX()

double JGEOMETRY2D::JVector2D::getX ( ) const
inlineinherited

Get x position.

Returns
x position

Definition at line 62 of file JVector2D.hh.

63  {
64  return __x;
65  }

◆ getY()

double JGEOMETRY2D::JVector2D::getY ( ) const
inlineinherited

Get y position.

Returns
y position

Definition at line 73 of file JVector2D.hh.

74  {
75  return __y;
76  }

◆ negate()

JVector2D& JGEOMETRY2D::JVector2D::negate ( )
inlineinherited

Negate vector.

Returns
this vector

Definition at line 84 of file JVector2D.hh.

85  {
86  __x = -__x;
87  __y = -__y;
88 
89  return *this;
90  }

◆ add()

JVector2D& JGEOMETRY2D::JVector2D::add ( const JVector2D vector)
inlineinherited

Add vector.

Parameters
vectorvector
Returns
this vector

Definition at line 99 of file JVector2D.hh.

100  {
101  __x += vector.getX();
102  __y += vector.getY();
103 
104  return *this;
105  }

◆ sub()

JVector2D& JGEOMETRY2D::JVector2D::sub ( const JVector2D vector)
inlineinherited

Subtract vector.

Parameters
vectorvector
Returns
this vector

Definition at line 114 of file JVector2D.hh.

115  {
116  __x -= vector.getX();
117  __y -= vector.getY();
118 
119  return *this;
120  }

◆ mul() [1/2]

JVector2D& JGEOMETRY2D::JVector2D::mul ( const double  factor)
inlineinherited

Scale vector.

Parameters
factormultiplication factor
Returns
this vector

Definition at line 129 of file JVector2D.hh.

130  {
131  __x *= factor;
132  __y *= factor;
133 
134  return *this;
135  }

◆ mul() [2/2]

JVector2D & JMATH::JMath< JVector2D , 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  }

◆ div()

JVector2D& JGEOMETRY2D::JVector2D::div ( const double  factor)
inlineinherited

Scale vector.

Parameters
factordivision factor
Returns
this vector

Definition at line 144 of file JVector2D.hh.

145  {
146  __x /= factor;
147  __y /= factor;
148 
149  return *this;
150  }

◆ transform()

JVector2D& JGEOMETRY2D::JVector2D::transform ( const JMatrix2D T)
inlineinherited

Transform.

Parameters
Tmatrix
Returns
this vector

Definition at line 159 of file JVector2D.hh.

160  {
161  T.transform(__x, __y);
162 
163  return *this;
164  }

◆ equals()

bool JGEOMETRY2D::JVector2D::equals ( const JVector2D vector,
const double  precision = std::numeric_limits<double>::min() 
) const
inlineinherited

Check equality.

Parameters
vectorvector
Returns
true if vectors are equal; else false

Definition at line 173 of file JVector2D.hh.

175  {
176  return (fabs(getX() - vector.getX()) <= precision &&
177  fabs(getY() - vector.getY()) <= precision);
178  }

◆ getLengthSquared()

double JGEOMETRY2D::JVector2D::getLengthSquared ( ) const
inlineinherited

Get length squared.

Returns
square of length

Definition at line 186 of file JVector2D.hh.

187  {
188  return getX()*getX() + getY()*getY();
189  }

◆ getLength()

double JGEOMETRY2D::JVector2D::getLength ( ) const
inlineinherited

Get length.

Returns
length

Definition at line 197 of file JVector2D.hh.

198  {
199  return sqrt(getLengthSquared());
200  }

◆ getDistanceSquared()

double JGEOMETRY2D::JVector2D::getDistanceSquared ( const JVector2D point) const
inlineinherited

Get squared of distance to point.

Parameters
pointpoint
Returns
square of distance

Definition at line 209 of file JVector2D.hh.

210  {
211  return JVector2D(point).sub(*this).getLengthSquared();
212  }

◆ getDistance()

double JGEOMETRY2D::JVector2D::getDistance ( const JVector2D point) const
inlineinherited

Get distance to point.

Parameters
pointpoint
Returns
distance

Definition at line 221 of file JVector2D.hh.

222  {
223  return sqrt(getDistanceSquared(point));
224  }

◆ getDot()

double JGEOMETRY2D::JVector2D::getDot ( const JVector2D point) const
inlineinherited

Get dot product.

Parameters
pointvector
Returns
dot product

Definition at line 233 of file JVector2D.hh.

234  {
235  return
236  getX() * point.getX() +
237  getY() * point.getY();
238  }

◆ getPerpDot()

double JGEOMETRY2D::JVector2D::getPerpDot ( const JVector2D point) const
inlineinherited

Get perpendicular dot product.

Parameters
pointvector
Returns
perpendicular dot product

Definition at line 247 of file JVector2D.hh.

248  {
249  return
250  getX() * point.getY() -
251  getY() * point.getX();
252  }

Member Data Documentation

◆ N

int JGEOMETRY2D::JEigenValues2D::N
protected

Definition at line 116 of file JEigenValues2D.hh.

◆ __x

double JGEOMETRY2D::JVector2D::__x
protectedinherited

Definition at line 255 of file JVector2D.hh.

◆ __y

double JGEOMETRY2D::JVector2D::__y
protectedinherited

Definition at line 256 of file JVector2D.hh.


The documentation for this class was generated from the following file:
JGEOMETRY2D::JEigenValues2D::N
int N
Definition: JEigenValues2D.hh:116
JGEOMETRY2D::JVector2D::getLengthSquared
double getLengthSquared() const
Get length squared.
Definition: JVector2D.hh:186
JTOOLS::n
const int n
Definition: JPolint.hh:628
JTOOLS::j
int j
Definition: JPolint.hh:634
JGEOMETRY2D::JVector2D::getDistanceSquared
double getDistanceSquared(const JVector2D &point) const
Get squared of distance to point.
Definition: JVector2D.hh:209
JGEOMETRY2D::JVector2D::__x
double __x
Definition: JVector2D.hh:255
JGEOMETRY2D::JCenter2D
Center.
Definition: JGeometry2DToolkit.hh:52
JGEOMETRY2D::JVector2D::JVector2D
JVector2D()
Default constructor.
Definition: JVector2D.hh:38
JGEOMETRY2D::JVector2D::getX
double getX() const
Get x position.
Definition: JVector2D.hh:62
JMATH::JCalculator
Auxiliary class for arithmetic operations on objects.
Definition: JCalculator.hh:18
JGEOMETRY2D::JVector2D::getY
double getY() const
Get y position.
Definition: JVector2D.hh:73
JGEOMETRY2D::JVector2D::__y
double __y
Definition: JVector2D.hh:256