Esempio n. 1
0
        /// <summary>
        /// Compute the eccentric anomaly 'E'
        /// </summary>
        /// <param name="eccentricity"></param>
        /// <param name="meanAnomaly"></param>
        /// <returns></returns>
        internal static double GetEccentricAnomaly(double eccentricity, DegreeModel meanAnomaly)
        {
            var iteration = 0;
            var maxIterationsiteration = 1000000;
            var tolerance = Math.Pow(10, -10);

            var eccentricAnomalyDegrees = new DegreeModel(DegreeHelper.RadiansToDegrees(eccentricity));

            var result = meanAnomaly.Degrees + (eccentricAnomalyDegrees.Degrees * MathDegrees.Sin(meanAnomaly.Degrees));

            while (iteration < maxIterationsiteration)
            {
                var deltaMeanAnomaly      = meanAnomaly.Degrees - (result - (eccentricAnomalyDegrees.Degrees * MathDegrees.Sin(result)));
                var deltaEccentricAnomaly = deltaMeanAnomaly / (1 - (eccentricity * MathDegrees.Cos(result)));
                result = result + deltaEccentricAnomaly;

                if (Math.Abs(deltaEccentricAnomaly) < tolerance)
                {
                    return(result);
                }

                iteration++;
            }

            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// Compute the eccentric anomaly 'E'
        /// </summary>
        /// <param name="eccentricity"></param>
        /// <param name="meanAnomaly"></param>
        /// <param name="tolerance">number of decimal positions</param>
        /// <param name="maximumIterations"></param>
        /// <returns></returns>
        internal static double GetEccentricAnomaly2(double eccentricity, DegreeModel meanAnomaly, double tolerance, double maximumIterations)
        {
            var delta = Math.Pow(10, -tolerance);

            var ma = meanAnomaly.Degrees;

            ma = ma / 360.0;

            ma = 2 * Math.PI * (ma - Math.Floor(ma));

            var eccentricAnomaly = eccentricity < 0.8 ? ma : Math.PI;

            var calculateF = eccentricAnomaly - (eccentricity * Math.Sin(ma)) - ma;

            double i = 0;

            while (Math.Abs(calculateF) > delta && i < maximumIterations)
            {
                eccentricAnomaly = eccentricAnomaly - (calculateF / (1.0 - (eccentricity * Math.Cos(eccentricAnomaly))));
                calculateF       = eccentricAnomaly - (eccentricity * Math.Sin(eccentricAnomaly)) - ma;
                i++;
            }

            eccentricAnomaly = DegreeHelper.RadiansToDegrees(eccentricAnomaly);

            var result = Math.Round(eccentricAnomaly * Math.Pow(10, tolerance)) / Math.Pow(10, tolerance);

            return(result);
        }
        public IHttpActionResult UpdateDegree(DegreeModel model)
        {
            var response = new DataResponse <EntityDegrees>();

            if (ModelState.IsValid)
            {
                var entityDegree = new EntityDegrees();
                entityDegree.Id         = model.Id;
                entityDegree.IsActive   = model.IsActive;
                entityDegree.DegreeName = model.DegreeName;
                entityDegree.ShortCode  = model.ShortCode;
                entityDegree.UpdatedBy  = CurrentUserId;
                entityDegree.UpdatedOn  = System.DateTime.UtcNow;
                response = repository.UpdateDegree(entityDegree);
                return(Ok <DataResponse>(response));
            }
            else
            {
                var errorList = ModelState.Where(a => a.Value.Errors.Any()).Select(s => new
                {
                    Key     = s.Key.Split('.').Last(),
                    Message = s.Value.Errors[0].ErrorMessage
                });
                return(Ok <dynamic>(new { Status = HttpStatusCode.BadRequest, Model = errorList }));
            }
        }
Esempio n. 4
0
        public void Modulo360AroundZeroTest(double value, double expected)
        {
            var model  = new DegreeModel(value);
            var actual = model.Modulo360AroundZero();

            Assert.True(expected.EqualsWithinTolerance(actual.Degrees, 6), $"expected {expected} and actual {actual.Degrees} are not equal.");
        }
Esempio n. 5
0
        public IHttpActionResult Update([FromBody] DegreeModel degree)
        {
            u = credenciales.getUsuario();

            var consulta = DegreeData.Actualizar(degree.DegreeId, degree.Nombre, u);

            return(Ok(consulta));
        }
Esempio n. 6
0
        public IHttpActionResult Create([FromBody] DegreeModel degree)
        {
            u = credenciales.getUsuario();
            c = credenciales.getUsuario();
            var consulta = DegreeData.Crear(degree.Nombre, u);

            return(Ok(consulta));
        }
 public DegreeViewModel MapDoctorDegree(DegreeModel dModel)
 {
     return(new DegreeViewModel()
     {
         Id = dModel.Id,
         DegreeName = dModel.DegreeName,
         TanentId = dModel.TenantID
     });
 }
Esempio n. 8
0
 public NexoBotState()
 {
     Messages           = new List <string>();
     StudyCenterModel   = new StudyCenterModel();
     DegreeCenterModel  = new DegreeModel();
     SubjectModel       = new SubjectModel();
     TeacherModel       = new TeacherModel();
     UnexFacilitieModel = new UnexFacilitieModel();
 }
        public KeplerianCalculationModel(KeplerianDateModel model)
        {
            MeanAnomaly      = model.Values.GetMeanAnomaly360();
            EccentricAnomaly = new DegreeModel(KeplerianHelper.GetEccentricAnomaly(model.Values.Eccentricity, MeanAnomaly));
            TrueAnomaly      = new DegreeModel(KeplerianHelper.GetEccentricAnomaly2(model.Values.Eccentricity, MeanAnomaly));

            TrueAnomaly = EccentricAnomaly;

            AverageCentricDistance = KeplerianHelper.GetAverageCentricDistance(model.Values.SemiMajorAxis.Degrees, model.Values.Eccentricity);
            CentricDistance        = KeplerianHelper.GetCentricDistance(AverageCentricDistance, model.Values.Eccentricity, TrueAnomaly);
            Location = KeplerianHelper.GetLocation(CentricDistance, model.Values.AscendingNodeLongitude, model.Values.GetArgumentOfPerihelion(), TrueAnomaly, model.Values.Inclination);
        }
 private List <Parameter> GetSaveDegreeParams(DegreeModel degreeModel)
 {
     return(new Parameter[]
     {
         new Parameter("@Id", degreeModel.Id),
         new Parameter("@DegreeName", degreeModel.DegreeName),
         new Parameter("@TenantID", degreeModel.TenantID),
         new Parameter("@CreatedBy", degreeModel.CreatedBy),
         new Parameter("@CreatedByEntity", degreeModel.CreatedByEntity),
         new Parameter("@UpdatedBy", degreeModel.ModifiedBy),
         new Parameter("@UpdatedByEntity", degreeModel.ModifiedByEntity)
     }.ToList <Parameter>());
 }
Esempio n. 11
0
 public KeplerianValueModel(
     double semiMajorAxis,
     double eccentricity,
     double inclination,
     double meanLongitude,
     double perihelionLongitude,
     double ascendingNodeLongitude)
 {
     SemiMajorAxis          = new DegreeModel(semiMajorAxis);
     Eccentricity           = eccentricity;
     Inclination            = new DegreeModel(inclination);
     MeanLongitude          = new DegreeModel(meanLongitude);
     PerihelionLongitude    = new DegreeModel(perihelionLongitude);
     AscendingNodeLongitude = new DegreeModel(ascendingNodeLongitude);
 }
Esempio n. 12
0
        public static LocationModel GetLocation(double centricDistance, DegreeModel ascendingNodeLongitude, DegreeModel perihelionOmega, DegreeModel trueAnomaly, DegreeModel inclination)
        {
            var x = centricDistance * (
                (ascendingNodeLongitude.Cos() * MathDegrees.Cos(perihelionOmega.Degrees + trueAnomaly.Degrees)) -
                (ascendingNodeLongitude.Sin() * inclination.Cos() * MathDegrees.Sin(perihelionOmega.Degrees + trueAnomaly.Degrees)));

            var y = centricDistance * (
                (ascendingNodeLongitude.Sin() * MathDegrees.Cos(perihelionOmega.Degrees + trueAnomaly.Degrees)) +
                (ascendingNodeLongitude.Cos() * inclination.Cos() * MathDegrees.Sin(perihelionOmega.Degrees + trueAnomaly.Degrees)));


            var z = centricDistance * (inclination.Sin() * MathDegrees.Sin(perihelionOmega.Degrees + trueAnomaly.Degrees));

            return(new LocationModel(x, y, z));
        }
Esempio n. 13
0
        public void ReflectionHelperMemberSelectorTest()
        {
            double expected = 1.23;
            var    model    = new DegreeModel(expected);

            var memberSelectorTyped = ReflectionHelper.MemberSelector <DegreeModel, double>(nameof(DegreeModel.Degrees));
            var func   = memberSelectorTyped.Compile();
            var actual = func.Invoke(model);

            Assert.Equal(expected, actual);

            var memberSelectorObject = ReflectionHelper.MemberSelector <DegreeModel>(nameof(DegreeModel.Degrees));

            actual = (double)memberSelectorObject.Compile().Invoke(model);
            Assert.Equal(expected, actual);
        }
        public void KeplerianHelperTEst()
        {
            var centricDistance        = 5.40406;
            var ascendingNodeLongitude = new DegreeModel(100.464);
            var perihelionOmega        = new DegreeModel(273.867);
            var trueAnomaly            = new DegreeModel(144.637);
            var inclination            = new DegreeModel(1.303);

            var location = KeplerianHelper.GetLocation(centricDistance, ascendingNodeLongitude, perihelionOmega, trueAnomaly, inclination);

            var x = location.X;
            var y = location.Y;
            var z = location.Z;

            Assert.True(x.EqualsWithinTolerance(-5.04289, 4));
            Assert.True(y.EqualsWithinTolerance(1.93965, 4));
            Assert.True(z.EqualsWithinTolerance(0.10478, 4));
        }
        public List <DegreeModel> GetDegree()
        {
            List <DegreeModel>          degree = new List <DegreeModel>();
            Dictionary <string, object> dict   = new Dictionary <string, object>();

            dict.Add("@LookupName", "Degree");
            dict.Add("@LCID", 1033);
            degree = ExecuteCollection <DegreeModel>("usp_Lookup_Get",
                                                     (reader) =>
            {
                DegreeModel degreeTemp = new DegreeModel()
                {
                    AttributeName  = reader.GetValue <String>(0),
                    AttributeValue = reader.GetValue <String>(1),
                    LCID           = reader.GetValue <int>(2)
                };
                return(degreeTemp);
            }, dict);


            return(degree);
        }
        public DegreeModel SaveDegree(DegreeModel dModel)
        {
            List <Parameter> saveHParam = GetSaveDegreeParams(dModel);
            Parameter        p_IsError  = new Parameter("@IsError", DBNull.Value, ParameterDirection.Output, DbType.Int16, 1);
            Parameter        p_ErrorMsg = new Parameter("@ErrorMsg", DBNull.Value, ParameterDirection.Output, DbType.String, 100);

            saveHParam.Add(p_IsError);
            saveHParam.Add(p_ErrorMsg);
            var r        = dataBaseService.ExecuteScalar(StoredProcedures.InsertUpdateDegree, DBCommandType.Procedure, saveHParam.ToArray <Parameter>());
            int retValue = Convert.ToInt32(r);

            if (retValue < (int)StoreProcStatusEnum.Success)
            {
                dModel.Success      = false;
                dModel.ErrorMessage = p_ErrorMsg.ToString();
            }
            else
            {
                dModel.Success = true;
                dModel.Id      = retValue;
            }
            return(dModel);
        }
Esempio n. 17
0
 /// <summary>
 /// Compute the eccentric anomaly 'E'
 /// </summary>
 /// <param name="eccentricity"></param>
 /// <param name="meanAnomaly"></param>
 /// <returns></returns>
 internal static double GetEccentricAnomaly2(double eccentricity, DegreeModel meanAnomaly)
 {
     return(GetEccentricAnomaly2(eccentricity, meanAnomaly, 10, 1000000));
 }
Esempio n. 18
0
 public static double GetCentricDistance(double averageCentricDistance, double eccentricity, DegreeModel trueAnomaly)
 {
     return(averageCentricDistance / (1 + (eccentricity * trueAnomaly.Cos())));
 }
 public static DegreeModel Modulo360Absolute(this DegreeModel model)
 {
     return(new DegreeModel(DegreeHelper.Modulo360Absolute(model.Degrees)));
 }
 public static double Sin(this DegreeModel model)
 {
     return(MathDegrees.Sin(model.Degrees));
 }
 public static double Cos(this DegreeModel model)
 {
     return(MathDegrees.Cos(model.Degrees));
 }
 public static DegreeModel Modulo360AroundZero(this DegreeModel model)
 {
     return(new DegreeModel(DegreeHelper.Modulo360AroundZero(model.Degrees)));
 }
Esempio n. 23
0
        public IHttpActionResult Delete(DegreeModel degree)
        {
            var consulta = DegreeData.Eliminar(degree.DegreeId);

            return(Ok(consulta));
        }
Esempio n. 24
0
        public IHttpActionResult ShowUpdate([FromBody] DegreeModel degree)
        {
            var consulta = DegreeData.MostrarUpdate(degree.DegreeId);

            return(Ok(consulta));
        }