示例#1
0
		/// <summary>
		/// Computes the list of hid ranges for a halfspace given as a "circle"
		/// with a given location in RA/DEC and a radius (in arc minutes).
		/// </summary>
		/// <param name="depth">Do not compute trixels beyond this depth</param>
		/// <param name="ra">RA in degrees</param>
		/// <param name="dec">DEC in degrees</param>
		/// <param name="radius">Radius of cone in arc minutes</param>
		/// <returns>A table of HtmIDs</returns>
		public static Int64[,] Circle(double depth, double ra, double dec, double radius){
			Int64[,] returnResult; // interface to caller
			ArrayList lohis; // interface to xphtm Convex
			lohis = new ArrayList();
			
			// Convert arc minutes to Radians. 60 * 180 = 10800;
			//
			double x, y, z;
			double d = Cartesian.Cos(Cartesian.Pi * radius/10800.0);
			SpatialVector.radec2cartesian(ra, dec, out x, out y, out z);
			Convex c = new Convex(Convex.Mode.Normal);
			c.add(x, y, z, d);
			c.intersect(false, HtmState.Instance.maxlevel, lohis);// lohis is list of pairs

			int rows = lohis.Count/2;
			int cols = 2;
			int k = 0;
			returnResult = new Int64[rows,cols];
			for(int i=0; i<rows; i++){
				returnResult[i,0] = (Int64) lohis[k++];
				returnResult[i,1] = (Int64) lohis[k++];
			}
			return returnResult;
		}
示例#2
0
		/// <summary>
		/// Computes the table for a single halfspace.
		/// Identical in function
		/// to Circle, only the parameters are different.
		/// </summary>
		/// <param name="depth">do not compute trixels beyond this depth</param>
		/// <param name="x">x-coordinate of halfspace's direction vector</param>
		/// <param name="y">y-coordinate of halfspace's direction vector</param>
		/// <param name="z">z-coordinate of halfspace's direction vector</param>
		/// <param name="d">distance of cutting plane from origin</param>
		/// <returns></returns>
		public static Int64[,] Halfspace(double depth, double x, double y, double z, double d){

			Int64[,] returnResult; // interface to caller
			ArrayList lohis; // interface to xphtm Convex
			lohis = new ArrayList();
			
			Convex c = new Convex(Convex.Mode.Normal);
			c.add(x, y, z, d);
			c.intersect(false, HtmState.Instance.maxlevel, lohis);// lohis is list of pairs

			int rows = lohis.Count/2;
			int cols = 2;
			int k = 0;
			returnResult = new Int64[rows,cols];
			for(int i=0; i<rows; i++){
				returnResult[i,0] = (Int64) lohis[k++];
				returnResult[i,1] = (Int64) lohis[k++];
			}
			return returnResult;
		}
示例#3
0
		/// <summary>
		/// Create a domain with a single convex defined 
		/// by a rectangle.
		/// The rectangle is defined by 
		/// RA/DEC limits. 
		/// The dec may be in any order,
		/// but the RA order is significant, because the spehere wraps around.
		/// In other words RA range 350 - 10 is distinguished from 10 - 350
		/// There are two great circles (ra) and two small circles (dec)
		/// </summary>
		/// <param name="depth">do not compute trixels beyond this depth</param>
		/// <param name="ra1"></param>
		/// <param name="dec1"></param>
		/// <param name="ra2"></param>
		/// <param name="dec2"></param>
		/// <returns>A table of HtmIDs</returns>
		public static Int64[,] Rectangle(double depth, double ra1, double dec1, double ra2, double dec2)
			{
			//
			// Create four halfspaces. Two great circles for RA and
			// two small circles for DEC
			Int64[,] returnResult;
			double dlo, dhi; // offset from center, parameter for constraint
			double declo, dechi;
			double costh, sinth; // sine and cosine of theta (RA) for rotation of vector
			double x, y, z;
			ArrayList lohis; // interface to xphtm Convex
			Convex c = new Convex(Convex.Mode.Normal);
			lohis = new ArrayList();

			//
			// Halfspaces belonging to declo and dechi are circles parallel
			// to the xy plane, their normal is (0, 0, +/-1)
			//
			// declo halfpsacet is pointing up (0, 0, 1)
			// dechi is pointing down (0, 0, -1)
			if (dec1 > dec2){
				declo = dec2;
				dechi = dec1;
			} else {
				declo = dec1;
				dechi = dec2;
			}
			dlo = Math.Sin(declo * Cartesian.DTOR);
			dhi = -Math.Sin(dechi * Cartesian.DTOR); // Yes, MINUS!
	
			c.add(0.0, 0.0,  1.0, dlo); // Halfspace #1
			c.add(0.0, 0.0, -1.0, dhi); // Halfspace #1

			costh = Cartesian.Cos(ra1 * Cartesian.DTOR);
			sinth = Math.Sin(ra1 * Cartesian.DTOR);
			x =  -sinth;
			y =   costh;
			z =       0.0;
			c.add(x, y, z, 0.0);// Halfspace #3

			costh = Cartesian.Cos(ra2 * Cartesian.DTOR);
			sinth = Math.Sin(ra2 * Cartesian.DTOR);
			x =   sinth;
			y =  -costh;
			z =       0.0;

			c.add(x, y, z, 0.0);// Halfspace #4
			/////////////////////////////////////// INTERSECT

			c.intersect(false, HtmState.Instance.maxlevel, lohis);// lohis is list of pairs
			/////////////////////////////////////// STORE RESULT
			int rows = lohis.Count/2;
			int cols = 2;
			int k = 0;
			returnResult = new Int64[rows,cols];
			for(int i=0; i<rows; i++){
				returnResult[i,0] = (Int64) lohis[k++];
				returnResult[i,1] = (Int64) lohis[k++];
			}
			return returnResult;
		}