Beispiel #1
0
        public void Calculate()
        {
            double jul_ut = SweWrapper.ToJulianDay(this.moment);

            PlanetPosition pos = null;

            foreach (PlanetId id in Astrolabe.Concerned)
            {
                pos = SweWrapper.PositionOf(jul_ut, id, SeFlg.SEFLG_SPEED);

                if (this.starPositions.ContainsKey(id))
                {
                    this.starPositions[id] = pos;
                }
                else
                {
                    this.starPositions.Add(id, pos);
                }

                //this.starPositions.Add(id, pos);

                //pos2 = PositionOf(jul_et, id);
            }

            SweWrapper.swe_close();

            PlanetPosition posA, posB;

            patterns.Clear();

            for (int i = 0; i < starPositions.Count - 1; i++)
            {
                KeyValuePair <PlanetId, PlanetPosition> kvp = starPositions.ElementAt(i);
                posA = kvp.Value;
                for (int j = i + 1; j < starPositions.Count; j++)
                {
                    kvp  = starPositions.ElementAt(j);
                    posB = kvp.Value;

                    if (Relation.HasRelation(posA, posB))
                    {
                        Relation newRelation = new Relation(posA, posB);

                        patterns.Add(newRelation.Kind, newRelation);
                    }
                }
            }
        }
Beispiel #2
0
        //public DateTime GetEventTime()
        //{
        //    Double expected = DegreesExpected;

        //    double jul = referencePoint;
        //    PlanetPosition interiorPos, exterirorPos;
        //    double angle, orb, speed, step = 100.0, inPos, exPos;

        //    for (int tryCount = 0; tryCount < maxTry; tryCount ++ )
        //    {
        //        interiorPos = SweWrapper.PositionOf(jul, Interior, SeFlg.SEFLG_SPEED);
        //        exterirorPos = SweWrapper.PositionOf(jul, Exterior, SeFlg.SEFLG_SPEED);

        //        inPos = interiorPos.Rectascension.Degrees;
        //        exPos = exterirorPos.Rectascension.Degrees;

        //        angle =( inPos - exPos + 360) % 360.0;

        //        orb = ( (angle > 180.0) ? 360.0-expected : expected) - angle;
        //        speed = interiorPos.LongVelo.Degrees - exterirorPos.LongVelo.Degrees;

        //        if (!cachedAspects.ContainsKey(jul))
        //            cachedAspects.Add(jul, angle);

        //        if (Math.Abs(orb) < Negligible)
        //            return SweWrapper.UtcFromJulianDay(jul);

        //        step = orb / speed;
        //        jul += step;

        //        //step = Math.Min(step / 2.0, Math.Abs(orb / speed));

        //        //if (orb * speed * (inPos-exPos) > 0)
        //        //    jul += step;
        //        //else
        //        //    jul -= step;
        //    }
        //    return getClosestFromCache();
        //}

        public Phenomenon PhenomenonNearby()
        {
            Double expected = similarAspectDegrees(cachedAspects[referencePoint]);

            double         jul = referencePoint;
            PlanetPosition interiorPos, exterirorPos;
            double         angle, orb, speed, step = 100.0, inPos, exPos;

            for (int tryCount = 0; tryCount < maxTry; tryCount++)
            {
                interiorPos  = SweWrapper.PositionOf(jul, Interior, SeFlg.SEFLG_SPEED);
                exterirorPos = SweWrapper.PositionOf(jul, Exterior, SeFlg.SEFLG_SPEED);

                inPos = interiorPos.Rectascension.Degrees;
                exPos = exterirorPos.Rectascension.Degrees;

                angle = (inPos - exPos + 360) % 360.0;

                orb   = ((angle > 180.0) ? 360.0 - expected : expected) - angle;
                speed = interiorPos.LongVelo.Degrees - exterirorPos.LongVelo.Degrees;

                if (!cachedAspects.ContainsKey(jul))
                {
                    cachedAspects.Add(jul, angle);
                }

                if (Math.Abs(orb) < Negligible)
                {
                    return(new Phenomenon(SweWrapper.UtcFromJulianDay(jul),
                                          new RelationKind(Interior, Exterior, Aspect.AspectTypeOf(expected)), inPos, exPos));
                    //return SweWrapper.UtcFromJulianDay(jul);
                }

                step = orb / speed;
                jul += step;

                //step = Math.Min(step / 2.0, Math.Abs(orb / speed));

                //if (orb * speed * (inPos-exPos) > 0)
                //    jul += step;
                //else
                //    jul -= step;
            }
            return(null);
        }