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 130 of file JGeometry3DToolkit.hh.

Constructor & Destructor Documentation

◆ JSmallestDistance3D()

JGEOMETRY3D::JSmallestDistance3D::JSmallestDistance3D ( )
inline

Default constructor.

Definition at line 212 of file JGeometry3DToolkit.hh.

213  {}

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 140 of file JGeometry3DToolkit.hh.

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

◆ 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 228 of file JGeometry3DToolkit.hh.

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

Member Data Documentation

◆ compareZ

const JCompareZ JGEOMETRY3D::JSmallestDistance3D::compareZ
static

Function object for sorting elements.

Definition at line 216 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:216
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:140
std
Definition: jaanetDictionary.h:36
JGEOMETRY2D::getSmallestDistance2D
static const JSmallestDistance2D getSmallestDistance2D
Function object for smallest distance determination.
Definition: JGeometry2DToolkit.hh:660