Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DistanceJoint getReactionForce function not working #275

Open
quinton-ashley opened this issue Mar 26, 2024 · 4 comments
Open

DistanceJoint getReactionForce function not working #275

quinton-ashley opened this issue Mar 26, 2024 · 4 comments

Comments

@quinton-ashley
Copy link

quinton-ashley commented Mar 26, 2024

I get an error when using getReactionForce with distance joints because this.m_u is undefined

/**
 * Get the reaction force on bodyB at the joint anchor in Newtons.
 */
DistanceJoint.prototype.getReactionForce = function (inv_dt) {
    return Vec2.mulNumVec2(this.m_impulse, this.m_u).mul(inv_dt);
};
@quinton-ashley quinton-ashley changed the title joint.getReactionForce and joint.getReactionTorque functions not working DistanceJoint getReactionForce function not working Mar 26, 2024
@quinton-ashley
Copy link
Author

Also these functions need a timeStamp as input (I think) which could be better documented.

image

@quinton-ashley
Copy link
Author

p5play discord user @ metamere said that the .initVelocityConstraints(step) function needed to be run

@shakiba
Copy link
Collaborator

shakiba commented Mar 26, 2024

I guess we need to initialize m_u to zero so that getReactionForce returns zero before the joint is activated. @zOadT what do you think?

Thanks for the feedback for the doc, I will update it.

@zOadT
Copy link
Collaborator

zOadT commented Mar 26, 2024

Hey! Haven't looked too much into it, but I also think initialising m_u to zero should be fine and reflect what the C code does. Maybe we also should do this for other Vec2 etc properties?
Later we could think about whether we want to reuse the vector instead of reassigning a newly created one or if we want to keep the vector constant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants