Exemplo n.º 1
0
        public virtual bool Move(double dtMS)
        {
            // do incremental move of the piece
            Point2D tempLocation;

            if (MovementAssist.CalculateNewLocation(CurrentLocation, SpeedMS, TravelDirectionRads, dtMS, out tempLocation))
            {
                CurrentLocation = tempLocation;
                return(true);
            }

            return(false);
        }
        bool RotateTextureZeroPtAboutCentre(Texture2D tex, double hdgRads, out Point2D newZeroPoint)
        {
            Point2D textTopPt = new Point2D();

            textTopPt.X = -tex.Width / 2;
            textTopPt.Y = -tex.Height / 2;
            Point2D rotPt = new Point2D();

            rotPt.X = 0.0;
            rotPt.Y = 0.0;
            MovementAssist.RotatePoint(rotPt, textTopPt, -hdgRads, out newZeroPoint);
            Debug.WriteLine("resPt.X = " + newZeroPoint.X.ToString());
            Debug.WriteLine("resPt.Y = " + newZeroPoint.Y.ToString());
            return(true);
        }
Exemplo n.º 3
0
        public override bool Move(double dt)
        {
            Debug.WriteLine("dt = " + dt.ToString());
            // currently just doing forward motion
            double forwardPropulsionForce;
            double rotationalTorque;

            if (CalculateForceAndTorque(dt, out forwardPropulsionForce, out rotationalTorque) == false)
            {
                return(false);
            }

            double I;

            if (PhysicsMaths.CalculateMomentOfInertia(DISK_INERTIA_CONSTANT, ROCKET_MASS_KG, ROCKET_RADIUS, out I) == false)
            {
                return(false);
            }

            Debug.WriteLine("forwardPropulsionForce = " + forwardPropulsionForce.ToString());

            Debug.WriteLine("rotationalTorque = " + rotationalTorque.ToString());


            double rotationalFriction;

            if (PhysicsMaths.CalculateRotationalFrictionTorqueOfDisc(ROCKET_RADIUS, ROCKET_HEIGHT, RateOfRotationRadsSec, AIR_DENSITY, out rotationalFriction) == false)
            {
                return(false);
            }

            Debug.WriteLine("rotationalFriction = " + rotationalFriction.ToString());
            Debug.WriteLine("RateOfRotationRadsSec = " + RateOfRotationRadsSec.ToString());


            rotationalTorque = rotationalTorque - rotationalFriction;
            double rotAccn;

            if (PhysicsMaths.CalculateRotationalAcceleration(rotationalTorque, I, out rotAccn) == false)
            {
                return(false);
            }
            // calc rate of rotation
            RateOfRotationRadsSec += rotAccn;

            // calc new heading
            HeadingRads = MovementAssist.RotateHeadingRadians(RateOfRotationRadsSec, HeadingRads, dt);

            double friction       = 0.0;
            double resultantForce = 0.0;

            if (PhysicsMaths.CalculateFriction(SpeedMS, CROSS_SECTION, Cd, AIR_DENSITY, out friction))
            {
                Vector powerAndFrictionVector;
                Debug.WriteLine("HeadingRads = " + HeadingRads.ToString());
                Debug.WriteLine(" TravelDirectionRads = " + TravelDirectionRads.ToString());
                // calculate the resultant force acting on the
                if (CalculateResultantForceVector(HeadingRads, forwardPropulsionForce, TravelDirectionRads + Math.PI, friction, out powerAndFrictionVector) == false)
                {
                    return(false);
                }


                Debug.WriteLine("powerAndFrictionVector.Magnitude = " + powerAndFrictionVector.Magnitude.ToString());

                if (CalculateNewCourseAndSpeed(powerAndFrictionVector, dt, ROCKET_MASS_KG) == false)
                {
                    return(false);
                }
            }


            Debug.WriteLine("SpeedMS = " + SpeedMS.ToString());

            return(base.Move(dt));
        }