Jpp
Classes | Public Member Functions | Static Public Attributes | Static Protected Member Functions | List of all members
JGEOMETRY3D::JSmallestDistance3D Class Reference

Auxiliary class for determination of smallest distance between pair of 3D points. More...

#include <JGeometry3DToolkit.hh>

Classes

struct  JCompareZ
 Auxiliary class for sorting elements. More...
 

Public Member Functions

 JSmallestDistance3D ()
 Default constructor. More...
 
template<class T >
double operator() (T __begin, T __end) const
 Get smallest distance between two points. More...
 

Static Public Attributes

static const JCompareZ compareZ
 Function object for sorting elements. More...
 

Static Protected Member Functions

template<class T >
static double getDmin (T __begin, T __end)
 Recursive method to find the smallest distance. More...
 

Detailed Description

Auxiliary class for determination of smallest distance between pair of 3D points.

Definition at line 131 of file JGeometry3DToolkit.hh.

Constructor & Destructor Documentation

◆ JSmallestDistance3D()

JGEOMETRY3D::JSmallestDistance3D::JSmallestDistance3D ( )
inline

Default constructor.

Definition at line 213 of file JGeometry3DToolkit.hh.

214  {}

Member Function Documentation

◆ getDmin()

template<class T >
static double JGEOMETRY3D::JSmallestDistance3D::getDmin ( __begin,
__end 
)
inlinestaticprotected

Recursive method to find the smallest distance.

Parameters
__beginbegin of data
__endend of data
Returns
minimal distance

Definition at line 141 of file JGeometry3DToolkit.hh.

142  {
143  using namespace std;
144 
145  const int N = distance(__begin, __end);
146 
147  if (N <= 3) {
148 
149  double Dmin = numeric_limits<double>::max();
150 
151  for (T i = __begin; i != __end; ++i) {
152  for (T j = i; ++j != __end; ) {
153 
154  const double d = getDistance(*i, *j);
155 
156  if (d < Dmin) {
157  Dmin = d;
158  }
159  }
160  }
161 
162  return Dmin;
163 
164  } else {
165 
166  T i = __begin;
167 
168  advance(i, N/2);
169 
170  const double dl = getDmin(__begin, i);
171  const double dr = getDmin(i, __end);
172 
173  const double Dmin = min(dl, dr);
174 
175  T il = i;
176  T ir = i;
177 
178  while (--il != __begin && i ->getZ() - il->getZ() < Dmin) {}
179  while (++ir != __end && ir->getZ() - i ->getZ() < Dmin) {}
180 
181  const double dz = JGEOMETRY2D::getSmallestDistance2D(++il, ir, Dmin);
182 
183  sort(il, ir, compareZ);
184 
185  return min(Dmin, dz);
186  }
187  }

◆ operator()()

template<class T >
double JGEOMETRY3D::JSmallestDistance3D::operator() ( __begin,
__end 
) const
inline

Get smallest distance between two points.


Note that this method changes the order of the elements.

Parameters
__beginbegin of data
__endend of data
Returns
minimal distance

Definition at line 229 of file JGeometry3DToolkit.hh.

230  {
231  using namespace std;
232 
233  sort(__begin, __end, compareZ);
234 
235  return getDmin(__begin, __end);
236  }

Member Data Documentation

◆ compareZ

const JCompareZ JGEOMETRY3D::JSmallestDistance3D::compareZ
static

Function object for sorting elements.

Definition at line 217 of file JGeometry3DToolkit.hh.


The documentation for this class was generated from the following file:
JROOT::advance
counter_type advance(counter_type &counter, const counter_type value, const counter_type limit=std::numeric_limits< counter_type >::max())
Advance counter.
Definition: JCounter.hh:35
JTOOLS::j
int j
Definition: JPolint.hh:634
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
JGEOMETRY3D::JSmallestDistance3D::compareZ
static const JCompareZ compareZ
Function object for sorting elements.
Definition: JGeometry3DToolkit.hh:217
JMATH::getDistance
double getDistance(const JFirst_t &first, const JSecond_t &second)
Get distance between objects.
Definition: JMathToolkit.hh:116
JGEOMETRY3D::JSmallestDistance3D::getDmin
static double getDmin(T __begin, T __end)
Recursive method to find the smallest distance.
Definition: JGeometry3DToolkit.hh:141
std
Definition: jaanetDictionary.h:36
JGEOMETRY2D::getSmallestDistance2D
static const JSmallestDistance2D getSmallestDistance2D
Function object for smallest distance determination.
Definition: JGeometry2DToolkit.hh:660