Example program to find smallest distance between two points.  
More...
#include <string>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <vector>
#include "TRandom3.h"
#include "JGeometry3D/JVector3D.hh"
#include "JGeometry3D/JGeometry3DToolkit.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JTimer.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
 
Go to the source code of this file.
 | 
| int  | main (int argc, char *argv[]) | 
|   | 
Example program to find smallest distance between two points. 
- Author
 - mdejong 
 
Definition in file JGetSmallestDistance3D.cc.
 
◆ main()
      
        
          | int main  | 
          ( | 
          int  | 
          argc,  | 
        
        
           | 
           | 
          char *  | 
          argv[]  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Definition at line 25 of file JGetSmallestDistance3D.cc.
   37     JParser<> zap(
"Example program to find smallest distance between two points.");
 
   47   catch(
const exception &error) {
 
   48     FATAL(error.what() << endl);
 
   51   gRandom->SetSeed(seed);
 
   61   if (inputFile != 
"") {
 
   63     ifstream in(inputFile.c_str());
 
   65     for (
double x, 
y, z; in >> 
x >> 
y >> z; ) {
 
   73     NOTICE(
"Seed: " << gRandom->GetSeed() << endl);
 
   77       buffer.push_back(
JVector3D(gRandom->Uniform(-1.0, +1.0),
 
   78                                  gRandom->Uniform(-1.0, +1.0),
 
   79                                  gRandom->Uniform(-1.0, +1.0)));
 
   86       for (const_iterator i = buffer.begin(); i != buffer.end(); ++i)
 
   87         out << setw(7) << i->getX() << 
' '  
   88             << setw(7) << i->getX() << 
' '  
   89             << setw(7) << i->getZ() << endl;
 
   95   if (buffer.size() < 2) {
 
   96     FATAL(
"Not enough points." << endl);
 
   99   for (const_iterator i = buffer.begin(); i != buffer.end(); ++i) {
 
  100     DEBUG(i->getX() << 
' ' << i->getY() << 
' ' << i->getZ() << endl);
 
  109     double dmin = numeric_limits<double>::max();
 
  111     for (const_iterator i = buffer.begin(); i != buffer.end(); ++i) {
 
  112       for (const_iterator 
j = i; ++
j != buffer.end(); ) {
 
  114         const double d = i->getDistance(*
j);
 
  124     cout << 
"Minimal distance " << 
SCIENTIFIC(12,5) << dmin << endl;
 
  129   JTimer timer(
"O(n log(n))");
 
  137   cout << 
"Minimal distance " << 
SCIENTIFIC(12,5) << dmin << endl;
 
#define DEBUG(A)
Message macros.
 
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
 
Auxiliary class for CPU timing and usage.
 
Data structure for vector in three dimensions.
 
Utility class to parse command line options.
 
static const JSmallestDistance3D getSmallestDistance3D
Function object for smallest distance determination.
 
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
 
Auxiliary data structure for floating point format specification.