12 const double pi=2*acos(0);
14 bU.SetMagPhi(pitch,phi1deg/180*pi);
18 uv=U*V; w0=(1-uv*uv)*pitch;
19 printf(
"Hex Grid base: U(%.3f,%3f), V(%.3f,%3f) U*V=%.3f\n",U.X(),U.Y(),V.X(),V.Y(),uv);
22 TVector2 snap(TVector2 &P,
int &ku,
int &kv){
25 double u=(a-b*uv)/w0, v=(b-a*uv)/w0;
26 double iu=floor(u), iv=floor(v);
27 printf(
"P(%.3f,%3f) --> hexLatice(%.3f,%.3f)*pitch -->floor(%.0f %.0f) \n", P.X(),P.Y(),u,v,iu,iv);
31 TVector2 Psnap=TVector2(99999,99999);
35 TVector2 Q=ju*bU + jv*bV;
36 double dist2=(Q-P).Mod2();
38 if(maxD2<dist2)
continue;
46 printf(
"closest node(%d,%d) Psnap(%.3f,%3f) -->dist/um=%.2f\n",ku,kv,Psnap.X(),Psnap.Y(),sqrt(maxD2)*1e4);