Esempio n. 1
0
        internal PositionNormalTexturedX2 GetMappedVertex(PositionTexture vert)
        {
            PositionNormalTexturedX2 vertOut = new PositionNormalTexturedX2();
            Coordinates latLng = Coordinates.CartesianToSpherical2(vert.Position);

            //      latLng.Lng += 90;
            if (latLng.Lng < -180)
            {
                latLng.Lng += 360;
            }
            if (latLng.Lng > 180)
            {
                latLng.Lng -= 360;
            }
            //if (false)
            //{
            ////    System.Diagnostics.Debug.WriteLine(String.Format("{0},{1}", (int)(vert.Tu * 16 + .5), (int)(vert.Tv * 16 + .5)));
            //}

            if (level > 1)
            {
                byte arrayX = (byte)(int)(vert.Tu * 16 + .5);
                byte arrayY = (byte)(int)(vert.Tv * 16 + .5);
                demArray[arrayX + arrayY * 17] = DemData[demIndex];

                if (backslash)
                {
                    if (tempBackslashYIndex != null)
                    {
                        tempBackslashXIndex[demIndex] = arrayX;
                        tempBackslashYIndex[demIndex] = arrayY;
                    }
                }
                else
                {
                    if (tempSlashYIndex != null)
                    {
                        tempSlashXIndex[demIndex] = arrayX;
                        tempSlashYIndex[demIndex] = arrayY;
                    }
                }
            }

            Vector3d pos = GeoTo3dWithAltitude(latLng.Lat, latLng.Lng, false);

            vertOut.Tu = (float)vert.Tu;
            vertOut.Tv = (float)vert.Tv;

            vertOut.Lat      = latLng.Lat;
            vertOut.Lng      = latLng.Lng;
            vertOut.Normal   = pos;
            pos              = pos - localCenter;
            vertOut.Position = pos;
            return(vertOut);
        }
Esempio n. 2
0
            public Coordinates Project(Vector2d point, double width, double height)
            {
                double lat = point.Y;
                double lng = point.X;

                lng = -lng;
                Matrix3d matrix = Matrix3d.Identity;

                matrix.Multiply(Matrix3d.RotationX((((Rotation - 180)) / 180f * Math.PI)));
                matrix.Multiply(Matrix3d.RotationZ(((Dec) / 180f * Math.PI)));
                matrix.Multiply(Matrix3d.RotationY((((360 - RA * 15) + 180) / 180f * Math.PI)));

                //lng = -lng;
                double fac1   = (Scale * height) / 2;
                double factor = Math.Tan(fac1 * RC);

                Vector3d retPoint = Vector3d.TransformCoordinate(new Vector3d(1f, (lat / fac1 * factor), (lng / fac1 * factor)), matrix);

                retPoint.Normalize();
                return(Coordinates.CartesianToSpherical2(retPoint));
            }
Esempio n. 3
0
        public override IPlace FindClosest(Coordinates target, float distance, IPlace defaultPlace, bool astronomical)
        {
            Vector3d searchPoint = Coordinates.GeoTo3dDouble(target.Lat, target.Lng);

            //searchPoint = -searchPoint;
            Vector3d dist;

            if (defaultPlace != null)
            {
                Vector3d testPoint = Coordinates.RADecTo3d(defaultPlace.RA, -defaultPlace.Dec, -1.0);
                dist     = searchPoint - testPoint;
                distance = (float)dist.Length();
            }

            int closestItem = -1;
            int index       = 0;

            foreach (Vector3 point in positions)
            {
                dist = searchPoint - new Vector3d(point);
                if (dist.Length() < distance)
                {
                    distance    = (float)dist.Length();
                    closestItem = index;
                }
                index++;
            }


            if (closestItem == -1)
            {
                return(defaultPlace);
            }

            Coordinates pnt = Coordinates.CartesianToSpherical2(positions[closestItem]);

            string name = table.Rows[closestItem].ColumnData[this.nameColumn].ToString();

            if (nameColumn == startDateColumn || nameColumn == endDateColumn)
            {
                name = SpreadSheetLayer.ParseDate(name).ToString("u");
            }

            if (String.IsNullOrEmpty(name))
            {
                name = string.Format("RA={0}, Dec={1}", Coordinates.FormatHMS(pnt.RA), Coordinates.FormatDMS(pnt.Dec));
            }
            TourPlace place = new TourPlace(name, pnt.Lat, pnt.RA, Classification.Unidentified, "", ImageSetType.Sky, -1);

            Dictionary <String, String> rowData = new Dictionary <string, string>();

            for (int i = 0; i < table.Columns.Count; i++)
            {
                string colValue = table.Rows[closestItem][i].ToString();
                if (i == startDateColumn || i == endDateColumn)
                {
                    colValue = SpreadSheetLayer.ParseDate(colValue).ToString("u");
                }

                if (!rowData.ContainsKey(table.Column[i].Name) && !string.IsNullOrEmpty(table.Column[i].Name))
                {
                    rowData.Add(table.Column[i].Name, colValue);
                }
                else
                {
                    rowData.Add("Column" + i.ToString(), colValue);
                }
            }
            place.Tag = rowData;
            if (Viewer != null)
            {
                Viewer.LabelClicked(closestItem);
            }
            return(place);
        }