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

Center. More...

#include <JGeometry2DToolkit.hh>

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

Public Member Functions

 JCenter2D (const JVector2D &p0, const JVector2D &p1)
 Constructor. More...
 
 JCenter2D (const JVector2D &p0, const JVector2D &p1, const JVector2D &p2)
 Constructor. More...
 
template<class T >
 JCenter2D (T __begin, T __end)
 Constructor. 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

double __x
 
double __y
 

Detailed Description

Center.

Definition at line 52 of file JGeometry2DToolkit.hh.

Constructor & Destructor Documentation

◆ JCenter2D() [1/3]

JGEOMETRY2D::JCenter2D::JCenter2D ( const JVector2D p0,
const JVector2D p1 
)
inline

Constructor.

Parameters
p0first point
p1second point

Definition at line 62 of file JGeometry2DToolkit.hh.

63  :
64  JVector2D()
65  {
66  add(p0);
67  add(p1);
68 
69  div(2);
70  }

◆ JCenter2D() [2/3]

JGEOMETRY2D::JCenter2D::JCenter2D ( const JVector2D p0,
const JVector2D p1,
const JVector2D p2 
)
inline

Constructor.

Parameters
p0first point
p1second point
p2third point

Definition at line 80 of file JGeometry2DToolkit.hh.

82  :
83  JVector2D()
84  {
85  add(p0);
86  add(p1);
87  add(p2);
88 
89  div(3);
90  }

◆ JCenter2D() [3/3]

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

Constructor.

Parameters
__beginbegin of data
__endend of data

Definition at line 100 of file JGeometry2DToolkit.hh.

101  :
102  JVector2D()
103  {
104  if (__begin != __end) {
105 
106  for (T i = __begin; i != __end; ++i) {
107  add(*i);
108  }
109 
110  div(std::distance(__begin, __end));
111  }
112  }

Member Function Documentation

◆ 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
precisionprecision
Returns
true if vectors are equal; else false

Definition at line 174 of file JVector2D.hh.

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

◆ getLengthSquared()

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

Get length squared.

Returns
square of length

Definition at line 187 of file JVector2D.hh.

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

◆ getLength()

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

Get length.

Returns
length

Definition at line 198 of file JVector2D.hh.

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

◆ 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 210 of file JVector2D.hh.

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

◆ getDistance()

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

Get distance to point.

Parameters
pointpoint
Returns
distance

Definition at line 222 of file JVector2D.hh.

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

◆ getDot()

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

Get dot product.

Parameters
pointvector
Returns
dot product

Definition at line 234 of file JVector2D.hh.

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

◆ getPerpDot()

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

Get perpendicular dot product.

Parameters
pointvector
Returns
perpendicular dot product

Definition at line 248 of file JVector2D.hh.

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

Member Data Documentation

◆ __x

double JGEOMETRY2D::JVector2D::__x
protectedinherited

Definition at line 256 of file JVector2D.hh.

◆ __y

double JGEOMETRY2D::JVector2D::__y
protectedinherited

Definition at line 257 of file JVector2D.hh.


The documentation for this class was generated from the following file:
JGEOMETRY2D::JVector2D::div
JVector2D & div(const double factor)
Scale vector.
Definition: JVector2D.hh:144
JGEOMETRY2D::JVector2D::getLengthSquared
double getLengthSquared() const
Get length squared.
Definition: JVector2D.hh:187
distance
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Definition: PhysicsEvent.hh:434
JGEOMETRY2D::JVector2D::add
JVector2D & add(const JVector2D &vector)
Add vector.
Definition: JVector2D.hh:99
JGEOMETRY2D::JVector2D::getDistanceSquared
double getDistanceSquared(const JVector2D &point) const
Get squared of distance to point.
Definition: JVector2D.hh:210
JGEOMETRY2D::JVector2D::__x
double __x
Definition: JVector2D.hh:256
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
p1
TPaveText * p1
Definition: JDrawModule3D.cc:35
JGEOMETRY2D::JVector2D::getY
double getY() const
Get y position.
Definition: JVector2D.hh:73
JGEOMETRY2D::JVector2D::__y
double __y
Definition: JVector2D.hh:257