Пример #1
0
 public Sun(string name)
 {
     Name     = name;
     Position = new PositionStrut {
         x = 0f, y = 0f, z = 0f
     };
     Rotation = new RotationStrut {
         x = 0f, y = 0f, z = 0f
     };
 }
Пример #2
0
        public static PositionStrut CalculatePointDouble(double position, double x1, double y1, double z1,
                                                         double x2, double z2, double orbit, RotationStrut rotation)
        {
            double a   = orbit / 2f;                                                   // Semimajor axis
            double x0  = (x2) / 2f;                                                    // Center x-value
            double z0  = (z2) / 2f;                                                    // Center y-value
            double f   = Math.Sqrt(Math.Pow((0f - x0), 2f) + Math.Pow((0f - z0), 2f)); // Distance from center to focus
            double b   = Math.Sqrt(a * a - f * f);                                     // Semiminor axis
            double phi = Math.Atan2((z2), (x2));                                       // Angle between major axis and x-axis

            // Parametric plot in t
            double t = 2 * Math.PI * position;

            double x3 = x0 + a * Math.Cos(t) * Math.Cos(phi) - b * Math.Sin(t) * Math.Sin(phi);
            double z3 = z0 + a * Math.Cos(t) * Math.Sin(phi) + b * Math.Sin(t) * Math.Cos(phi);
            double y3 = 0f;

            // X axis rotation
            double y4 = y3 * Mathf.Cos(rotation.x) - z3 * Mathf.Sin(rotation.x);
            double z4 = z3 * Mathf.Cos(rotation.x) + y3 * Mathf.Sin(rotation.x);
            // Z axis Rotation
            double y5 = y4 * Mathf.Cos(rotation.z) - x3 * Mathf.Sin(rotation.z);
            double x4 = x3 * Mathf.Cos(rotation.z) + y4 * Mathf.Sin(rotation.z);


            double x = x4 + x1;
            double y = y5 + y1;
            double z = z4 + z1;

            return(new PositionStrut {
                x = x, y = y, z = z
            });
        }
Пример #3
0
        public static Vector3 CalculatePointVector3(double position, double x1, double y1, double z1,
                                                    double x2, double z2, double orbit, RotationStrut rotation)
        {
            PositionStrut pos = CalculatePointDouble(position, x1, y1, z1, x2, z2, orbit, rotation);

            return(new Vector3((float)pos.x, (float)pos.y, (float)pos.z));
        }