예제 #1
0
파일: Math.cs 프로젝트: dstovell/Sol
        public static List <Vector3> GetOrbitalPath(Orbiter orbiter, int segmentCount)
        {
            List <Vector3> points = new List <Vector3>();

            if (orbiter.Orbit == OrbitType.Circular)
            {
                float   deltaAngle = TwoPI / (float)segmentCount;
                Vector3 firstPoint = Vector3.zero;
                float   scaler     = (float)orbiter.GetOrbitalScale();
                for (float angle = 0; angle < TwoPI; angle += deltaAngle)
                {
                    float x = orbiter.SemiMajorAxis * Mathf.Cos(angle) * scaler;
                    float z = orbiter.SemiMajorAxis * Mathf.Sin(angle) * scaler;

                    Vector3 point = new Vector3(x, 0.0f, z);
                    points.Add(point);

                    if (angle == 0)
                    {
                        firstPoint = point;
                    }
                }

                if (firstPoint != Vector3.zero)
                {
                    points.Add(firstPoint);
                }
            }

            return(points);
        }
예제 #2
0
파일: Math.cs 프로젝트: dstovell/Sol
        public static Vector3 GetOrbitPositionAtTime(Orbiter orbiter, long time, double scale)
        {
            float angle = GetOrbitAngleAtTime(orbiter, time);

            if (orbiter.Orbit == OrbitType.Circular)
            {
                float orbitalRadius = orbiter.SemiMajorAxis * (float)scale;

                float x = orbitalRadius * Mathf.Cos(angle);
                float z = orbitalRadius * Mathf.Sin(angle);
                return(new Vector3(x, 0f, z));
            }

            return(Vector3.zero);
        }
예제 #3
0
파일: Math.cs 프로젝트: dstovell/Sol
        public static float GetOrbitAngleAtTime(Orbiter orbiter, long time)
        {
            float angle     = 0f;
            long  orbitTime = orbiter.GetOrbitTime();

            if (orbiter.Orbit == OrbitType.Circular)
            {
                long  remainder  = time % orbitTime;
                float angleDelta = ((float)remainder / (float)orbitTime) * TwoPI;

                angle = orbiter.InitialAngle + angleDelta;
            }

            return(angle);
        }