Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

And it's not supposed to be. I've been pulling my hair out for a while trying to figure out why...

The values used in T = F - ma are below:

mass of first body: 1 kg

acceleration: [0, 9.80665] (as a test, gravity is the only force acting on the body)

max length of tension generator: 5 meters.


Free-Body Diagram as requested:

Free Body Diagram at t=0

void TensionForceGenerator::Update(double /*deltaTime*/) {

    if(_tension_ends.first == nullptr || _tension_ends.second == nullptr) return;

    RigidBody* first_body = _tension_ends.first;
    RigidBody* second_body = _tension_ends.second;

    double distance_length_squared = (_tension_ends.first->GetPosition() - _tension_ends.second->GetPosition()).GetLengthSquared();
    if(distance_length_squared < _length_squared) return;

    double current_length = std::sqrt(distance_length_squared);
    double max_length = std::sqrt(_length_squared);

    double penetration = current_length - max_length;

    ApplyTensionForce(first_body, second_body, penetration);
    ApplyTensionForce(second_body, first_body, penetration);


void TensionForceGenerator::ApplyTensionForce(RigidBody* reference_body, RigidBody* other_body, double /*penetration*/) {
    double m = reference_body->GetMass();
    Vector2D a = reference_body->GetAcceleration();
    Vector2D F = m * a;

    Vector2D T = F - (m * a);

    Vector2D tension_direction = other_body->GetPosition() - reference_body->GetPosition();

    double angle = tension_direction.GetAngle();
    double tension_forceX = T.GetX() * std::cos(angle);
    double tension_forceY = T.GetY() * std::sin(angle);
    Vector2D tension_force(tension_forceX, tension_forceY);
    first_body->ApplyForce(tension_force, 0.0);
share|improve this question
You can't do dynamics without a Free-Body Diagram identifying the force vectors. Supply one, and I will look at the code. –  Pieter Geerkens Jun 17 '13 at 3:22
These two lines: Vector2D F = m * a; and Vector2D T = F - (m * a); will yield a zero-vector every time. –  Seth Battin Jun 17 '13 at 3:30
As I suspected, the tension force is calculated to be zero because it is zero. In order to generate a tension force in the bar (which by the way should be in the negative x direction at m1's end of the bar; compression is in the direction given.) the bar must first deflect. –  Pieter Geerkens Jun 17 '13 at 5:31
As they teach the 1st year engineers; "F=ma and you can't push a rope."; neither can you cantilever with one. If this is a statics problem, hang m2 vertically down so T = W = mg; if this is a dynamics problem, provide the dynamic conditions. –  Pieter Geerkens Jun 17 '13 at 11:31
This doesn't seem particularly on-topic to me. It looks like a question better suited to a math or physics SE site. –  Josh Petrie Jun 18 '13 at 0:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.