1. PF Contest - Win "Conquering the Physics GRE" book! Click Here to Enter
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Check calculation on pendulum.

  1. Dec 26, 2009 #1
    Can someone check my calculation for pendulum. Its written in C++, but I think it should be understandable.

    //F = mg*sin(theta) = ma;
    //a = F/ m
    //a = mgsin(theta) / m
    //a = g*sin(theta)
    ball.accelVec = Vector3D( g * sin( changeInAngle ) ,g * cos(changeInAngle) , 0.0f );

    //V = v_0 + a*t
    ball.velVec += ball.accelVec * deltaTime;

    // X = v*dt + 1/2 a*dt^2
    ball.posVec += ball.velVec * deltaTime + 1.0f/2.0f * ball.accelVec * deltaTime * deltaTime;

    changeInAngle = atan2( ball.posVec.getY(), ball.posVec.getX() ) - restAngle;

    rope.setEndPoint( ball.posVec );
    Basically, ball.accelVec is the critical one, since everything else depends upon it.
    The Vector3D is Vector3D( x ,y z ). So is the acceleration vector correct for the pendulum.

    I think the Force for the pendulum should be < w*sin(theta), w*cos(theta) >, where w is
    weight and theta is in radians ?

    Sorry for the programming language.
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted