pymunk icon indicating copy to clipboard operation
pymunk copied to clipboard

Electricity and general attractive/repulsive force?

Open aparamon opened this issue 5 years ago • 2 comments

pymunk.Body seems to only support gravitation, but not other types of mechanical forces, e.g. electricity. Is it possible to specify body electric charges?

More generally: is it possible to specify polynomial attractive/repulsive force, and specify its per-body "charges"?

aparamon avatar Feb 22 '19 06:02 aparamon

There is no built in ready to use support for this. You will have to do something yourself.

There are some resources for Chipmunk (The c library pymunk is using) that you might find useful: https://chipmunk-physics.net/forum/viewtopic.php?f=1&t=1433&p=6906 https://github.com/slembcke/Chipmunk2D/blob/b56ae7591b78acc6bb72401ee999d0e9b5019305/Demo/MagnetsElectric.c https://github.com/slembcke/Chipmunk2D/blob/master/demo/Planet.c

viblo avatar Feb 22 '19 09:02 viblo

Rereading this issue I see that another thing should be clarified: Pymunk does not calculate any gravity force between two bodies. The only thing it does is calculate how the gravity set on the space should affect each body.

viblo avatar Apr 16 '19 18:04 viblo