//public static Pointing Create(Vector3d vec) //{ // Pointing temp = new Pointing(); // temp.theta = FastMath.atan2(Math.Sqrt(vec.X * vec.X + vec.Y * vec.Y), vec.Z); // temp.phi = FastMath.atan2(vec.Y, vec.X); // if (temp.phi < 0d) // { // temp.phi += 2 * Math.PI; // } // if (temp.phi >= 2 * Math.PI) // { // temp.phi -= 2 * Math.PI; // } // return temp; //} //public static Pointing Create(Zphi zphi) //{ // Pointing temp = new Pointing(); // double xy = Math.Sqrt((1d - zphi.z) * (1d + zphi.z)); // temp.theta = FastMath.atan2(xy, zphi.z); // temp.phi = zphi.phi; // return temp; //} /** Normalize theta range */ public void normalizeTheta() { theta = HealpixUtils.fmodulo(theta, 2 * Math.PI); if (theta > Math.PI) { phi += Math.PI; theta = 2 * Math.PI - theta; } }
private static Fxyf FromHploc(Hploc loc) { Fxyf temp = new Fxyf(); double z = loc.z, phi = loc.phi; double za = Math.Abs(z); double tt = HealpixUtils.fmodulo((phi * Fxyf.inv_halfpi), 4.0); // in [0,4) if (za <= Fxyf.twothird) // Equatorial region { double temp1 = 0.5 + tt; double temp2 = z * 0.75; double jp = temp1 - temp2; // index of ascending edge line double jm = temp1 + temp2; // index of descending edge line long ifp = (long)jp; // in {0,4} long ifm = (long)jm; long face_num = (ifp == ifm) ? (ifp | 4) : ((ifp < ifm) ? ifp : (ifm + 8)); temp.fx = HealpixUtils.fmodulo(jm, 1d); temp.fy = 1d - HealpixUtils.fmodulo(jp, 1d); temp.face = (int)face_num; } else // polar region, za > 2/3 { int ntt = Math.Min(3, (int)tt); double tp = tt - ntt; double tmp; if ((za < 0.99) || (!loc.have_sth)) { tmp = Math.Sqrt(3 * (1 - za)); } else { tmp = loc.sth / Math.Sqrt((1d + za) / 3d); } double jp = tp * tmp; // increasing edge line index double jm = (1.0 - tp) * tmp; // decreasing edge line index if (jp >= 1d) { jp = 1d; // for points too close to the boundary } if (jm >= 1d) { jm = 1d; } if (z >= 0) { temp.fx = 1d - jm; temp.fy = 1d - jp; temp.face = ntt; } else { temp.fx = jp; temp.fy = jm; temp.face = ntt + 8; } } return(temp); }
/** Normalize theta and phi ranges */ public void normalize() { normalizeTheta(); phi = HealpixUtils.fmodulo(phi, 2 * Math.PI); }