Package com.nr.cg

Examples of com.nr.cg.Nearpoints


      pvec[i] = new Point(2);
      pvec[i].x[0]=myran.doub();
      pvec[i].x[1]=myran.doub();
    }

    Nearpoints qo = new Nearpoints(2,pvec);
    KDtree kd = new KDtree(2,pvec);

    int[] kdlist=new int[M];
    Point[] qolist=new Point[M];

    testpt.x[0]=0.6;
    testpt.x[1]=0.7;
    r=0.1;
    nkd=kd.locatenear(testpt,r,kdlist,M);
    nqo=qo.locatenear(testpt,r,qolist,M);

    // See if KDtree and Nearpoints found the same number of
    // neighbors withing radius r
    localflag = (nkd != nqo);
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Nearpoints,2D: KDtree found a different number of neighbors inside radius r");
     
    }

    // See if each point from kdlist can be found in qolist
    sbeps=1.e-16;
    if (nkd == nqo) {
      for (i=0;i<nkd;i++) {
        min=1.e99;
        for (j=0;j<nqo;j++) {
          d=dist(kd.ptss[kdlist[i]],qolist[j]);
          if (d < min) min=d;
        }
//        System.out.printf(min);
        localflag = min > sbeps;
        globalflag = globalflag || localflag;
        if (localflag) {
          fail("*** Nearpoints,2D: A point identified by KDtree was not found by Nearpoints");
         
        }
      }
    }

    // Create KDtree and Qotree of same Points<3> in 3D
    Point test3pt=new Point(3);
    Point[] p3vec=new Point[N]
    for (i=0;i<N;i++) {
      p3vec[i] = new Point(3);
      p3vec[i].x[0]=myran.doub();
      p3vec[i].x[1]=myran.doub();
      p3vec[i].x[2]=myran.doub();
    }

    Nearpoints qo3=new Nearpoints(3,p3vec);
    KDtree kd3=new KDtree(3,p3vec);

    int[] kd3list=new int[M];
    Point[] qo3list=new Point[M];

    test3pt.x[0]=0.6;
    test3pt.x[1]=0.7;
    test3pt.x[2]=0.6;
    r=0.1;
    nkd=kd3.locatenear(test3pt,r,kd3list,M);
    nqo=qo3.locatenear(test3pt,r,qo3list,M);

    // See if KDtree and Nearpoints found the same number of
    // neighbors withing radius r
    localflag = (nkd != nqo);
    globalflag = globalflag || localflag;
View Full Code Here

TOP

Related Classes of com.nr.cg.Nearpoints

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.