Exemple #1
0
 /// <summary>
 /// Check Static Friction
 /// </summary>
 /// <param name="parallelNetForce">the net force vector projected parallel to the surface</param>
 /// <param name="normalForce">the normal force vector</param>
 /// <param name="coefficientOfFriction">the coefficient of static friction</param>
 /// <returns>if the force is sufficient to overcome static friction</returns>
 public static bool CheckStaticFriction(Vector3D parallelNetForce, Vector3D normalForce, float coefficientOfFriction)
 {
     return ((coefficientOfFriction * normalForce.GetMagnitude()) < parallelNetForce.GetMagnitude());
 }
Exemple #2
0
 /// <summary>
 /// Kinetic Friction
 /// </summary>
 /// <param name="velocity">velocity vector</param>
 /// <param name="normalForce">normal force vector</param>
 /// <param name="coefficientOfFriction">the coefficient of kinetic friction</param>
 /// <returns>kinetic friction force vector</returns>
 public static Vector3D KineticFriction(Vector3D velocity, Vector3D normalForce, float coefficientOfFriction)
 {
     return ((-coefficientOfFriction * normalForce.GetMagnitude()) * (!velocity));
 }
Exemple #3
0
        static void Orbit()
        {
            //giant block o' variables
            Console.Write("Input initial speed in km/s: ");
            Vector3D velocity = new Vector3D(Convert.ToSingle(Console.ReadLine()) * 1000f, 0); //m/s
            Vector3D position = new Vector3D(0, 6778000f); //m
            float massOfSpacecraft = 225f; //kg
            float inverseMassOfSpacecraft = 1 / massOfSpacecraft; //1/kg
            float massOfEarth = 5.98e24f; //kg
            float radiusOfEarth = 6378000f; //m
            float atmosphereRadius = 6478000f; //m
            int timeStep = 10; //s
            float arbitrarySmallAmount = 1f; //m
            float altitude = (position.Y - radiusOfEarth) / 1000f; //km
            float speed = velocity.X / 1000f; //km/s
            float totalEnergy = (massOfSpacecraft * speed * speed * 500000f) + GravityPE(position.GetMagnitude(), massOfSpacecraft, massOfEarth); //N
            Vector3D acceleration = inverseMassOfSpacecraft * GravityPEForce2D (position, massOfSpacecraft, massOfEarth, arbitrarySmallAmount); //m/(s^2)
            Console.WriteLine("Time: {0:N}s, Altitude: {1:N2}km,\nSpeed: {2:N2}km/s,\nTotal energy: {3:N2}N Acceleration: " + acceleration.PrintRect(), 0, altitude, speed, totalEnergy);

            //start simulation loop
            for (int time = 0; time < 36000 && position.GetMagnitude() > atmosphereRadius; time += timeStep) //time is in seconds
            {
                position += velocity * timeStep; //update position
                velocity += acceleration * timeStep; //update velocity
                acceleration = inverseMassOfSpacecraft * GravityPEForce2D(position, massOfSpacecraft, massOfEarth, arbitrarySmallAmount); //update acceleration

                //calculate and display output
                altitude = (position.GetMagnitude() - radiusOfEarth) / 1000f;
                speed = velocity.GetMagnitude() / 1000f;
                totalEnergy = (massOfSpacecraft * speed * speed * 500000f) + GravityPE(position.GetMagnitude(), massOfSpacecraft, massOfEarth);
                Console.WriteLine("Time: {0:N}s, Altitude: {1:N2}km,\nSpeed: {2:N2}km/s,\nTotal energy: {3:N2}N", time, altitude, speed, totalEnergy);

            }
            if (position.GetMagnitude() <= atmosphereRadius)
            {
                Console.WriteLine("Crashed into atmosphere! Go faster next time!");
            }
        }