Пример #1
0
        internal void FillNearCasterArray(float[] ary, Vector3d base_point, int line_min, int line_max, int sample_min, int sample_max)
        {
            var ptr = 0;
            var bx  = base_point.X;
            var by  = base_point.Y;
            var bz  = base_point.Z;

            for (var line = line_min; line < line_max; line++)
            {
                for (var sample = sample_min; sample < sample_max; sample++)
                {
                    var relz   = Terrain.LineSampleToTerrainOffset(line, sample);
                    var radius = TerrainPatch.MoonRadius + relz / 1000d;
                    InMemoryInt16Terrain.GetLatLon(line, sample, out double lat, out double lon);
                    var z = radius * Math.Sin(lat);
                    var c = radius * Math.Cos(lat);
                    var x = c * Math.Cos(lon);
                    var y = c * Math.Sin(lon);

                    ary[ptr++] = (float)(x - bx);
                    ary[ptr++] = (float)(y - by);
                    ary[ptr++] = (float)(z - bz);
                }
            }
        }
 IEnumerable <Siegler> ReadSieglerProduct2()
 {
     using (var tr = new StreamReader("ice-stability-depth-export.csv"))  // export of ice stability depth image
     {
         string file_line;
         tr.ReadLine();
         while ((file_line = tr.ReadLine()) != null)
         {
             var split   = file_line.Split(',');
             var lat     = double.Parse(split[0]);
             var lon     = double.Parse(split[1]);
             var depth   = float.Parse(split[2]);
             var lat_rad = lat * Math.PI / 180d;
             var lon_rad = lon * Math.PI / 180d;
             InMemoryInt16Terrain.GetLineSample(lat_rad, lon_rad, out int line, out int sample);
             //InMemoryTerrainManager.GetLatLonDegrees(line, sample, out double lat1, out double lon1);
             if (line < 0 || sample < 0 || line >= InMemoryInt16Terrain.Samples || sample >= InMemoryInt16Terrain.Samples)
             {
                 continue;
             }
             var pixel = new Point(sample, line);
             yield return(new Siegler {
                 Lat = lat, Lon = lon, Depth = depth, Pixel = pixel
             });
         }
     }
 }
Пример #3
0
        private void ProjectPoint(double[] rectan, ref PointF p)
        {
            double r = 0, lat_rad = 0, lon_rad = 0;

            CSpice.reclat_c(rectan, ref r, ref lon_rad, ref lat_rad);
            InMemoryInt16Terrain.GetLineSample(lat_rad, lon_rad, out int line, out int sample);
            p.X = sample;
            p.Y = line;
        }
        IEnumerable <Siegler> ReadSieglerProduct()
        {
            var config = new Configuration {
                AllowComments = true, HasHeaderRecord = false, IgnoreBlankLines = true, Delimiter = "\t"
            };

            using (var tr = new StreamReader(IceDepthCsvPath))
                using (var csv = new CsvReader(tr, config))
                {
                    while (csv.Read())
                    {
                        // Assume lat,lon are at the center of the triangle
                        var depth = csv.GetField <float>(3);
                        var lon   = -csv.GetField <float>(7); // Note the - sign
                        var lat   = csv.GetField <float>(8);
                        var x     = csv.GetField <double>(4);
                        var y     = csv.GetField <double>(5);
                        var z     = csv.GetField <double>(6);

                        var lat1 = lat * Math.PI / 180d;
                        var lon1 = lon * Math.PI / 180d;

                        //var lon2 = Math.Atan2(y, x);
                        //if (lon2 < -Math.PI) lon2 += 2d * Math.PI;
                        //var d2 = Math.Sqrt(x * x + y * y);
                        //var lat2 = Math.Atan2(z, d2);

                        //lat2 = lat * Math.PI/180d;
                        //lon2 = lon * Math.PI / 180d;

                        InMemoryInt16Terrain.GetLineSample(lat1, lon1, out int line, out int sample);
                        if (line < 0 || sample < 0 || line >= InMemoryInt16Terrain.Samples || sample >= InMemoryInt16Terrain.Samples)
                        {
                            continue;
                        }

                        // Distance from tri center to one corner
                        var delta = Vector3d.Subtract(new Vector3d(x, y, z), TerrainPatch.MoonRadius * LatLonToPoint(lat1, lon1)).Length;
                        var pixel = new Point(sample, line);
                        yield return(new Siegler {
                            Lat = lat1, Lon = lon1, Depth = depth, Pixel = pixel, Distance = delta
                        });
                    }
                }
        }