Пример #1
0
        public static double GetRadiusOfOrbit(AstronomicalBody satellite, AstronomicalBody primary, double relativeTangentialSpeed)
        {
            double requiredRadiusNotFixed = GravitationalConstant * primary.Mass / (relativeTangentialSpeed * relativeTangentialSpeed);
            double requiredRadiusFixed    = requiredRadiusNotFixed * GravitationalConstantDecimalFix;

            return(requiredRadiusFixed);
        }
Пример #2
0
        public static double GetRelativeTangentialSpeedForOrbit(AstronomicalBody satellite, AstronomicalBody primary)
        {
            double distance = GetDistanceBetweenPoints(satellite.Center, primary.Center);
            double requiredTangentialSpeedFixed = Math.Sqrt((GravitationalConstant * primary.Mass / distance) * GravitationalConstantDecimalFix);

            return(requiredTangentialSpeedFixed);
        }
Пример #3
0
        // Methods
        public void AdvanceMovement(double timeInSeconds)
        {
            AstronomicalBody dummyBody = new AstronomicalBody(this.Center, this.Mass, this.Radius, this.Velocity, this.Name);

            Physics.AdvanceMovementOfBody(ref dummyBody, timeInSeconds);
            this.Center = dummyBody.Center;
        }
Пример #4
0
        public void ApplyForce(Vector force, double secondsUnderForce)
        {
            AstronomicalBody dummyBody = new AstronomicalBody(this.Center, this.Mass, this.Radius, this.Velocity, this.Name);

            Physics.ApplyForceToBody(ref dummyBody, force, secondsUnderForce);
            this.Center   = dummyBody.Center;
            this.Velocity = dummyBody.Velocity;
        }
Пример #5
0
        public static AstronomicalBody AdvanceMovementOfBody(ref AstronomicalBody body, double timeInSeconds)
        {
            double resultingX = body.Center.X + (body.Velocity.X * timeInSeconds);
            double resultingY = body.Center.Y + (body.Velocity.Y * timeInSeconds);
            double resultingZ = body.Center.Z + (body.Velocity.Z * timeInSeconds);
            Point  newCenter  = new Point(resultingX, resultingY, resultingZ);

            body.Center = newCenter;
            return(new AstronomicalBody(body));
        }
Пример #6
0
        public static double GetGravitationalForceMagnitude(AstronomicalBody body1, AstronomicalBody body2)
        {
            double distance       = GetDistanceBetweenPoints(body1.Center, body2.Center);
            double resultNotFixed = GravitationalConstant *
                                    (body1.Mass * body2.Mass) /
                                    (distance * distance);
            double result = resultNotFixed * GravitationalConstantDecimalFix;

            return(result);
        }
Пример #7
0
        public static Vector GetFinalVelocityVectorFromForce(
            AstronomicalBody body,
            Vector forceVector,
            double secondsUnderForce)
        {
            Vector accelerationVector = GetAccelerationVector(body, forceVector);
            Vector velocityVector     = GetFinalVelocityVectorFromAcceleration(
                body, accelerationVector, secondsUnderForce);

            return(velocityVector);
        }
Пример #8
0
        public static Vector GetFinalVelocityVectorFromAcceleration(
            AstronomicalBody body,
            Vector accelerationVector,
            double secondsUnderAcceleration)
        {
            Vector startingVelocity = body.Velocity;
            Vector deltaVelocity    = accelerationVector * secondsUnderAcceleration;
            Vector finalVelocity    = startingVelocity + deltaVelocity;

            return(finalVelocity);
        }
Пример #9
0
        public static Vector GetGravitationalForceVector(AstronomicalBody body1, AstronomicalBody body2)
        {
            double forceMagnitude  = GetGravitationalForceMagnitude(body1, body2);
            Vector prototypeVector = new Vector(new Point(
                                                    body2.Center.X - body1.Center.X,
                                                    body2.Center.Y - body1.Center.Y,
                                                    body2.Center.Z - body1.Center.Z));

            prototypeVector.Length = forceMagnitude;
            return(prototypeVector);
        }
Пример #10
0
        public static AstronomicalBody ApplyForceToBody(ref AstronomicalBody body, Vector force, double secondsUnderForce)
        {
            Vector startingVelocity       = new Vector(body.Velocity);
            Vector finalVelocityFromForce = GetFinalVelocityVectorFromForce(body, force, secondsUnderForce);
            Vector averageVelocity        = Vector.GetAverage(new List <Vector> {
                startingVelocity, finalVelocityFromForce
            });

            body.Velocity = averageVelocity;
            AdvanceMovementOfBody(ref body, secondsUnderForce);
            body.Velocity = finalVelocityFromForce;
            return(body);
        }
Пример #11
0
        public static void EnterOrbitByGivenSpeed <T>(ref T satellite, AstronomicalBody primary, double relativeTangentialSpeed, double coveredAngle
                                                      /*Vector orbitAxis, double StartingPointOffset*/) where T : AstronomicalBody, new()
        {
            // startingPointOffset == 0 => point with the highest x
            // orbit axis - right hand rule
            // TODO: Implement orbital axis and startingPointOffset
            double radius = GetRadiusOfOrbit(satellite, primary, relativeTangentialSpeed);

            satellite.Center = new Point(
                primary.Center.X + (radius * Math.Cos(coveredAngle)),
                primary.Center.Y + (radius * Math.Sin(coveredAngle)),
                primary.Center.Z);
            Vector satelliteRelativeVelocity = new Vector(relativeTangentialSpeed, Math.PI / 2, (Math.PI / 2) + coveredAngle);

            if (satellite is Moon)
            {
                satelliteRelativeVelocity = satelliteRelativeVelocity.GetOpposite();
            }

            Vector satelliteAbsoluteVelocity = satelliteRelativeVelocity + primary.Velocity;

            satellite.Velocity = satelliteAbsoluteVelocity;
        }
Пример #12
0
        public static Vector GetAccelerationVector(AstronomicalBody body, Vector forceVector)
        {
            Vector resultingVector = forceVector / body.Mass;

            return(resultingVector);
        }
Пример #13
0
 public AstronomicalBody(AstronomicalBody body)
     : this(body.Center, body.Mass, body.Radius, body.Velocity, body.Name)
 {
 }