Exemplo n.º 1
0
        public void Move(ref SimPoint position, ref SimPoint velocity, SimPoint acceleration, double deltaT)
        {
            if (!((acceleration.X == 0.0) && (acceleration.Y == 0.0)))
            {
                // Apply linear acceleration during the time interval

                double newVelocityX = velocity.X + (acceleration.X * deltaT);
                position.X += (velocity.X + newVelocityX) / 2 * deltaT;
                velocity.X  = newVelocityX;

                double newVelocityY = velocity.Y + (acceleration.Y * deltaT);
                position.Y += (velocity.Y + newVelocityY) / 2 * deltaT;
                velocity.Y  = newVelocityY;
            }
        }
Exemplo n.º 2
0
        public void Accelerate(SimPoint position, ref SimPoint acceleration)
        {
            double rX = -position.X;
            double rY = -position.Y;

            double rSquared = (rX * rX) + (rY * rY);
            // rSquared = Math.Max(rSquared, MinimumSeparationSquared); // enforce minimum value of r -- unnecessary with orbital scenarios
            double r = Math.Sqrt(rSquared);

            // F = m1 * a, g = G * m1 * m2 / rSquared, m1's cancel out so a = G * m2 / rSquared
            double a = BigG * CentralBodyMass / rSquared;

            acceleration.X = a * rX / r;
            acceleration.Y = a * rY / r;
        }
Exemplo n.º 3
0
        public void MoveWithPrecisionCheck(ref SimPoint position, ref SimPoint velocity, SimPoint acceleration, double deltaT)
        {
            if (!((acceleration.X == 0.0) && (acceleration.Y == 0.0)))
            {
                // Apply linear acceleration during the time interval

                double deltaVX = acceleration.X * deltaT;
                if (FloatingPointUtil.CheckAdditionPrecision(velocity.X, deltaVX))
                {
                    DisplayPrecisionIssue(velocity.X, deltaVX, "Adding DeltaV to VX", 0);
                }
                double newVelocityX = velocity.X + deltaVX;

                double deltaPX = (velocity.X + newVelocityX) / 2 * deltaT;
                if (FloatingPointUtil.CheckAdditionPrecision(position.X, deltaPX))
                {
                    DisplayPrecisionIssue(position.X, deltaPX, "Adding to Position.X", 0);
                }
                position.X += deltaPX;

                velocity.X = newVelocityX;

                double deltaVY = acceleration.Y * deltaT;
                if (FloatingPointUtil.CheckAdditionPrecision(velocity.Y, deltaVY))
                {
                    DisplayPrecisionIssue(velocity.Y, deltaVY, "Adding DeltaV to VY", 0);
                }
                double newVelocityY = velocity.Y + deltaVY;

                double deltaPY = (velocity.Y + newVelocityY) / 2 * deltaT;
                if (FloatingPointUtil.CheckAdditionPrecision(position.Y, deltaPY))
                {
                    DisplayPrecisionIssue(position.Y, deltaPY, "Adding to Position.Y", 0);
                }
                position.Y += deltaPY;

                velocity.Y = newVelocityY;
            }
        }