Esempio n. 1
0
        /// <summary>
        /// A direction interpolated between the two given directions.
        /// </summary>
        /// <param name="slon">Start longitude.</param>
        /// <param name="slat">Start latitude.</param>
        /// <param name="elon">End longitude.</param>
        /// <param name="elat">End latitude.</param>
        /// <param name="t">Interpolation.</param>
        /// <param name="lon">Output longitude.</param>
        /// <param name="lat">Output latitude.</param>
        public virtual void InterpolateDirection(double slon, double slat, double elon, double elat, double t, ref double lon, ref double lat)
        {
            var s = new Vector3d(Math.Cos(slon) * Math.Cos(slat), Math.Sin(slon) * Math.Cos(slat), Math.Sin(slat));
            var e = new Vector3d(Math.Cos(elon) * Math.Cos(elat), Math.Sin(elon) * Math.Cos(elat), Math.Sin(elat));
            var v = (s * (1.0 - t) + e * t).Normalized();

            lat = Functions.Safe_Asin(v.z);
            lon = Math.Atan2(v.y, v.x);
        }
Esempio n. 2
0
        public override void Move(Vector3d oldp, Vector3d p, double speed)
        {
            var oldPosition = oldp.Normalized();
            var position    = p.Normalized();

            var oldlat = Functions.Safe_Asin(oldPosition.z);
            var oldlon = Math.Atan2(oldPosition.y, oldPosition.x);
            var lat    = Functions.Safe_Asin(position.z);
            var lon    = Math.Atan2(position.y, position.x);

            base.position.X -= (lon - oldlon) * speed * Math.Max(1.0, worldPosition.Magnitude() - Radius);
            base.position.Y -= (lat - oldlat) * speed * Math.Max(1.0, worldPosition.Magnitude() - Radius);
        }
Esempio n. 3
0
        public override void MoveForward(double distance)
        {
            // NOTE : co - x; so - y; ca - z; sa - w;
            var oa = CalculatelongitudeLatitudeVector(position.X, position.Y);

            var po = new Vector3d(oa.x * oa.z, oa.y * oa.z, oa.w) * Radius;
            var px = new Vector3d(-oa.y, oa.x, 0.0);
            var py = new Vector3d(-oa.x * oa.w, -oa.y * oa.w, oa.z);
            var pd = (po - px * Math.Sin(position.Phi) * distance + py * Math.Cos(position.Phi) * distance).Normalized();

            position.X = Math.Atan2(pd.y, pd.x);
            position.Y = Functions.Safe_Asin(pd.z);
        }