Пример #1
0
        public double MoonPhase(double JD)
        {
            Object3   CelObject = new Object3();
            OnSurface onSurface = new OnSurface();
            CatEntry3 catEntry3 = new CatEntry3();
            SkyPos    Output1   = new SkyPos();
            SkyPos    Output2   = new SkyPos();
            Observer  Location  = new Observer();
            double    DeltaT    = DeltatCode.DeltaTCalc(JD);

            CelObject.Name   = "Moon";
            CelObject.Number = Body.Moon;
            CelObject.Star   = catEntry3;
            CelObject.Type   = ASCOM.Astrometry.ObjectType.MajorPlanetSunOrMoon;
            Location.OnSurf  = onSurface;
            Location.Where   = ObserverLocation.EarthGeoCenter;
            int num1 = (int)Nov31.Place(JD + DeltaT * 1.15740740740741E-05, CelObject, Location, DeltaT, CoordSys.EquinoxOfDate, Accuracy.Full, ref Output2);

            CelObject.Name   = "Sun";
            CelObject.Number = Body.Sun;
            CelObject.Star   = catEntry3;
            CelObject.Type   = ASCOM.Astrometry.ObjectType.MajorPlanetSunOrMoon;
            int num2 = (int)Nov31.Place(JD + DeltaT * 1.15740740740741E-05, CelObject, Location, DeltaT, CoordSys.EquinoxOfDate, Accuracy.Full, ref Output1);

            return(Range((Output2.RA - Output1.RA) * 15.0, -180.0, false, 180.0, true));
        }
Пример #2
0
        public double MoonIllumination(double JD)
        {
            Object3   CelObject = new Object3();
            OnSurface onSurface = new OnSurface();
            CatEntry3 catEntry3 = new CatEntry3();
            SkyPos    Output1   = new SkyPos();
            SkyPos    Output2   = new SkyPos();
            Observer  Location  = new Observer();
            double    DeltaT    = DeltatCode.DeltaTCalc(JD);

            CelObject.Name   = "Moon";
            CelObject.Number = Body.Moon;
            CelObject.Star   = catEntry3;
            CelObject.Type   = ASCOM.Astrometry.ObjectType.MajorPlanetSunOrMoon;
            Location.OnSurf  = onSurface;
            Location.Where   = ObserverLocation.EarthGeoCenter;
            int num1 = (int)Nov31.Place(JD + DeltaT * 1.15740740740741E-05, CelObject, Location, DeltaT, CoordSys.EquinoxOfDate, Accuracy.Full, ref Output2);

            CelObject.Name   = "Sun";
            CelObject.Number = Body.Sun;
            CelObject.Star   = catEntry3;
            CelObject.Type   = ASCOM.Astrometry.ObjectType.MajorPlanetSunOrMoon;
            int    num2 = (int)Nov31.Place(JD + DeltaT * 1.15740740740741E-05, CelObject, Location, DeltaT, CoordSys.EquinoxOfDate, Accuracy.Full, ref Output1);
            double num3 = Math.Acos(Math.Sin(Output1.Dec * (Math.PI / 180.0)) * Math.Sin(Output2.Dec * (Math.PI / 180.0)) + Math.Cos(Output1.Dec * (Math.PI / 180.0)) * Math.Cos(Output2.Dec * (Math.PI / 180.0)) * Math.Cos((Output1.RA - Output2.RA) * 15.0 * (Math.PI / 180.0)));

            return((1.0 + Math.Cos(Math.Atan2(Output1.Dis * Math.Sin(num3), Output2.Dis - Output1.Dis * Math.Cos(num3)))) / 2.0);
        }
Пример #3
0
        /// <summary>
        /// Calculates the area of an object
        /// </summary>
        public static double GetArea(IRhinoObject obj, double tol)
        {
            if (null != obj)
            {
                IOnCurve crv = OnCurve.ConstCast(obj.Geometry());
                if (null != crv)
                {
                    return(GetCurveArea(crv, tol));
                }

                IOnSurface srf = OnSurface.ConstCast(obj.Geometry());
                if (null != srf)
                {
                    return(GetSurfaceArea(srf));
                }

                IOnBrep brep = OnBrep.ConstCast(obj.Geometry());
                if (null != brep)
                {
                    return(GetBrepArea(brep));
                }

                IOnMesh mesh = OnMesh.ConstCast(obj.Geometry());
                if (null != mesh)
                {
                    return(GetMeshArea(mesh));
                }
            }
            return(0.0);
        }
        private static OnCurve CreateOuterTrimmingCurve(
            OnSurface s,
            int side                   // 0 = SW to SE
            // 1 = SE to NE
            // 2 = NE to NW
            // 3 = NW to SW
            )
        {
            // A trimming curve is a 2d curve whose image lies in the surface's domain.
            // The "active" portion of the surface is to the left of the trimming curve.
            // An outer trimming loop consists of a simple closed curve running
            // counter-clockwise around the region it trims.

            //In cases when trim curve is not easily defined in surface domain,
            //use ON_Surface::Pullback only be careful about curve direction to ensure
            //loop trims run anti-clockwise for outer loop and clockwise for inner loop.

            //In this case, trim curves lie on the four edges of the surface
            On2dPoint from = new On2dPoint();
            On2dPoint to = new On2dPoint();
            double    u0 = double.NaN, u1 = double.NaN, v0 = double.NaN, v1 = double.NaN;

            s.GetDomain(0, ref u0, ref u1);
            s.GetDomain(1, ref v0, ref v1);

            switch (side)
            {
            case 0: // SW to SE
                from.x = u0; from.y = v0;
                to.x   = u1; to.y = v0;
                break;

            case 1: // SE to NE
                from.x = u1; from.y = v0;
                to.x   = u1; to.y = v1;
                break;

            case 2: // NE to NW
                from.x = u1; from.y = v1;
                to.x   = u0; to.y = v1;
                break;

            case 3: // NW to SW
                from.x = u0; from.y = v1;
                to.x   = u0; to.y = v0;
                break;

            default:
                return(null);
            }

            OnCurve c2d = new OnLineCurve(from, to);

            if (c2d != null)
            {
                c2d.SetDomain(0.0, 1.0);
            }
            return(c2d);
        }
        private static OnCurve CreateTrimmingCurve(
            OnSurface s,
            int side                    // 0 = SW to SE
            // 1 = SE to NE
            // 2 = NE to NW
            // 3 = NW to SW
            )
        {
            // A trimming curve is a 2d curve whose image lies in the surface's domain.
            // The "active" portion of the surface is to the left of the trimming curve.
            // An outer trimming loop consists of a simple closed curve running
            // counter-clockwise around the region it trims.
            // An inner trimming loop consists of a simple closed curve running
            // clockwise around the region the hole.

            On2dPoint from = new On2dPoint();
            On2dPoint to = new On2dPoint();
            double    u0 = double.NaN, u1 = double.NaN, v0 = double.NaN, v1 = double.NaN;

            s.GetDomain(0, ref u0, ref u1);
            s.GetDomain(1, ref v0, ref v1);

            switch (side)
            {
            case 0: // SW to SE
                from.x = u0; from.y = v0;
                to.x   = u1; to.y = v0;
                break;

            case 1: // diagonal
                from.x = u1; from.y = v0;
                to.x   = (u0 + u1) / 2; to.y = v1;
                break;

            case 2: // diagonal
                from.x = (u0 + u1) / 2; from.y = v1;
                to.x   = u0; to.y = v0;
                break;

            default:
                return(null);
            }

            OnCurve c2d = new OnLineCurve(from, to);

            if (c2d != null)
            {
                c2d.SetDomain(0.0, 1.0);
            }
            return(c2d);
        }
