Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
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.
 
template<class T >
double operator() (T __begin, T __end) const
 Get smallest distance between two points.
 

Static Public Attributes

static const JCompareZ compareZ
 Function object for sorting elements.
 

Static Protected Member Functions

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

Detailed Description

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

Definition at line 134 of file JGeometry3DToolkit.hh.

Constructor & Destructor Documentation

◆ JSmallestDistance3D()

JGEOMETRY3D::JSmallestDistance3D::JSmallestDistance3D ( )
inline

Default constructor.

Definition at line 216 of file JGeometry3DToolkit.hh.

217 {}

Member Function Documentation

◆ getDmin()

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

Recursive method to find the smallest distance.

Parameters
__beginbegin of data
__endend of data
Returns
minimal distance

Definition at line 144 of file JGeometry3DToolkit.hh.

145 {
146 using namespace std;
147
148 const int N = distance(__begin, __end);
149
150 if (N <= 3) {
151
152 double Dmin = numeric_limits<double>::max();
153
154 for (T i = __begin; i != __end; ++i) {
155 for (T j = i; ++j != __end; ) {
156
157 const double d = getDistance(*i, *j);
158
159 if (d < Dmin) {
160 Dmin = d;
161 }
162 }
163 }
164
165 return Dmin;
166
167 } else {
168
169 T i = __begin;
170
171 advance(i, N/2);
172
173 const double dl = getDmin(__begin, i);
174 const double dr = getDmin(i, __end);
175
176 const double Dmin = min(dl, dr);
177
178 T il = i;
179 T ir = i;
180
181 while (--il != __begin && i ->getZ() - il->getZ() < Dmin) {}
182 while (++ir != __end && ir->getZ() - i ->getZ() < Dmin) {}
183
184 const double dz = JGEOMETRY2D::getSmallestDistance2D(++il, ir, Dmin);
185
186 sort(il, ir, compareZ);
187
188 return min(Dmin, dz);
189 }
190 }
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
static const JCompareZ compareZ
Function object for sorting elements.
static double getDmin(T __begin, T __end)
Recursive method to find the smallest distance.
static const JSmallestDistance2D getSmallestDistance2D
Function object for smallest distance determination.
counter_type advance(counter_type &counter, const counter_type value, const counter_type limit=std::numeric_limits< counter_type >::max())
Advance counter.
int j
Definition JPolint.hh:801

◆ operator()()

template<class T >
double JGEOMETRY3D::JSmallestDistance3D::operator() ( T __begin,
T __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 232 of file JGeometry3DToolkit.hh.

233 {
234 using namespace std;
235
236 sort(__begin, __end, compareZ);
237
238 return getDmin(__begin, __end);
239 }

Member Data Documentation

◆ compareZ

const JCompareZ JGEOMETRY3D::JSmallestDistance3D::compareZ
static

Function object for sorting elements.

Definition at line 220 of file JGeometry3DToolkit.hh.


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