-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Body behaving erratically when pivot point is away from centre of mass (?) #1240
Comments
If I change It certainly seems that there is something wrong whenever the pivot is anywhere other than the centre of mass. |
I have found a solution: https://incoherency.co.uk/matterjs-test-case/fixed.html I needed to leave the two balls as separate bodies and constrain their locations with constraints, instead of trying to turn them into oen body. It seems like this is a bug in compound bodies, since to my mind the two methods should give the same outcome. |
I seem to be running into this bug as well: https://jsfiddle.net/Oli414/2gapbwoq/ @jes did you notice a performance difference with your solution compared to using a compound? I'd expect there to be some extra overhead. I'm a bit concerned about using your solution at a larger scale. |
I've been trying to dig a bit deeper, I might have found the underlying issue. But for now the best I've got is a better temporary solution. First of all some discoveries regarding this bug:
With that in mind I ended up cloning the repo to see if I could figure out what was going on, focusing on a single iteration of the constraint solver. I found that there was a discrepancy in the inertia value between single-part bodies and multi-part bodies. A compound consisting of 3 squares (3 times 64x64, forming a 192x64 rectangle) has an inertia of 33554.432 as opposed to a single rectangle having an inertia of 167772.16 (1 time 192x64), 5 times that of the 3 separate squares. You can manually set the compound's inertia to the correct value and the constraint starts to behave identically to a constraint with a non-compound body. I'm don't know enough about the inner workings of this physics engine to make a bugfix, but something seems off about the way the inertia is calculated for compound bodies. |
Thanks for looking at this. No I did not notice any performance difference, but I'm only using 2 balls, so I wouldn't. Your finding that the inertia is calculated incorrectly for compound bodies sounds promising. |
Hi, I'm trying to make a clock escapement simulator using Matter.js. It should be a very simple problem as there are only 2 degrees of freedom (rotation of the escape wheel, rotation of the anchor).
However I am having trouble modelling the anchor because I want it to pivot around a point that is quite far away from the centre of mass.
I have made this minimal test case to demonstrate the problem: https://incoherency.co.uk/matterjs-test-case/
Can anyone suggest what I should do about this?
The JavaScript source is:
The text was updated successfully, but these errors were encountered: