Esempio n. 1
0
        static void Main(string[] args)
        {
            TimePoint  tp       = null;
            IAngleCalc ArgsCalc = null;

            if (args.Length == 3)
            {
                tp       = new TimePoint(byte.Parse(args[0]), byte.Parse(args[1]), byte.Parse(args[2]));
                ArgsCalc = new CalcV2();
            }
            else if (args.Length == 4)
            {
                tp       = new TimePoint(byte.Parse(args[0]), byte.Parse(args[1]), byte.Parse(args[2]), int.Parse(args[3]));
                ArgsCalc = new CalcV3();
            }

            if (tp != null)
            {
                Console.WriteLine($"computing with {ArgsCalc.ToString()}");
                Print2(new TimeWithAngle(ArgsCalc.Compute(tp), tp));
                return;
            }

            var start = DateTime.Now;

            //IAngleCalc AngelCalculator = new CalcV2();
            IAngleCalc AngelCalculator = new CalcV3();

            foreach (var timeAngle in AngelCalculator.Values().Where(ta => ta.angle.Diff < 10.0D))     //.OrderBy( a => a.Diff ) )
            {
                Print2(timeAngle);
            }

            Console.Error.WriteLine("Duration: {0}", new TimeSpan(DateTime.Now.Ticks - start.Ticks));
        }
Esempio n. 2
0
        public Angle Compute(TimePoint tp)
        {
            int h = tp.h;
            int m = tp.m;
            int s = tp.s;

            return(new Angle(
                       HourAngle:      (double)(h * 3600 + m * 60 + s) / SecondsPer12Hour * 360d,
                       MinuteAngle:    (double)(m * 60 + s) / SecondsPerHour * 360d,
                       SecAngle:       (double)(s) / SecondsPerMinute * 360d));
        }
Esempio n. 3
0
        public Angle Compute(TimePoint tp)
        {
            const double FractionsPerSecond = 1000;
            const double FractionsPerMinute = FractionsPerSecond * 60;
            const double FractionsPerHour   = FractionsPerMinute * 60;
            const double FractionsPer12Hour = FractionsPerHour * 12;

            double SecAngle  = (tp.s * FractionsPerSecond + tp.f) / FractionsPerMinute * 360;
            double MinAngle  = (tp.m * FractionsPerMinute + tp.s * FractionsPerSecond + tp.f) / FractionsPerHour * 360;
            double HourAngle = (tp.h * FractionsPerHour + tp.m * FractionsPerMinute + tp.s * FractionsPerSecond + tp.f) / FractionsPer12Hour * 360;

            return(new Angle(HourAngle, MinAngle, SecAngle));
        }
Esempio n. 4
0
 public IEnumerable <TimeWithAngle> Values()
 {
     for (byte h = 0; h < 12; h++)
     {
         for (byte m = 0; m < 60; m++)
         {
             for (byte s = 0; s < 60; s++)
             {
                 TimePoint tp = new TimePoint(h, m, s);
                 Angle     a  = Compute(tp);
                 yield return(new TimeWithAngle(a, tp));
             }
         }
     }
 }
Esempio n. 5
0
 public TimeWithAngle(byte h, byte m, byte s, Angle angle)
 {
     this.time  = new TimePoint(h, m, s);
     this.angle = angle;
 }
Esempio n. 6
0
 public TimeWithAngle(Angle angle, TimePoint time)
 {
     this.angle = angle;
     this.time  = time;
 }
Esempio n. 7
0
 public Angle Compute(TimePoint tp)
 {
     throw new NotImplementedException();
 }