Exemple #1
0
		public static IEnumerable fHtmToCenterPoint(SqlInt64 HtmID)
		{
			double x, y, z;
			ArrayList point = new ArrayList();
			HtmTrixel htm = new HtmTrixel();
			char[] name = new char[HtmTrixel.eMaxNameSize];
			double[] v0, v1, v2;
			double norm;
			v0 = new double[3];
			v1 = new double[3];
			v2 = new double[3];
			if (htm.hid2name(name, (long)HtmID) > 1)
			{
				htm.name2Triangle(name, v0, v1, v2);
				x = v0[0] + v1[0] + v2[0];
				y = v0[1] + v1[1] + v2[1];
				z = v0[2] + v1[2] + v2[2];
				norm = x * x + y * y + z * z;
				norm = Math.Sqrt(norm);
				x /= norm;
				y /= norm;
				z /= norm;
				point.Add(new Triple(x, y, z));
			}
			else { /* return empty */ }
			return (IEnumerable)point;
		}
Exemple #2
0
		public static IEnumerable fHtmToCornerPoints(SqlInt64 HtmID)
		{
			ArrayList point = new ArrayList();
			HtmTrixel htm = new HtmTrixel();
			char[] name = new char[HtmTrixel.eMaxNameSize];
			double[] v0, v1, v2;
			v0 = new double[3];
			v1 = new double[3];
			v2 = new double[3];
			if (htm.hid2name(name, (long)HtmID) > 1)
			{
				htm.name2Triangle(name, v0, v1, v2);
				point.Add(new Triple(v0[0], v0[1], v0[2]));
				point.Add(new Triple(v1[0], v1[1], v1[2]));
				point.Add(new Triple(v2[0], v2[1], v2[2]));
			}
			else { /* return empty */ }
			return (IEnumerable)point;
		}
Exemple #3
0
		public static SqlDouble fHtmIDToSquareArcmin(SqlInt64 hid)
		{
			HtmTrixel htm = new HtmTrixel();

			double t1, t2, t3;
			double area;
			if (htm.getAngles((Int64)hid, out  t1, out  t2, out  t3))
			{
				// Area in stearadians A = R^2[(t1 + t2 + t3 ) - Pi], but R=1.
				area = (t1 + t2 + t3) - Cartesian.Pi;
				area *= Cartesian.RTOD * Cartesian.RTOD; // to get square degrees;
				area *= 3600.0; // square arc minutes
			}
			else
			{
				area = 0.0;
			}
			return (area);
		}
Exemple #4
0
		public static SqlString fHtmToString(SqlInt64 HtmID)
		{
			HtmTrixel htm = new HtmTrixel();
			char[] name = new char[HtmTrixel.eMaxNameSize];
			int level = htm.hid2name(name, (long)HtmID);
			if (level < 0)
			{
				return (new SqlString("Invalid HTM Identifier."));
			}
			else
			{
				return (new SqlString(new string(name, 0, level)));
			}
		}
Exemple #5
0
		public static long fHtmLatLon(double lat, double lon)
		{
			double x, y, z;
			HtmTrixel ht = new HtmTrixel();
			SpatialVector.radec2cartesian(lon, lat, out x, out y, out z);
			return ht.cartesian2HID(x, y, z, level);
		}
Exemple #6
0
		public static long fHtmEq(double ra, double dec)
		{
			double x, y, z;
			HtmTrixel ht = new HtmTrixel();
			SpatialVector.radec2cartesian(ra, dec, out x, out y, out z);
			return ht.cartesian2HID(x, y, z, level);
		}
Exemple #7
0
		public static long fHtmXyz(double x, double y, double z)
		{	// avoid zero vectors by setting them to 1,0,0.
			if (Cartesian.Epsilon2 > (x * x + y * y + z * z)) { x = 0; y = 0; z = 1; }
			HtmTrixel ht = new HtmTrixel();
			return ht.cartesian2HID(x, y, z, level);
		}
Exemple #8
0
		private void init(){
			_halfspaces     = new ArrayList(); // will change
			_corners        = new ArrayList();
			_sign           = Halfspace.Sign.Zero;
			_boundingCircle = new Halfspace();
			_htm		    = new HtmTrixel();
		}
Exemple #9
0
		private  void clear(){
			_halfspaces     = null;
			_corners        = null;
			_sign           = Halfspace.Sign.Zero;
			_boundingCircle = null;
			_htm		    = new HtmTrixel();
		}