- Main Page
- Classes
- Files

- File List

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

    00001 // --------------------------------------------------------
    00002 // DoubleRegularPendulumAcceleration.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
    00019     public class DoubleRegularPendulumAcceleration : ISecondDerivative
    00020     {
    00021         private double l1;      // length of rod of top pendulum (constant)
    00022         private double m1;      // mass of top pendulum (constant)
    00023         private double l2;      // length of rod of bottom pendulum (constant)
    00024         private double m2;      // mass of bottom pendulum (constant)
    00025         private double g;       // gravitational constant
    00026
    00030         public DoubleRegularPendulumAcceleration(double l1, double m1, double l2, double m2, double g)
    00031         {
    00032             this.l1 = l1;
    00033             this.m1 = m1;
    00034             this.l2 = l2;
    00035             this.m2 = m2;
    00036             this.g = g;
    00037         }
    00038
    00042         public double L1
    00043         {
    00044             get
    00045             {
    00046                 return this.l1;
    00047             }
    00048         }
    00049
    00053         public double M1
    00054         {
    00055             get
    00056             {
    00057                 return this.m1;
    00058             }
    00059         }
    00060
    00064         public double L2
    00065         {
    00066             get
    00067             {
    00068                 return this.l2;
    00069             }
    00070         }
    00071
    00075         public double M2
    00076         {
    00077             get
    00078             {
    00079                 return this.m2;
    00080             }
    00081         }
    00082
    00086         public double G
    00087         {
    00088             get
    00089             {
    00090                 return this.g;
    00091             }
    00092
    00093             set
    00094             {
    00095                 this.g = value;
    00096             }
    00097         }
    00098
    00106         VectorN ISecondDerivative.GetValue(double t, VectorN theta, VectorN omega)
    00107         {
    00108             double theta1 = theta[0];
    00109             double theta2 = theta[1];
    00110             double omega1 = omega[0];
    00111             double omega2 = omega[1];
    00112
    00113             VectorN acceleration = new VectorN(2);
    00114             double theta_diff = theta1 - theta2;
    00115             double mass_sum = m1 + m2;
    00116             double mass_sum2 = mass_sum + m1;
    00117             double denom_part = mass_sum2 - m2 * Math.Cos(2 * theta_diff);
    00118             double sin_theta_diff = Math.Sin(theta_diff);
    00119             double cos_theta_diff = Math.Cos(theta_diff);
    00120             acceleration[0] = (-g * mass_sum2 * Math.Sin(theta1) - m2 * g * Math.Sin(theta_diff - theta2) - 2 * sin_theta_diff * m2 * (omega2 * omega2 * l2 + omega1 * omega1 * l1 * cos_theta_diff)) / (l1 * denom_part);
    00121             acceleration[1] = ( 2 * sin_theta_diff * (omega1 * omega1 * l1 * mass_sum + g * mass_sum * Math.Cos(theta1) + omega2 * omega2 * l2 * m2 * cos_theta_diff) ) / ( l2 * denom_part );
    00122
    00123             return acceleration;
    00124         }
    00125     }
    00126 }