예제 #1
0
        //TODO: Improve rendering code to segment spherical coordinates
        //which are too far apart to follow curvature
        public Vector3[] BuildSegment(Angle startLatitude, Angle startLongitude, Angle endLatitude, Angle endLongitude, float heightAboveSurface)
        {
            //check how far the point being added is from the last point
            Angle angularDistance = World.ApproxAngularDistance(
                startLatitude,
                startLongitude,
                endLatitude,
                endLongitude);

            Vector3[] newPoints = null;
            if (angularDistance.Degrees >= 2.0)
            {
                int samples = (int)(angularDistance.Radians * 30);                // 1 point for every 2 degrees.
                if (samples < 2)
                {
                    samples = 2;
                }

                Angle lat, lon = Angle.Zero;
                newPoints = new Vector3[samples];
                for (int i = 0; i < samples; i++)
                {
                    float t = (float)i / (samples - 1);
                    World.IntermediateGCPoint(t, startLatitude, startLongitude, endLatitude, endLongitude,
                                              angularDistance, out lat, out lon);
                    newPoints[i] = MathEngine.SphericalToCartesian(lat, lon, this._parentWorld.EquatorialRadius + this.verticalExaggeration * heightAboveSurface);
                }
            }
            return(newPoints);
        }
예제 #2
0
        /// <summary>
        /// Adds a point to the end of the line.
        /// </summary>
        /// <param name="x">Lon</param>
        /// <param name="y">Lat</param>
        /// <param name="z">Alt (meters)</param>
        public void AddPoint(double x, double y, double z)
        {
            Point3d point = new Point3d(x, y, z);

            //TODO:Divide into subsegments if too far
            if (this.m_points.Count > 0)
            {
                Angle  startlon = Angle.FromDegrees(this.m_points.Last.Value.X);
                Angle  startlat = Angle.FromDegrees(this.m_points.Last.Value.Y);
                double startalt = this.m_points.Last.Value.Z;
                Angle  endlon   = Angle.FromDegrees(x);
                Angle  endlat   = Angle.FromDegrees(y);
                double endalt   = z;

                Angle dist = World.ApproxAngularDistance(startlat, startlon, endlat, endlon);
                if (dist.Degrees > 0.25)
                {
                    double stepSize = 0.25;
                    int    samples  = (int)(dist.Degrees / stepSize);

                    for (int i = 0; i < samples; i++)
                    {
                        Angle lat, lon = Angle.Zero;
                        float frac = (float)i / samples;
                        World.IntermediateGCPoint(frac, startlat, startlon, endlat, endlon,
                                                  dist, out lat, out lon);
                        double  alt      = startalt + frac * (endalt - startalt);
                        Point3d pointint = new Point3d(lon.Degrees, lat.Degrees, alt);
                        this.AddPoint(pointint);
                    }

                    this.AddPoint(point);
                }
                else
                {
                    this.AddPoint(point);
                }
            }
            else
            {
                this.AddPoint(point);
            }

            this.NeedsUpdate = true;
        }