- Main Page
- Classes
- Files

- File List

# C:/Users/Andreas Schiffler/Desktop/SVN/NewGamePhysics/NewGamePhysics/Physics/CircularObjectAcceleration.cs

    00001 // --------------------------------------------------------
    00002 // CircularObjectAcceleration.cs
    00003 // (A. Schiffler, 2009)
    00004 // --------------------------------------------------------
    00005
    00006 namespace NewGamePhysics.Physics
    00007 {
    00008     using System;
    00009     using System.Collections.Generic;
    00010     using System.Text;
    00011
    00012     using NewGamePhysics.Mathematics;
    00013
    00018     class CircularObjectAcceleration : ISecondDerivative
    00019     {
    00020         double dB;      // Object diameter
    00021         double roB;     // Object material density
    00022         double cD;      // Drag coefficient
    00023         double g;       // Acceleration due to gravity
    00024         double roA;     // Air density
    00025         double mB;      // Ball mass
    00026         double aB;      // Area of the ball cross-section
    00027
    00036         public CircularObjectAcceleration(double dB, double roB, double cD, double g, double roA)
    00037         {
    00038             this.dB = dB;
    00039             this.roB = roB;
    00040             this.cD = cD;
    00041             this.g = g;
    00042             this.roA = roA;
    00043
    00044             double v = Math.PI * Math.Pow(dB, 3) / 6;
    00045             mB = roB * v;
    00046             aB = 0.25 * Math.PI * dB * dB;
    00047         }
    00048
    00057         VectorN ISecondDerivative.GetValue(double t, VectorN p, VectorN v)
    00058         {
    00059             double vx = v[0];
    00060             double vy = v[1];
    00061             double vxSqr = vx * vx;
    00062             double vySqr = vy * vy;
    00063             double vSqr = vxSqr + vySqr;
    00064             double vTotal = Math.Sqrt(vSqr);
    00065
    00066             double cosAlpha = 1;
    00067             double cosBeta = 0;
    00068             if (vTotal > 1.0e-12)
    00069             {
    00070                 cosAlpha = vx / vTotal;
    00071                 cosBeta = vy / vTotal;
    00072             }
    00073
    00074             double drag = 0.5 * cD * roA * vSqr * aB;
    00075             double dragX = -drag * cosAlpha;
    00076             double dragY = -drag * cosBeta;
    00077
    00078             VectorN force = new VectorN(2);
    00079             force[0] = dragX;
    00080             force[1] = -mB * g + dragY;
    00081
    00082             VectorN acceleration = force/mB;
    00083             return acceleration;
    00084         }
    00085     }
    00086 }