Example #1
0
        public static void PhysicsUpdate(OrbitWidgetIconData icon)
        {
            var ralitivePoint = (icon.IconData.WorldPosition - icon.InsertionPoint);

            icon._orbitEllipseSemiMaj = (ralitivePoint).Length();

            icon._orbitAngleRadians     = Math.Atan2(ralitivePoint.Y, ralitivePoint.X);
            icon._eccentricity          = icon._focalDistance / icon._orbitEllipseSemiMaj;
            icon._orbitEllipseSemiMinor = icon._orbitEllipseSemiMaj * Math.Sqrt(1 - icon._eccentricity * icon._eccentricity);
            SetPointArray();

            PointD pointD = new PointD()
            {
                x = icon.InsertionPoint.X, y = icon.InsertionPoint.Y
            };                                                                                     //may make this ralitive

            double minDist = PointDFunctions.CalcDistance(pointD, icon._points[icon._index]);

            for (int i = 0; i < icon._points.Length; i++)
            {
                double dist = PointDFunctions.CalcDistance(pointD, icon._points[i]);
                if (dist < minDist)
                {
                    minDist = dist;
                    _index  = i;
                }
            }
        }
Example #2
0
        internal void SetPointArray(OrbitWidgetIconData icon)
        {
            icon._points = new PointD[icon._numberOfArcSegments + 1];
            double angle = 0;//_orbitAngleRadians;

            for (int i = 0; i < icon._numberOfArcSegments + 1; i++)
            {
                double x1 = icon._orbitEllipseSemiMaj * Math.Sin(angle) - icon._focalDistance; //we add the focal distance so the focal point is "center"
                double y1 = icon._orbitEllipseSemiMinor * Math.Cos(angle);

                //rotates the points to allow for the LongditudeOfPeriapsis.
                double x2 = (x1 * Math.Cos(icon._orbitAngleRadians)) - (y1 * Math.Sin(icon._orbitAngleRadians));
                double y2 = (x1 * Math.Sin(icon._orbitAngleRadians)) + (y1 * Math.Cos(icon._orbitAngleRadians));
                angle          += icon._segmentArcSweepRadians;
                icon._points[i] = new PointD()
                {
                    x = x2, y = y2
                };
            }
        }
Example #3
0
        internal static OrbitWidgetIconData  CreateIcon(PositionDB parentPosition)
        {
            OrbitWidgetIconData icon = new OrbitWidgetIconData();

            icon.IconData.PositionDB = parentPosition;
            icon.IconData.ShouldUpdateFromPositionDB = true;
            icon.IconData.WorldPosition = parentPosition.AbsolutePosition;

            icon._orbitEllipseSemiMaj   = 20000;
            icon._orbitEllipseMajor     = (float)icon._orbitEllipseSemiMaj * 2; //Major Axis
            icon._orbitEllipseSemiMinor = 10000;
            //_orbitEllipseMinor =


            icon._segmentArcSweepRadians = (float)(Math.PI * 2.0 / icon._numberOfArcSegments);
            icon._numberOfDrawSegments   = (int)Math.Max(1, (icon.EllipseSweepRadians / icon._segmentArcSweepRadians));
            icon._alphaChangeAmount      = ((float)icon.MaxAlpha - icon.MinAlpha) / icon._numberOfDrawSegments;

            return(icon);
        }