Пример #6
0
        public void OnTick(Graphics gr)
        {
            OnDelete?.Invoke();
            OnGravity?.Invoke(true);
            OnSpring?.Invoke();
            OnRope?.Invoke();
            for (int i = 0; i < Surface.stillColliding.Count; i++)
            {
                Surface.stillColliding[i] = false;
            }
            do
            {
                for (int i = 0; i < Surface.stillColliding.Count; i++)
                {
                    Surface.stillColliding[i] = false;
                }
                OnSurface?.Invoke();
            } while (Surface.stillColliding.Contains(true));
            OnForceChange?.Invoke();
            OnVelChange?.Invoke(dt);
            OnPosChange?.Invoke(dt);
            for (int i = -10; i < 10; i++)
            {
                gr.DrawLine(Pens.LightGray, i * 60, 0, i * 60, 600);
                gr.DrawLine(Pens.LightGray, 0, i * 60, 600, i * 60);
                if (i == 5)
                {
                    gr.DrawLine(Pens.DarkGray, i * 60, 0, i * 60, 600);
                    gr.DrawLine(Pens.DarkGray, 0, i * 60, 600, i * 60);
                }
            }

            foreach (Body body in bodies)
            {
                body.DrawBody(gr);
            }
            foreach (Spring spring in springs)
            {
                spring.DrawSpring(gr);
            }
            foreach (Rope rope in ropes)
            {
                rope.DrawRope(gr);
            }
            foreach (Surface surface in surfaces)
            {
                surface.DrawSurface(gr);
            }
        }
