Example #1
0
        public static BasicUniverse SunEarth(double distance, double sunMass, double height = 0)
        {
            double gravConstant = 1.0;
            double earthMass    = Math.Pow(10, -5);
            double moonMass     = Math.Pow(10, -10);

            double earthSpeed = Math.Sqrt(gravConstant * sunMass / distance); // for circular orbit

            earthSpeed *= 1.2;

            double moonSpeed = Math.Sqrt(gravConstant * sunMass / (0.8 * distance));

            var sun = BodyFactory.PointMass(sunMass, Vector3.Zero + Vector3.J * height, Vector3.Zero);

            sun.Dynamics.Fix();
            var earth = BodyFactory.PointMass(earthMass, distance * Vector3.I + Vector3.J * height, earthSpeed * Vector3.K);

            earth.Dynamics.ThrustInputs(Vector3.Zero, new Vector3(0.1, 0.1, 0.1), 1); // add a slight rotation to earth
            var moon = BodyFactory.PointMass(moonMass, 0.8 * distance * Vector3.I + Vector3.J * height, moonSpeed * Vector3.J);

            moon.Dynamics.ThrustInputs(Vector3.Zero, new Vector3(0.1, 0.1, 0.1), 1); // add a slight rotation to earth

            var uni = new BasicUniverse();

            uni.Bodies.Add(sun, earth, moon);
            uni.ForceFields.Add(ForceFieldFactory.Gravity(sun, gravConstant * sunMass));

            return(uni);
        }
Example #2
0
        public static BasicUniverse BouncyGravity(double distance, double sunMass)
        {
            double gravConstant = 1.0;
            double earthMass    = Math.Pow(10, -5);

            var sun = BodyFactory.SphereMass(0.2, sunMass, Vector3.Zero, Vector3.Zero);

            sun.Dynamics.Fix();
            sun.Material.DynamicFrictionCoef = 0.0f;
            sun.Material.StaticFrictionCoef  = 0.0f;

            var satOne = BodyFactory.SphereMass(0.2, earthMass, distance * Vector3.I, Vector3.Zero);

            satOne.Material.Epsilon             = 0.75f;
            satOne.Material.DynamicFrictionCoef = 0.05f;
            satOne.Material.StaticFrictionCoef  = 0.1f;

            var satTwo = BodyFactory.SphereMass(0.2, earthMass, -distance * Vector3.I, Vector3.I - Vector3.J - Vector3.K);

            satTwo.Material.Epsilon             = 0.75f;
            satTwo.Material.DynamicFrictionCoef = 0.05f;
            satTwo.Material.StaticFrictionCoef  = 0.1f;

            var satThree = BodyFactory.SphereMass(0.2, earthMass, distance * Vector3.J, Vector3.I - Vector3.J - Vector3.K);

            satThree.Material.Epsilon             = 0.75f;
            satThree.Material.DynamicFrictionCoef = 0.05f;
            satThree.Material.StaticFrictionCoef  = 0.1f;

            var satFour = BodyFactory.SphereMass(0.2, earthMass, -distance * Vector3.J, Vector3.I - Vector3.J - Vector3.K);

            satFour.Material.Epsilon             = 0.75f;
            satFour.Material.DynamicFrictionCoef = 0.05f;
            satFour.Material.StaticFrictionCoef  = 0.1f;

            var satFive = BodyFactory.SphereMass(0.2, 10 * earthMass, -10 * distance * Vector3.J, Vector3.J);

            satFive.Material.Epsilon             = 0.75f;
            satFive.Material.DynamicFrictionCoef = 0.05f;
            satFive.Material.StaticFrictionCoef  = 0.1f;

            var uni = new BasicUniverse();

            uni.Bodies.Add(sun, satOne, satTwo, satThree, satFour, satFive);
            uni.ForceFields.Add(ForceFieldFactory.Gravity(sun, gravConstant * sunMass));

            return(uni);
        }