Changeset 2517 in Sophya for trunk/SophyaPI/PIext/pintuple.cc


Ignore:
Timestamp:
Mar 17, 2004, 7:04:57 PM (22 years ago)
Author:
cmv
Message:

GetDistanceToPoint cmv 17/03/04

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PIext/pintuple.cc

    r2469 r2517  
    44
    55#include <stdio.h>
     6#include <stdlib.h>
     7#include <iostream>
     8#include <math.h>
    69#include "pintuple.h"
    710
     
    5558  SelectLabel(NULL);
    5659  SetName("NTupleDrw");
     60  NptDraw = 0;
     61
    5762}
    5863
     
    189194xp = yp = xl = yl = 0;
    190195PIGrCoord xpolyg[NMXMULTP_LOCAL], ypolyg[NMXMULTP_LOCAL];
    191 npolyg = 0; 
     196npolyg = 0;
     197NptDraw = 0;
    192198for (long i=0; i<(long)mNT->NbLines(); i++) {
    193199  xl = xp;  yl = yp;
     
    198204  if ( (xp < xmin) || (xp > xmax) || (yp < ymin) || (yp > ymax) )  continue;
    199205
     206  NptDraw++;
    200207// Taille - couleur de marker en fonction du poids
    201208  if (wK >= 0) wp = mNT->GetCell(i, wK);
     
    391398
    392399
    393 
     400/* --Methode-- */
     401double PINTuple::GetDistanceToPoint(double x, double y)
     402{
     403 if(!mNT) return 1.e+9;
     404 if( xK<0 || yK<0 ) return 1.e+9;
     405
     406 const int nessai = 100;
     407 long inc = (NptDraw>nessai) ? (long)(NptDraw/nessai)+1 : 1;
     408
     409 double dist = -1.e+18;
     410 long n = 0;
     411 for(long i=0; i<(long)mNT->NbLines(); i++) {
     412   double xp=mNT->GetCell(i,xK);
     413   if(xp<XMin() || xp>XMax()) continue;
     414   double yp=mNT->GetCell(i,yK);
     415   if(yp<YMin() || yp>YMax()) continue;
     416   if(n%inc==0) {
     417     xp = (xp-x)/(XMax()-XMin())/0.5;
     418     yp = (yp-y)/(YMax()-YMin())/0.5;
     419     xp = xp*xp+yp*yp;
     420     if(dist<0. || xp<dist) dist = xp;
     421   }
     422   n++;
     423 }
     424 dist=sqrt(fabs(dist));
     425 //cout<<"PINTuple: xlim="<<XMin()<<","<<XMax()<<" ylim="<<YMin()<<","<<YMax()
     426 //    <<" NbLines="<<mNT->NbLines()<<" inc="<<inc<<endl;
     427 //cout<<"....d="<<dist<<" x="<<x<<" y="<<y<<" NptDraw="<<NptDraw<<endl;
     428
     429 return dist;
     430}
Note: See TracChangeset for help on using the changeset viewer.