Beispiel #1
0
//----------------------------------------------------------------------------
bool RoughPlaneParticle2::OnInitialize ()
{
    if (!WindowApplication2::OnInitialize())
    {
        return false;
    }

    // Set up the physics module.
    mModule.Gravity = 10.0;
    mModule.Mass1 = 10.0;
    mModule.Mass2 = 20.0;
    mModule.Friction1 = 1.0;
    mModule.Friction2 = 1.0;

    // Initialize the differential equations.
    double time = 0.0;
    double deltaTime = 1.0/60.0;
    double x1 = 16.0;
    double y1 = 116.0;
    double x2 = 100.0;
    double y2 = 200.0;
    double xDot = 10.0;
    double yDot = -10.0;
    double thetaDot = 0.5;
    mModule.Initialize(time, deltaTime, x1, y1, x2, y2, xDot, yDot, thetaDot);

    // Use right-handed coordinates.
    DoFlip(true);

    // Drawing might extend outside the application window.
    ClampToWindow() = true;

    OnDisplay();
    return true;
}
//----------------------------------------------------------------------------
bool RoughPlaneParticle1::OnInitialize ()
{
    if (!WindowApplication2::OnInitialize())
    {
        return false;
    }

    // Set up the physics module.
    mModule.Gravity = 10.0;
    mModule.Mass = 10.0;
    mModule.Friction = 1.0;
    mModule.Angle = 0.125*Mathd::PI;

    // Initialize the differential equations.
    double time = 0.0;
    double deltaTime = 1.0/60.0;
    double x = 0.0;
    double w = 0.0;
    double xDer = 10.0;
    double wDer = 40.0;
    mModule.Initialize(time, deltaTime, x, w, xDer, wDer);

    // Initialize the coefficients for the viscous friction solution.
    mR = mModule.Friction/mModule.Mass;
    mA0 = -xDer/mR;
    mA1 = x - mA0;
    mB1 = -mModule.Gravity*Mathd::Sin(mModule.Angle)/mR;
    mB2 = (wDer + mR*w - mB1)/mR;
    mB0 = w - mB2;

    // Save path of motion.
    mVFPositions.push_back(GetVFPosition(time));
    mSFPositions.push_back(Vector2d(x, w));

    // Use right-handed coordinates.
    DoFlip(true);

    // Mass drawing might extend outside the application window.
    ClampToWindow() = true;

    OnDisplay();
    return true;
}
//----------------------------------------------------------------------------
bool RoughPlaneThinRod2::OnInitialize ()
{
	if (!WindowApplication2::OnInitialize())
	{
		return false;
	}

	// Same starting values as in RoughPlaneParticle2.
	double x1 = 16.0;
	double y1 = 116.0;
	double x2 = 100.0;
	double y2 = 200.0;
	double xDelta = x2 - x1;
	double yDelta = y2 - y1;

	// Set up the physics module.
	mModule.Length = Mathd::Sqrt(xDelta*xDelta + yDelta*yDelta);
	mModule.MuGravity = 5.0;  // mu*g = c/delta0 from RoughPlaneThinRod1

	// Initialize the differential equations.
	double time = 0.0;
	double deltaTime = 1.0/60.0;
	double x = 0.5*(x1 + x2);
	double y = 0.5*(y1 + y2);
	double theta = Mathd::ATan2(yDelta, xDelta);
	double xDer = 10.0;
	double yDer = -10.0;
	double thetaDer = 4.0;
	mModule.Initialize(time, deltaTime, x, y, theta, xDer, yDer, thetaDer);

	// Use right-handed coordinates.
	DoFlip(true);

	// Drawing might extend outside the application window.
	ClampToWindow() = true;

	OnDisplay();
	return true;
}