Example #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);
        }
Example #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;
        }
Example #3
0
			/// <summary>
			/// Calculates the segments of the measure curve
			/// </summary>
			public void Calculate(World world, bool useTerrain)
			{
				Angle angularDistance = World.ApproxAngularDistance( startLatitude, startLongitude, endLatitude, endLongitude );
				Linear = angularDistance.Radians * world.EquatorialRadius;
			
				int samples = (int)(angularDistance.Radians*30);  // 1 point for every 2 degrees.
				if(samples<2)
					samples = 2;

				LinearTrackLine = new CustomVertex.PositionColored[samples];
				for(int i=0;i<LinearTrackLine.Length;i++)
					LinearTrackLine[i].Color = World.Settings.MeasureLineLinearColorXml;;
			
				Angle lat,lon=Angle.Zero;
				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 );
				
					double elevation = 0;
					if(useTerrain)
						elevation = world.TerrainAccessor.GetElevationAt(lat.Degrees,lon.Degrees,1024);

					Vector3 subSegmentXyz = MathEngine.SphericalToCartesian(lat, lon, 
						world.EquatorialRadius + elevation * World.Settings.VerticalExaggeration );
					LinearTrackLine[i].X = subSegmentXyz.X;
					LinearTrackLine[i].Y = subSegmentXyz.Y;
					LinearTrackLine[i].Z = subSegmentXyz.Z;
				}

				WorldXyzMid = world.IntermediateGCPoint(0.5f, startLatitude, startLongitude, endLatitude, endLongitude,
					angularDistance );
			}