Body.applyForce is mis-implemented as Body.applyImpulse
- Dominant language
- JavaScript
- Stars
- 539
- Forks
- 59
- PR merge metrics
- No merged PRs in 30d
Description
This issue serves as a report about a potential bug in the function `cp.Body.applyForce`. I believe that it is mis-implemented as the function `cp.Body.applyForce`.
According to Chipmunk documentations, this function applys force $$`F`$$ to the body, in time $$`dt`$$. It should be
```math
f=F(t)
```
However, in `line 1767, cp.js`, the function is implemented as
```javascript
Body.prototype.applyForce = function(force, r)
{
this.activate();
this.f = vadd(this.f, force);
this.t += vcross(r, force);
};
```
This leads to add $$`F(t)`$$ cumulatively in every $$`dt`$$, thus calculating the integration of $`F`$ over time domain, and that is essentially calculating impulse of the force from the beginning to now
```math
I=\int F(t)dt
```
To apply force, the code should be
```javascript
Body.prototype.applyForce = function(force, r)
{
this.activate();
// this.f = vadd(this.f, force);
this.f = force;
this.t += vcross(r, force);
};
```
I hope the team could check and fix this bug. Thanks for your attention.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.