14 #include "TApplication.h" 
   31 int main(
int argc, 
char* argv[])
 
   43     JParser<> zap(
"Example program to find smallest distance between two points.");
 
   53   catch(
const exception &error) {
 
   54     FATAL(error.what() << endl);
 
   57   gRandom->SetSeed(seed);
 
   67   if (inputFile != 
"") {
 
   69     ifstream in(inputFile.c_str());
 
   71     for (
double x, 
y; in >> 
x >> 
y; ) {
 
   79     NOTICE(
"Seed: " << gRandom->GetSeed() << endl);
 
   83       buffer.push_back(
JVector2D(gRandom->Uniform(-1.0, +1.0),
 
   84                                  gRandom->Uniform(-1.0, +1.0)));
 
   91       for (const_iterator i = buffer.begin(); i != buffer.end(); ++i)
 
   92         out << setw(7) << i->getX() << 
' '  
   93             << setw(7) << i->getY() << endl;
 
   99   if (buffer.size() < 2) {
 
  100     FATAL(
"Not enough points." << endl);
 
  103   for (const_iterator i = buffer.begin(); i != buffer.end(); ++i) {
 
  104     DEBUG(i->getX() << 
' ' << i->getY() << endl);
 
  113     double dmin = numeric_limits<double>::max();
 
  115     for (const_iterator i = buffer.begin(); i != buffer.end(); ++i) {
 
  116       for (const_iterator 
j = i; ++
j != buffer.end(); ) {
 
  118         const double d = i->getDistance(*
j);
 
  128     cout << 
"Minimal distance " << 
SCIENTIFIC(12,5) << dmin << endl;
 
  133   JTimer timer(
"O(n log(n))");
 
  141   cout << 
"Minimal distance " << 
SCIENTIFIC(12,5) << dmin << endl;
 
  149        << 
"(" << 
FIXED(7,5) << 
result.second->getX() << 
"," << 
FIXED(7,5) << 
result.second->getY() << 
")" << endl; 
 
  153   TApplication* tp = 
new TApplication(
"user", NULL, NULL);
 
  155   TCanvas cv(
"cv", 
"", 400, 400);
 
  157   cv.SetFillStyle(4000);
 
  164   const Int_t MAX_BUFFER_SIZE = buffer.size() + 1;
 
  166   Double_t  
x[MAX_BUFFER_SIZE];
 
  167   Double_t  
y[MAX_BUFFER_SIZE];
 
  171   for (const_iterator i = buffer.begin(); i != buffer.end(); ++i, ++N) {
 
  177   Double_t 
xmin = -1.1;
 
  178   Double_t 
xmax = +1.1;
 
  179   Double_t ymin = -1.1;
 
  180   Double_t ymax = +1.1;
 
  182   TH2D h2(
"h2", 
"", 1000, 
xmin, 
xmax, 1000, ymin, ymax);
 
  190   g.SetMarkerStyle(20);
 
  191   g.SetMarkerColor(kBlack);
 
  192   g.SetMarkerSize(0.7);
 
  195   TMarker m1(
result.first ->getX(), 
result.first ->getY(), 20);
 
  196   TMarker m2(
result.second->getX(), 
result.second->getY(), 20);
 
  198   m1.SetMarkerColor(kRed);
 
  199   m2.SetMarkerColor(kRed);
 
  201   m1.SetMarkerSize(0.7);
 
  202   m2.SetMarkerSize(0.7);
 
int main(int argc, char *argv[])
 
General purpose messaging.
 
#define DEBUG(A)
Message macros.
 
Utility class to parse command line options.
 
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
 
I/O formatting auxiliaries.
 
Auxiliary class for CPU timing and usage.
 
void print(std::ostream &out, const JScale_t scale=milli_t) const
Print timer data.
 
Data structure for vector in two dimensions.
 
Utility class to parse command line options.
 
static const JSmallestDistance2D getSmallestDistance2D
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.
 
Auxiliary data structure for floating point format specification.