Пример #1
0
        public double TrueAnomalyAtDN(Vessel target)
        {
            if (ReferenceEquals(target, null))
            {
                throw new ArgumentNullException(nameof(target));
            }
            var degrees = FinePrint.Utilities.OrbitUtilities.AngleOfDescendingNode(InternalOrbit, target.Orbit.InternalOrbit);

            return(GeometryExtensions.ToRadians(GeometryExtensions.ClampAngle180(degrees)));
        }
Пример #2
0
        public double RelativeInclination(Vessel target)
        {
            if (ReferenceEquals(target, null))
            {
                throw new ArgumentNullException(nameof(target));
            }
            var degrees = FinePrint.Utilities.OrbitUtilities.GetRelativeInclination(InternalOrbit, target.Orbit.InternalOrbit);

            return(GeometryExtensions.ToRadians(degrees));
        }
Пример #3
0
 public double BedrockHeight (double latitude, double longitude)
 {
     if (InternalBody.pqsController == null)
         return 0;
     var latitudeRadians = GeometryExtensions.ToRadians (latitude);
     var longitudeRadians = GeometryExtensions.ToRadians (longitude);
     var cosLatitude = Math.Cos (latitudeRadians);
     var sinLatitude = Math.Sin (latitudeRadians);
     var cosLongitude = Math.Cos (longitudeRadians);
     var sinLongitude = Math.Sin (longitudeRadians);
     var position = new Vector3d (cosLatitude * cosLongitude, sinLatitude, cosLatitude * sinLongitude);
     return InternalBody.pqsController.GetSurfaceHeight (position) - InternalBody.pqsController.radius;
 }
Пример #4
0
        /// <summary>
        /// Convert a vector of angles to a vector of angular velocities. This
        /// implements the function f(x) from the documentation.
        /// </summary>
        Vector3d AnglesToAngularVelocity(Vector3d angles, Vector3d torque, Vector3d moi)
        {
            var result = Vector3d.zero;

            for (int i = 0; i < 3; i++)
            {
                var theta            = GeometryExtensions.ToRadians(angles [i]);
                var maxAcceleration  = torque [i] / moi [i];
                var maxVelocity      = maxAcceleration * StoppingTime [i];
                var acceleration     = Math.Min(maxAcceleration, maxVelocity / DecelerationTime [i]);
                var velocity         = -Math.Sign(angles [i]) * Math.Min(maxVelocity, Math.Sqrt(2.0 * Math.Abs(theta) * acceleration));
                var attenuationAngle = GeometryExtensions.ToRadians(AttenuationAngle [i]);
                var attenuation      = 1.0 / (1.0 + Math.Exp(-((Math.Abs(theta) - attenuationAngle) * (6.0 / attenuationAngle))));
                if (double.IsNaN(attenuation))
                {
                    attenuation = 0;
                }
                result [i] = velocity * attenuation;
            }
            return(result);
        }