Пример #7
0
        public override bool CustomGeometryFilter(IRhinoObject obj, IOnGeometry geo, OnCOMPONENT_INDEX ci)
        {
            if (geo != null)
            {
                IOnCurve crv = OnCurve.ConstCast(geo);
                if (crv != null)
                {
                    if (crv.IsClosed() && crv.IsPlanar())
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }

                IOnBrep brep = OnBrep.ConstCast(geo);
                if (brep != null)
                {
                    if (brep.m_F.Count() == 1)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }

                IOnSurface srf = OnSurface.ConstCast(geo);
                if (srf != null)
                {
                    return(true);
                }

                IOnMesh mesh = OnMesh.ConstCast(geo);
                if (mesh != null)
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #8
0
        public double UnRefract(OnSurface Location, RefractionOption RefOption, double ZdObs)
        {
            if (ZdObs <0.0 | ZdObs> 90.0)
            {
                throw new InvalidValueException("Unrefract", "Zenith distance", "0.0 to 90.0 degrees");
            }
            int    num1   = 0;
            double ZdObs1 = ZdObs;
            double num2;

            do
            {
                checked { ++num1; }
                num2    = ZdObs1 - Nov31.Refract(Location, RefOption, ZdObs1);
                ZdObs1 += ZdObs - num2;
                TL.LogMessage("Unrefract", Conversions.ToString(num1) + ": " + Conversions.ToString(num2) + " " + Conversions.ToString(ZdObs1));
            }while (!(num1 == 20 | num2 == ZdObs));
            TL.LogMessage("Unrefract", "Final: " + Conversions.ToString(num1) + ", Unrefracted zenith distance: " + Conversions.ToString(ZdObs1));
            return(ZdObs1);
        }
Пример #9
0
        /// <summary>
        /// Calculates the volume of an object
        /// </summary>
        public static double GetVolume(IRhinoObject obj)
        {
            if (null != obj && obj.IsSolid())
            {
                IOnSurface srf = OnSurface.ConstCast(obj.Geometry());
                if (null != srf)
                {
                    return(GetSurfaceVolume(srf));
                }

                IOnBrep brep = OnBrep.ConstCast(obj.Geometry());
                if (null != brep)
                {
                    return(GetBrepVolume(brep));
                }

                IOnMesh mesh = OnMesh.ConstCast(obj.Geometry());
                if (null != mesh)
                {
                    return(GetMeshVolume(mesh));
                }
            }
            return(0.0);
        }
        private static OnCurve CreateTrimmingCurve(
                              OnSurface s,
                              int side  // 0 = SW to SE
      // 1 = SE to NE
      // 2 = NE to NW
      // 3 = NW to SW
                              )
        {
            // A trimming curve is a 2d curve whose image lies in the surface's domain.
              // The "active" portion of the surface is to the left of the trimming curve.
              // An outer trimming loop consists of a simple closed curve running
              // counter-clockwise around the region it trims.
              // An inner trimming loop consists of a simple closed curve running
              // clockwise around the region the hole.

              On2dPoint from = new On2dPoint();
              On2dPoint to = new On2dPoint();
              double u0 = double.NaN, u1 = double.NaN, v0 = double.NaN, v1 = double.NaN;

              s.GetDomain(0, ref u0, ref u1);
              s.GetDomain(1, ref v0, ref v1);

              switch (side)
              {
            case 0:  // SW to SE
              from.x = u0; from.y = v0;
              to.x = u1; to.y = v0;
              break;
            case 1: // diagonal
              from.x = u1; from.y = v0;
              to.x = (u0 + u1) / 2; to.y = v1;
              break;
            case 2: // diagonal
              from.x = (u0 + u1) / 2; from.y = v1;
              to.x = u0; to.y = v0;
              break;
            default:
              return null;
              }

              OnCurve c2d = new OnLineCurve(from, to);
              if (c2d != null)
            c2d.SetDomain(0.0, 1.0);
              return c2d;
        }
        private static OnCurve CreateOuterTrimmingCurve(
                              OnSurface s,
                              int side // 0 = SW to SE
      // 1 = SE to NE
      // 2 = NE to NW
      // 3 = NW to SW
                              )
        {
            // A trimming curve is a 2d curve whose image lies in the surface's domain.
              // The "active" portion of the surface is to the left of the trimming curve.
              // An outer trimming loop consists of a simple closed curve running
              // counter-clockwise around the region it trims.

              //In cases when trim curve is not easily defined in surface domain,
              //use ON_Surface::Pullback only be careful about curve direction to ensure
              //loop trims run anti-clockwise for outer loop and clockwise for inner loop.

              //In this case, trim curves lie on the four edges of the surface
              On2dPoint from = new On2dPoint();
              On2dPoint to = new On2dPoint();
              double u0 = double.NaN, u1 = double.NaN, v0 = double.NaN, v1 = double.NaN;

              s.GetDomain(0, ref u0, ref u1);
              s.GetDomain(1, ref v0, ref v1);

              switch (side)
              {
            case 0:  // SW to SE
              from.x = u0; from.y = v0;
              to.x = u1; to.y = v0;
              break;
            case 1: // SE to NE
              from.x = u1; from.y = v0;
              to.x = u1; to.y = v1;
              break;
            case 2: // NE to NW
              from.x = u1; from.y = v1;
              to.x = u0; to.y = v1;
              break;
            case 3: // NW to SW
              from.x = u0; from.y = v1;
              to.x = u0; to.y = v0;
              break;
            default:
              return null;
              }

              OnCurve c2d = new OnLineCurve(from, to);
              if (c2d != null)
            c2d.SetDomain(0.0, 1.0);
              return c2d;
        }
        //Trim curves must run is clockwise direction
        private static OnCurve CreateInnerTrimmingCurve(
                  OnSurface s,
                  int side // 0 = near SE to SW
      // 1 = near SW to NW
      // 2 = near NW to NE
      // 3 = near NE to SE
                  )
        {
            // A trimming curve is a 2d curve whose image lies in the surface's domain.
              // The "active" portion of the surface is to the left of the trimming curve.
              // An inner trimming loop consists of a simple closed curve running
              // clockwise around the region the hole.

              //In this case, trim curves lie with 0.2 domain distance from surface edge
              On2dPoint from = new On2dPoint();
              On2dPoint to = new On2dPoint();
              double u0 = double.NaN,
              u1 = double.NaN,
              v0 = double.NaN,
              v1 = double.NaN;

              s.GetDomain(0, ref u0, ref u1);
              s.GetDomain(1, ref v0, ref v1);

              double udis = 0.2 * (u1 - u0);
              double vdis = 0.2 * (v1 - v0);

              u0 += udis;
              u1 -= udis;
              v0 += vdis;
              v1 -= vdis;

              switch (side)
              {
            case 0:  // near SE to SW
              from.x = u1; from.y = v0;
              to.x = u0; to.y = v0;
              break;
            case 1: // near SW to NW
              from.x = u0; from.y = v0;
              to.x = u0; to.y = v1;
              break;
            case 2: // near NW to NE
              from.x = u0; from.y = v1;
              to.x = u1; to.y = v1;
              break;
            case 3: // near NE to SE
              from.x = u1; from.y = v1;
              to.x = u1; to.y = v0;
              break;
            default:
              return null;
              }

              OnCurve c2d = new OnLineCurve(from, to);
              if (c2d != null)
            c2d.SetDomain(0.0, 1.0);

              return c2d;
        }
        private static int MakeInnerTrimmingLoop(ref OnBrep brep,                        // returns index of loop
                                                 ref OnBrepFace face,                    // face loop is on
                                                 int vSWi, int vSEi, int vNEi, int vNWi, // Indices of hole vertices
                                                 int eSi,                                // index of edge close to south side of surface
                                                 int eS_dir,                             // orientation of edge with respect to surface trim
                                                 int eEi,                                // index of edge close to east side of surface
                                                 int eE_dir,                             // orientation of edge with respect to surface trim
                                                 int eNi,                                // index of edge close to north side of surface
                                                 int eN_dir,                             // orientation of edge with respect to surface trim
                                                 int eWi,                                // index of edge close to west side of surface
                                                 int eW_dir                              // orientation of edge with respect to surface trim
                                                 )
        {
            OnSurface srf = brep.m_S[face.m_si];
            //Create new inner loop
            OnBrepLoop loop = brep.NewLoop(IOnBrepLoop.TYPE.inner, ref face);

            // Create trimming curves running counter clockwise around the surface's domain.
            // Note that trims of outer loops run counter clockwise while trims of inner loops (holes) run clockwise.
            // Also note that when trims locate on surface N,S,E or W ends, then trim_iso becomes N_iso, S_iso, E_iso and W_iso respectfully.
            // While if trim is parallel to surface N,S or E,W, then trim iso becomes y_iso and x_iso respectfully.
            // All other cases, iso is set to not_iso

            // Start near the south side
            OnCurve c2;
            int     c2i, ei = 0;
            bool    bRev3d = false;

            IOnSurface.ISO iso = IOnSurface.ISO.not_iso;

            for (int side = 0; side < 4; side++)
            {
                // side: 0=near south(y_iso), 1=near west(x_iso), 2=near north(y_iso), 3=near east(x_iso)

                //Create trim 2d curve
                c2 = CreateInnerTrimmingCurve(srf, side);

                //Add trimming curve to brep trmming curves array
                c2i = brep.m_C2.Count();
                brep.m_C2.Append(c2);

                switch (side)
                {
                case 0: // near south
                    ei     = eSi;
                    bRev3d = (eS_dir == -1);
                    iso    = IOnSurface.ISO.y_iso;
                    break;

                case 1: // near west
                    ei     = eEi;
                    bRev3d = (eE_dir == -1);
                    iso    = IOnSurface.ISO.x_iso;
                    break;

                case 2: // near north
                    ei     = eNi;
                    bRev3d = (eN_dir == -1);
                    iso    = IOnSurface.ISO.y_iso;
                    break;

                case 3: // near east
                    ei     = eWi;
                    bRev3d = (eW_dir == -1);
                    iso    = IOnSurface.ISO.x_iso;
                    break;
                }

                //Create new trim topology that references edge, direction reletive to edge, loop and trim curve geometry
                OnBrepEdge edge = brep.m_E[ei];
                OnBrepTrim trim = brep.NewTrim(ref edge, bRev3d, ref loop, c2i);
                if (trim != null)
                {
                    trim.m_iso  = iso;
                    trim.m_type = IOnBrepTrim.TYPE.boundary; // This one b-rep face, so all trims are boundary ones.
                    trim.set_m_tolerance(0, 0.0);            // This simple example is exact - for models with non-exact
                    trim.set_m_tolerance(1, 0.0);            // data, set tolerance as explained in definition of ON_BrepTrim.
                }
            }

            return(loop.m_loop_index);
        }
        private static int MakeTrimmingLoop(ref OnBrep brep,        // returns index of loop
                                            ref OnBrepFace face,    // face loop is on
                                            int v0, int v1, int v2, // Indices of corner vertices listed in A,B,C order
                                            int e0,                 // index of first edge
                                            int e0_dir,             // orientation of edge
                                            int e1,                 // index second edgee
                                            int e1_dir,             // orientation of edge
                                            int e2,                 // index third edge
                                            int e2_dir              // orientation of edge
                                            )
        {
            OnSurface srf = brep.m_S[face.m_si];

            //Create new loop
            OnBrepLoop loop = brep.NewLoop(IOnBrepLoop.TYPE.outer, ref face);

            // Create trimming curves running counter clockwise around the surface's domain.
            // Note that trims of outer loops run counter clockwise while trims of inner loops (holes) run anti-clockwise.
            // Also note that when trims locate on surface N,S,E or W ends, then trim_iso becomes N_iso, S_iso, E_iso and W_iso respectfully.
            // While if trim is parallel to surface N,S or E,W, then trim is becomes y_iso and x_iso respectfully.

            // Start at the south side
            OnCurve c2;
            int     c2i, ei = 0;
            bool    bRev3d = false;

            IOnSurface.ISO iso = IOnSurface.ISO.not_iso;

            for (int side = 0; side < 3; side++)
            {
                // side: 0=south, 1=east, 2=north, 3=west

                c2 = CreateTrimmingCurve(srf, side);

                //Add trimming curve to brep trmming curves array
                c2i = brep.m_C2.Count();
                brep.m_C2.Append(c2);

                switch (side)
                {
                case 0: // south
                    ei     = e0;
                    bRev3d = (e0_dir == -1);
                    iso    = IOnSurface.ISO.S_iso;
                    break;

                case 1: // diagonal
                    ei     = e1;
                    bRev3d = (e1_dir == -1);
                    iso    = IOnSurface.ISO.not_iso;
                    break;

                case 2: // diagonal
                    ei     = e2;
                    bRev3d = (e2_dir == -1);
                    iso    = IOnSurface.ISO.not_iso;
                    break;
                }

                //Create new trim topology that references edge, direction reletive to edge, loop and trim curve geometry
                OnBrepEdge edge = brep.m_E[ei];
                OnBrepTrim trim = brep.NewTrim(ref edge, bRev3d, ref loop, c2i);
                if (trim != null)
                {
                    trim.m_iso  = iso;
                    trim.m_type = IOnBrepTrim.TYPE.boundary; // This one b-rep face, so all trims are boundary ones.
                    trim.set_m_tolerance(0, 0.0);            // This simple example is exact - for models with non-exact
                    trim.set_m_tolerance(1, 0.0);            // data, set tolerance as explained in definition of ON_BrepTrim.
                }
            }
            return(loop.m_loop_index);
        }
Пример #15
0
 private static extern double NOVAS_Refract(ref OnSurface location, RefractionOption refractionOption, double zdObs);
Пример #16
0
 /// <summary>
 /// Computes atmospheric refraction in zenith distance
 /// </summary>
 /// <param name="location"></param>
 /// <param name="refractionOption"></param>
 /// <param name="zdObs"></param>
 /// <returns></returns>
 public static double Refract(ref OnSurface location, RefractionOption refractionOption, double zdObs)
 {
     return(NOVAS_Refract(ref location, refractionOption, zdObs));
 }
Пример #17
0
 public override byte[] Serialize(Game game, Endianness endianness)
 {
     using (var writer = new EndianBinaryWriter(endianness))
     {
         writer.Write(SerializeBase(endianness));
         writer.Write(DamageType);
         writer.Write(Sticky);
         writer.Write(DamageFlags);
         writer.Write(SurfaceType);
         writer.Write(Phys_Pad);
         writer.Write(SlideStart);
         writer.Write(SlideStop);
         writer.Write(PhysicsFlags.FlagValueByte);
         writer.Write(Friction);
         writer.Write(zSurfMatFX.Serialize(game, endianness));
         writer.Write(zSurfColorFX.Serialize(game, endianness));
         writer.Write(TextureAnimFlags.FlagValueInt);
         writer.Write(zSurfTextureAnim1.Serialize(game, endianness));
         writer.Write(zSurfTextureAnim2.Serialize(game, endianness));
         writer.Write(UVEffectsFlags.FlagValueInt);
         writer.Write(zSurfUVFX.Serialize(game, endianness));
         if (game != Game.Scooby)
         {
             writer.Write(zSurfUVFX2.Serialize(game, endianness));
             writer.Write(On);
             writer.Write((byte)0);
             writer.Write((byte)0);
             writer.Write((byte)0);
         }
         writer.Write(OutOfBoundsDelay);
         writer.Write(WalljumpScaleXZ);
         writer.Write(WalljumpScaleY);
         writer.Write(DamageTimer);
         writer.Write(DamageBounce);
         if (game == Game.Scooby)
         {
             writer.Write(UnknownInt);
             writer.Write(On);
             writer.Write((byte)0);
             writer.Write((byte)0);
             writer.Write((byte)0);
         }
         if (game == Game.Incredibles)
         {
             writer.Write(ImpactSound_AssetID);
             writer.Write(DashImpactType);
             writer.Write((byte)0);
             writer.Write((byte)0);
             writer.Write((byte)0);
             writer.Write(DashImpactThrowBack);
             writer.Write(DashSprayMagnitude);
             writer.Write(DashCoolRate);
             writer.Write(DashCoolAmount);
             writer.Write(DashPass);
             writer.Write(DashRampMaxDistance);
             writer.Write(DashRampMinDistance);
             writer.Write(DashRampKeySpeed);
             writer.Write(DashRampMaxHeight);
             writer.Write(DashRampTarget_MovePoint_AssetID);
             writer.Write(DamageAmount);
             writer.Write((int)HitSourceDamageType);
             writer.Write(OffSurface.Serialize(game, endianness));
             writer.Write(OnSurface.Serialize(game, endianness));
             writer.Write(HitDecalData0.Serialize(game, endianness));
             writer.Write(HitDecalData1.Serialize(game, endianness));
             writer.Write(HitDecalData2.Serialize(game, endianness));
             writer.Write(OffSurfaceTime);
             writer.Write(SwimmableSurface);
             writer.Write(DashFall);
             writer.Write(NeedButtonPress);
             writer.Write(DashAttack);
             writer.Write(FootstepDecals);
             writer.Write(0);
             writer.Write(DrivingSurfaceType);
             writer.Write((byte)0);
             writer.Write((byte)0);
         }
         writer.Write(SerializeLinks(endianness));
         return(writer.ToArray());
     }
 }
Пример #18
0
        private ASCOM.Astrometry.AstroUtils.AstroUtils.BodyInfo BodyAltitude(EventType TypeOfEvent, double JD, double Hour, double Latitude, double Longitude)
        {
            Object3   CelObject = new Object3();
            OnSurface onSurface = new OnSurface();
            CatEntry3 catEntry3 = new CatEntry3();
            SkyPos    Output    = new SkyPos();
            Observer  Location  = new Observer();

            ASCOM.Astrometry.AstroUtils.AstroUtils.BodyInfo bodyInfo = new ASCOM.Astrometry.AstroUtils.AstroUtils.BodyInfo();
            double JdHigh = JD + Hour / 24.0;
            double DeltaT = DeltatCode.DeltaTCalc(JD);

            switch (TypeOfEvent)
            {
            case EventType.SunRiseSunset:
            case EventType.CivilTwilight:
            case EventType.NauticalTwilight:
            case EventType.AmateurAstronomicalTwilight:
            case EventType.AstronomicalTwilight:
                CelObject.Name   = "Sun";
                CelObject.Number = Body.Sun;
                break;

            case EventType.MoonRiseMoonSet:
                CelObject.Name   = "Moon";
                CelObject.Number = Body.Moon;
                break;

            case EventType.MercuryRiseSet:
                CelObject.Name   = "Mercury";
                CelObject.Number = Body.Mercury;
                break;

            case EventType.VenusRiseSet:
                CelObject.Name   = "Venus";
                CelObject.Number = Body.Venus;
                break;

            case EventType.MarsRiseSet:
                CelObject.Name   = "Mars";
                CelObject.Number = Body.Mars;
                break;

            case EventType.JupiterRiseSet:
                CelObject.Name   = "Jupiter";
                CelObject.Number = Body.Jupiter;
                break;

            case EventType.SaturnRiseSet:
                CelObject.Name   = "Saturn";
                CelObject.Number = Body.Saturn;
                break;

            case EventType.UranusRiseSet:
                CelObject.Name   = "Uranus";
                CelObject.Number = Body.Uranus;
                break;

            case EventType.NeptuneRiseSet:
                CelObject.Name   = "Neptune";
                CelObject.Number = Body.Neptune;
                break;

            case EventType.PlutoRiseSet:
                CelObject.Name   = "Pluto";
                CelObject.Number = Body.Pluto;
                break;

            default:
                throw new InvalidValueException("TypeOfEvent", TypeOfEvent.ToString(), "Unknown type of event");
            }
            CelObject.Star  = catEntry3;
            CelObject.Type  = ASCOM.Astrometry.ObjectType.MajorPlanetSunOrMoon;
            Location.OnSurf = onSurface;
            Location.Where  = ObserverLocation.EarthGeoCenter;
            int num1 = (int)Nov31.Place(JdHigh + DeltaT * 1.15740740740741E-05, CelObject, Location, DeltaT, CoordSys.EquinoxOfDate, Accuracy.Full, ref Output);

            bodyInfo.Distance = Output.Dis * 149597870.691;
            double Gst = 0;

            Nov31.SiderealTime(JdHigh, 0.0, DeltaT, GstType.GreenwichApparentSiderealTime, ASCOM.Astrometry.Method.EquinoxBased, Accuracy.Full, ref Gst);
            double num2 = 15.0 * (Range(Gst + Longitude * (1.0 / 15.0), 0.0, true, 24.0, false) - Output.RA);

            bodyInfo.Altitude = Math.Asin(Math.Sin(Latitude * (Math.PI / 180.0)) * Math.Sin(Output.Dec * (Math.PI / 180.0)) + Math.Cos(Latitude * (Math.PI / 180.0)) * Math.Cos(Output.Dec * (Math.PI / 180.0)) * Math.Cos(num2 * (Math.PI / 180.0))) * (180.0 / Math.PI);
            switch (TypeOfEvent)
            {
            case EventType.MoonRiseMoonSet:
                bodyInfo.Radius = 1737.0;
                break;

            case EventType.MercuryRiseSet:
                bodyInfo.Radius = 2439.7;
                break;

            case EventType.VenusRiseSet:
                bodyInfo.Radius = 2439.7;
                break;

            case EventType.MarsRiseSet:
                bodyInfo.Radius = 3396.2;
                break;

            case EventType.JupiterRiseSet:
                bodyInfo.Radius = 69911.0;
                break;

            case EventType.SaturnRiseSet:
                bodyInfo.Radius = 6051.8;
                break;

            case EventType.UranusRiseSet:
                bodyInfo.Radius = 24973.0;
                break;

            case EventType.NeptuneRiseSet:
                bodyInfo.Radius = 24767.0;
                break;

            case EventType.PlutoRiseSet:
                bodyInfo.Radius = 1153.0;
                break;

            default:
                bodyInfo.Radius = 696342.0;
                break;
            }
            return(bodyInfo);
        }
Пример #19
0
        public ArrayList EventTimes(EventType TypeofEvent, int Day, int Month, int Year, double SiteLatitude, double SiteLongitude, double SiteTimeZone)
        {
            OnSurface     Location    = new OnSurface();
            ArrayList     arrayList   = new ArrayList();
            List <double> doubleList1 = new List <double>();
            List <double> doubleList2 = new List <double>();
            bool          flag1       = false;
            bool          flag2       = false;

            try
            {
                DateTime.Parse(Conversions.ToString(Month) + "/" + Conversions.ToString(Day) + "/" + Conversions.ToString(Year), (IFormatProvider)CultureInfo.InvariantCulture);
            }
            catch (FormatException ex)
            {
                //ProjectData.SetProjectError((Exception) ex);
                throw new InvalidValueException("Day or Month", Day.ToString() + " " + Month.ToString() + " " + Year.ToString(), "Day must not exceed the number of days in the month");
            }
            catch (Exception ex)
            {
                //ProjectData.SetProjectError(ex);
                TL.LogMessageCrLf("EventTimes", ex.ToString());
                throw;
            }
            double JD = Nov31.JulianDate(checked ((short)Year), checked ((short)Month), checked ((short)Day), 0.0) - SiteTimeZone / 24.0;

            Location.Latitude  = SiteLatitude;
            Location.Longitude = SiteLongitude;
            double num1  = Nov31.Refract(Location, RefractionOption.StandardRefraction, 90.0);
            double Hour  = 1.0;
            bool   flag3 = false;

            do
            {
                ASCOM.Astrometry.AstroUtils.AstroUtils.BodyInfo bodyInfo1 = BodyAltitude(TypeofEvent, JD, Hour - 1.0, SiteLatitude, SiteLongitude);
                ASCOM.Astrometry.AstroUtils.AstroUtils.BodyInfo bodyInfo2 = BodyAltitude(TypeofEvent, JD, Hour, SiteLatitude, SiteLongitude);
                ASCOM.Astrometry.AstroUtils.AstroUtils.BodyInfo bodyInfo3 = BodyAltitude(TypeofEvent, JD, Hour + 1.0, SiteLatitude, SiteLongitude);
                double num2;
                double num3;
                double num4;
                switch (TypeofEvent)
                {
                case EventType.SunRiseSunset:
                    num2 = bodyInfo1.Altitude - -5.0 / 6.0;
                    num3 = bodyInfo2.Altitude - -5.0 / 6.0;
                    num4 = bodyInfo3.Altitude - -5.0 / 6.0;
                    break;

                case EventType.MoonRiseMoonSet:
                    num2 = bodyInfo1.Altitude - 365432.481734439 / bodyInfo1.Distance + bodyInfo1.Radius * (180.0 / Math.PI) / bodyInfo1.Distance + num1;
                    num3 = bodyInfo2.Altitude - 365432.481734439 / bodyInfo2.Distance + bodyInfo2.Radius * (180.0 / Math.PI) / bodyInfo2.Distance + num1;
                    num4 = bodyInfo3.Altitude - 365432.481734439 / bodyInfo3.Distance + bodyInfo3.Radius * (180.0 / Math.PI) / bodyInfo3.Distance + num1;
                    break;

                case EventType.CivilTwilight:
                    num2 = bodyInfo1.Altitude - -6.0;
                    num3 = bodyInfo2.Altitude - -6.0;
                    num4 = bodyInfo3.Altitude - -6.0;
                    break;

                case EventType.NauticalTwilight:
                    num2 = bodyInfo1.Altitude - -12.0;
                    num3 = bodyInfo2.Altitude - -12.0;
                    num4 = bodyInfo3.Altitude - -12.0;
                    break;

                case EventType.AmateurAstronomicalTwilight:
                    num2 = bodyInfo1.Altitude - -15.0;
                    num3 = bodyInfo2.Altitude - -15.0;
                    num4 = bodyInfo3.Altitude - -15.0;
                    break;

                case EventType.AstronomicalTwilight:
                    num2 = bodyInfo1.Altitude - -18.0;
                    num3 = bodyInfo2.Altitude - -18.0;
                    num4 = bodyInfo3.Altitude - -18.0;
                    break;

                default:
                    num2 = bodyInfo1.Altitude + num1 + 180.0 / Math.PI * bodyInfo2.Radius / bodyInfo2.Distance;
                    num3 = bodyInfo2.Altitude + num1 + 180.0 / Math.PI * bodyInfo2.Radius / bodyInfo2.Distance;
                    num4 = bodyInfo3.Altitude + num1 + 180.0 / Math.PI * bodyInfo2.Radius / bodyInfo2.Distance;
                    break;
                }
                if (Hour == 1.0)
                {
                    flag3 = num2 >= 0.0;
                }
                double num5  = num3;
                double num6  = 0.5 * (num4 - num2);
                double num7  = 0.5 * (num4 + num2) - num3;
                double num8  = -num6 / (2.0 * num7);
                double num9  = (num7 * num8 + num6) * num8 + num5;
                double d     = num6 * num6 - 4.0 * num7 * num5;
                double num10 = double.NaN;
                double num11 = double.NaN;
                int    num12 = 0;
                if (d > 0.0)
                {
                    double num13 = 0.5 * Math.Sqrt(d) / Math.Abs(num7);
                    num10 = num8 - num13;
                    num11 = num8 + num13;
                    if (Math.Abs(num10) <= 1.0)
                    {
                        checked { ++num12; }
                    }
                    if (Math.Abs(num11) <= 1.0)
                    {
                        checked { ++num12; }
                    }
                    if (num10 < -1.0)
                    {
                        num10 = num11;
                    }
                }
                switch (num12)
                {
                case 1:
                    if (num2 < 0.0)
                    {
                        flag1 = true;
                        doubleList1.Add(Hour + num10);
                        break;
                    }
                    flag2 = true;
                    doubleList2.Add(Hour + num10);
                    break;

                case 2:
                    if (num2 < 0.0)
                    {
                        doubleList1.Add(Hour + num10);
                        doubleList2.Add(Hour + num11);
                    }
                    else
                    {
                        doubleList1.Add(Hour + num11);
                        doubleList2.Add(Hour + num10);
                    }
                    flag1 = true;
                    flag2 = true;
                    break;
                }
                Hour += 2.0;
            }while (!(flag1 & flag2 & Math.Abs(SiteLatitude) < 60.0 | Hour == 25.0));
            arrayList.Add((object)flag3);
            arrayList.Add((object)doubleList1.Count);
            arrayList.Add((object)doubleList2.Count);
            List <double> .Enumerator enumerator1 = default(List <double> .Enumerator);
            try
            {
                enumerator1 = doubleList1.GetEnumerator();
                while (enumerator1.MoveNext())
                {
                    double current = enumerator1.Current;
                    arrayList.Add((object)current);
                }
            }
            finally
            {
                enumerator1.Dispose();
            }
            List <double> .Enumerator enumerator2 = default(List <double> .Enumerator);
            try
            {
                enumerator2 = doubleList2.GetEnumerator();
                while (enumerator2.MoveNext())
                {
                    double current = enumerator2.Current;
                    arrayList.Add((object)current);
                }
            }
            finally
            {
                enumerator2.Dispose();
            }
            return(arrayList);
        }
        //Trim curves must run is clockwise direction
        private static OnCurve CreateInnerTrimmingCurve(
            OnSurface s,
            int side       // 0 = near SE to SW
            // 1 = near SW to NW
            // 2 = near NW to NE
            // 3 = near NE to SE
            )
        {
            // A trimming curve is a 2d curve whose image lies in the surface's domain.
            // The "active" portion of the surface is to the left of the trimming curve.
            // An inner trimming loop consists of a simple closed curve running
            // clockwise around the region the hole.

            //In this case, trim curves lie with 0.2 domain distance from surface edge
            On2dPoint from = new On2dPoint();
            On2dPoint to   = new On2dPoint();
            double    u0   = double.NaN,
                      u1   = double.NaN,
                      v0   = double.NaN,
                      v1   = double.NaN;

            s.GetDomain(0, ref u0, ref u1);
            s.GetDomain(1, ref v0, ref v1);

            double udis = 0.2 * (u1 - u0);
            double vdis = 0.2 * (v1 - v0);

            u0 += udis;
            u1 -= udis;
            v0 += vdis;
            v1 -= vdis;

            switch (side)
            {
            case 0: // near SE to SW
                from.x = u1; from.y = v0;
                to.x   = u0; to.y = v0;
                break;

            case 1: // near SW to NW
                from.x = u0; from.y = v0;
                to.x   = u0; to.y = v1;
                break;

            case 2: // near NW to NE
                from.x = u0; from.y = v1;
                to.x   = u1; to.y = v1;
                break;

            case 3: // near NE to SE
                from.x = u1; from.y = v1;
                to.x   = u1; to.y = v0;
                break;

            default:
                return(null);
            }

            OnCurve c2d = new OnLineCurve(from, to);

            if (c2d != null)
            {
                c2d.SetDomain(0.0, 1.0);
            }

            return(c2d);
        }
Пример #21
0
        public PositionVector GetLocalPosition(double tjd, Site site)
        {
            double[]  pos2_1       = new double[4];
            double[]  pos2_2       = new double[4];
            double[]  earthvector1 = new double[4];
            double[]  vel1         = new double[4];
            double[]  earthvector2 = new double[4];
            double[]  numArray1    = new double[4];
            double[]  pos          = new double[4];
            double[]  vel2         = new double[4];
            double[]  pos2_3       = new double[4];
            double[]  pos2_4       = new double[4];
            double[]  pos2_5       = new double[4];
            double[]  numArray2    = new double[4];
            double[]  peb          = new double[4];
            double[]  veb          = new double[4];
            double[]  pes          = new double[4];
            double[]  ves          = new double[4];
            Object3   SsBody       = new Object3();
            OnSurface onSurface    = new OnSurface();

            if (!this.m_bDTValid)
            {
                this.m_deltat = DeltatCode.DeltaTCalc(tjd);
            }
            double   num1   = tjd - this.m_deltat / 86400.0;
            SiteInfo locale = new SiteInfo();

            try
            {
                locale.Latitude = site.Latitude;
            }
            catch (Exception ex)
            {
                //ProjectData.SetProjectError(ex);
                throw new ValueNotAvailableException("Star:GetTopocentricPosition Site.Latitude is not available");
            }
            try
            {
                locale.Longitude = site.Longitude;
            }
            catch (Exception ex)
            {
                //ProjectData.SetProjectError(ex);
                throw new ValueNotAvailableException("Star:GetTopocentricPosition Site.Longitude is not available");
            }
            try
            {
                locale.Height = site.Height;
            }
            catch (Exception ex)
            {
                //ProjectData.SetProjectError(ex);
                throw new ValueNotAvailableException("Star:GetTopocentricPosition Site.Height is not available");
            }
            PositionVector positionVector;

            if (this.m_type == BodyType.Moon & (this.m_number == 10 | this.m_number == 11))
            {
                onSurface.Height      = site.Height;
                onSurface.Latitude    = site.Latitude;
                onSurface.Longitude   = site.Longitude;
                onSurface.Pressure    = site.Pressure;
                onSurface.Temperature = site.Temperature;
                SsBody.Number         = CommonCode.NumberToBody(this.m_number);
                SsBody.Type           = ASCOM.Astrometry.ObjectType.MajorPlanetSunOrMoon;
                RefractionOption RefOption = RefractionOption.NoRefraction;
                double           Ra        = 0;
                double           Dec       = 0;
                double           Dis       = 0;
                this.Nov31.LocalPlanet(tjd, SsBody, this.m_deltat, onSurface, Accuracy.Full, ref Ra, ref Dec, ref Dis);
                double Zd   = 0;
                double Az   = 0;
                double RaR  = 0;
                double DecR = 0;
                this.Nov31.Equ2Hor(num1, this.m_deltat, Accuracy.Full, 0.0, 0.0, onSurface, Ra, Dec, RefOption, ref Zd, ref Az, ref RaR, ref DecR);
                this.Nov31.RaDec2Vector(RaR, DecR, Dis, ref numArray2);
                positionVector = new PositionVector(numArray2[0], numArray2[1], numArray2[2], RaR, DecR, Dis, Dis / 173.14463348, Az, 90.0 - Zd);
            }
            else
            {
                double tdb = 0;
                EphemerisCode.get_earth_nov(ref this.m_earthephobj, tjd, ref tdb, ref peb, ref veb, ref pes, ref ves);
                double mobl = 0;
                double tobl = 0;
                double eq   = 0;
                double dpsi = 0;
                double deps = 0;
                NOVAS2.EarthTilt(tdb, ref mobl, ref tobl, ref eq, ref dpsi, ref deps);
                double gst = 0;
                NOVAS2.SiderealTime(num1, 0.0, eq, ref gst);
                NOVAS2.Terra(ref locale, gst, ref pos, ref vel2);
                int num2 = (int)NOVAS2.Nutate(tdb, NutationDirection.TrueToMean, pos, ref pos2_3);
                NOVAS2.Precession(tdb, pos2_3, 2451545.0, ref pos2_1);
                int num3 = (int)NOVAS2.Nutate(tdb, NutationDirection.TrueToMean, vel2, ref pos2_4);
                NOVAS2.Precession(tdb, pos2_4, 2451545.0, ref pos2_2);
                int index = 0;
                do
                {
                    earthvector1[index] = peb[index] + pos2_1[index];
                    vel1[index]         = veb[index] + pos2_2[index];
                    earthvector2[index] = pes[index] + pos2_1[index];
                    numArray1[index]    = ves[index] + pos2_2[index];
                    checked { ++index; }
                }while (index <= 2);
                EphemerisCode.ephemeris_nov(ref this.m_ephobj, tdb, this.m_type, this.m_number, this.m_name, Origin.Barycentric, ref pos, ref vel2);
                double lighttime = 0;
                NOVAS2.BaryToGeo(pos, earthvector1, ref pos2_3, ref lighttime);
                double num4 = tdb - lighttime;
                int    num5 = 0;
                double tjd1;
                do
                {
                    tjd1 = num4;
                    EphemerisCode.ephemeris_nov(ref this.m_ephobj, tjd1, this.m_type, this.m_number, this.m_name, Origin.Barycentric, ref pos, ref vel2);
                    NOVAS2.BaryToGeo(pos, earthvector1, ref pos2_3, ref lighttime);
                    num4 = tdb - lighttime;
                    checked { ++num5; }
                }while (Math.Abs(num4 - tjd1) > 1E-06 & num5 < 100);
                if (num5 >= 100)
                {
                    throw new HelperException("Planet:GetLocalPoition ephemeris_nov did not converge in 100 iterations");
                }
                int num6 = (int)NOVAS2.SunField(pos2_3, earthvector2, ref pos2_5);
                int num7 = (int)NOVAS2.Aberration(pos2_5, vel1, lighttime, ref numArray2);
                positionVector   = new PositionVector();
                positionVector.x = numArray2[0];
                positionVector.y = numArray2[1];
                positionVector.z = numArray2[2];
            }
            return(positionVector);
        }
Пример #22
0
        public PositionVector GetTopocentricPosition(double tjd, Site site, bool Refract)
        {
            double[]  pos1         = new double[4];
            double[]  pos2_1       = new double[4];
            double[]  pos2_2       = new double[4];
            double[]  pos2_3       = new double[4];
            double[]  pos2_4       = new double[4];
            double[]  vel1         = new double[4];
            double[]  pos2_5       = new double[4];
            double[]  pos2_6       = new double[4];
            double[]  pos2_7       = new double[4];
            double[]  earthvector1 = new double[4];
            double[]  pos2         = new double[4];
            double[]  vel2         = new double[4];
            double[]  earthvector2 = new double[4];
            double[]  peb          = new double[4];
            double[]  veb          = new double[4];
            double[]  pes          = new double[4];
            double[]  ves          = new double[4];
            Object3   SsBody       = new Object3();
            OnSurface onSurface    = new OnSurface();

            if (!this.m_bDTValid)
            {
                this.m_deltat = DeltatCode.DeltaTCalc(tjd);
            }
            double   num1     = tjd - this.m_deltat / 86400.0;
            SiteInfo siteInfo = new SiteInfo();

            try
            {
                siteInfo.Latitude = site.Latitude;
            }
            catch (Exception ex)
            {
                //ProjectData.SetProjectError(ex);
                throw new ValueNotAvailableException("Star:GetTopocentricPosition Site.Latitude is not available");
            }
            try
            {
                siteInfo.Longitude = site.Longitude;
            }
            catch (Exception ex)
            {
                //ProjectData.SetProjectError(ex);
                throw new ValueNotAvailableException("Star:GetTopocentricPosition Site.Longitude is not available");
            }
            try
            {
                siteInfo.Height = site.Height;
            }
            catch (Exception ex)
            {
                //ProjectData.SetProjectError(ex);
                throw new ValueNotAvailableException("Star:GetTopocentricPosition Site.Height is not available");
            }
            PositionVector positionVector;

            if (this.m_type == BodyType.Moon & (this.m_number == 10 | this.m_number == 11))
            {
                onSurface.Height      = site.Height;
                onSurface.Latitude    = site.Latitude;
                onSurface.Longitude   = site.Longitude;
                onSurface.Pressure    = site.Pressure;
                onSurface.Temperature = site.Temperature;
                SsBody.Number         = CommonCode.NumberToBody(this.m_number);
                SsBody.Type           = ASCOM.Astrometry.ObjectType.MajorPlanetSunOrMoon;
                RefractionOption RefOption = !Refract ? RefractionOption.NoRefraction : RefractionOption.LocationRefraction;
                double           Ra        = 0;
                double           Dec       = 0;
                double           Dis       = 0;
                this.Nov31.TopoPlanet(tjd, SsBody, this.m_deltat, onSurface, Accuracy.Full, ref Ra, ref Dec, ref Dis);
                double Zd   = 0;
                double Az   = 0;
                double RaR  = 0;
                double DecR = 0;
                this.Nov31.Equ2Hor(num1, this.m_deltat, Accuracy.Full, 0.0, 0.0, onSurface, Ra, Dec, RefOption, ref Zd, ref Az, ref RaR, ref DecR);
                this.Nov31.RaDec2Vector(RaR, DecR, Dis, ref pos2);
                positionVector = new PositionVector(pos2[0], pos2[1], pos2[2], RaR, DecR, Dis, Dis / 173.14463348, Az, 90.0 - Zd);
            }
            else
            {
                double tdb = 0;
                EphemerisCode.get_earth_nov(ref this.m_earthephobj, tjd, ref tdb, ref peb, ref veb, ref pes, ref ves);
                double mobl = 0;
                double tobl = 0;
                double eq   = 0;
                double dpsi = 0;
                double deps = 0;
                NOVAS2.EarthTilt(tdb, ref mobl, ref tobl, ref eq, ref dpsi, ref deps);
                double gst = 0;
                NOVAS2.SiderealTime(num1, 0.0, eq, ref gst);
                NOVAS2.Terra(ref siteInfo, gst, ref pos1, ref vel1);
                int num2 = (int)NOVAS2.Nutate(tdb, NutationDirection.TrueToMean, pos1, ref pos2_1);
                NOVAS2.Precession(tdb, pos2_1, 2451545.0, ref pos2_6);
                int num3 = (int)NOVAS2.Nutate(tdb, NutationDirection.TrueToMean, vel1, ref pos2_5);
                NOVAS2.Precession(tdb, pos2_5, 2451545.0, ref pos2_7);
                short num4 = 0;
                do
                {
                    earthvector1[(int)num4] = peb[(int)num4] + pos2_6[(int)num4];
                    vel2[(int)num4]         = veb[(int)num4] + pos2_7[(int)num4];
                    earthvector2[(int)num4] = pes[(int)num4] + pos2_6[(int)num4];
                    ++num4;
                }while ((int)num4 <= 2);
                EphemerisCode.ephemeris_nov(ref this.m_ephobj, tdb, this.m_type, this.m_number, this.m_name, Origin.Barycentric, ref pos1, ref vel1);
                double lighttime = 0;
                NOVAS2.BaryToGeo(pos1, earthvector1, ref pos2_1, ref lighttime);
                double num5 = tdb - lighttime;
                int    num6 = 0;
                double tjd1;
                do
                {
                    tjd1 = num5;
                    EphemerisCode.ephemeris_nov(ref this.m_ephobj, tjd1, this.m_type, this.m_number, this.m_name, Origin.Barycentric, ref pos1, ref vel1);
                    NOVAS2.BaryToGeo(pos1, earthvector1, ref pos2_1, ref lighttime);
                    num5 = tdb - lighttime;
                    checked { ++num6; }
                }while (Math.Abs(num5 - tjd1) > 1E-06 & num6 < 100);
                if (num6 >= 100)
                {
                    throw new HelperException("Planet:GetTopocentricPoition ephemeris_nov did not converge in 100 iterations");
                }
                int num7 = (int)NOVAS2.SunField(pos2_1, earthvector2, ref pos2_2);
                int num8 = (int)NOVAS2.Aberration(pos2_2, vel2, lighttime, ref pos2_3);
                NOVAS2.Precession(2451545.0, pos2_3, tdb, ref pos2_4);
                int              num9       = (int)NOVAS2.Nutate(tdb, NutationDirection.MeanToTrue, pos2_4, ref pos2);
                double           ra         = 0;
                double           dec        = 0;
                int              num10      = (int)NOVAS2.Vector2RADec(pos2, ref ra, ref dec);
                double           num11      = Math.Sqrt(Math.Pow(pos2[0], 2.0) + Math.Pow(pos2[1], 2.0) + Math.Pow(pos2[2], 2.0));
                RefractionOption ref_option = RefractionOption.NoRefraction;
                if (Refract)
                {
                    bool flag = true;
                    try
                    {
                        siteInfo.Temperature = site.Temperature;
                    }
                    catch (Exception ex)
                    {
                        //ProjectData.SetProjectError(ex);
                        flag = false;
                        //ProjectData.ClearProjectError();
                    }
                    try
                    {
                        siteInfo.Pressure = site.Pressure;
                    }
                    catch (Exception ex)
                    {
                        //ProjectData.SetProjectError(ex);
                        flag = false;
                        //ProjectData.ClearProjectError();
                    }
                    ref_option = !flag ? RefractionOption.StandardRefraction : RefractionOption.LocationRefraction;
                }
                double zd   = 0;
                double az   = 0;
                double rar  = 0;
                double decr = 0;
                if (this.m_bDTValid)
                {
                    NOVAS2.Equ2Hor(tjd, this.m_deltat, 0.0, 0.0, ref siteInfo, ra, dec, ref_option, ref zd, ref az, ref rar, ref decr);
                }
                else
                {
                    NOVAS2.Equ2Hor(tjd, DeltatCode.DeltaTCalc(tjd), 0.0, 0.0, ref siteInfo, ra, dec, ref_option, ref zd, ref az, ref rar, ref decr);
                }
                if (ref_option != RefractionOption.NoRefraction)
                {
                    NOVAS2.RADec2Vector(rar, decr, num11, ref pos2);
                }
                positionVector = new PositionVector(pos2[0], pos2[1], pos2[2], rar, decr, num11, num11 / 173.14463348, az, 90.0 - zd);
            }
            return(positionVector);
        }