making bodies repel each other with a field point charge

2 views
Skip to first unread message

Pete

unread,
Jun 1, 2010, 7:58:06 PM6/1/10
to Physics2D.Net
What would be the best way to implement a field point charge for a
body so that it repels other bodies from it when they get too close?

What I have tried is to implement a PhysicsLogic that implements
Coulomb's law, and added charge info to each body. The issue is that
because each body affects all other charged bodies, this has a
complexity of O(N^2) and starts to chug very quickly.

I was thinking that I can have a shared helper so that for each pair
of charged bodies the calcs are only done once for each time step, and
when the iteration gets to the other body in the pair it only needs to
reverse the direction of the previous calculation.

Maybe p/linq in .net 4.0 might be able to process each physics logic
in parallel?

Let me know if you have any ideas.

JonoPorter

unread,
Jun 2, 2010, 1:00:25 PM6/2/10
to Physics2D.Net
Because of the O(N^2) nature of the problem expecting real time,
accurate solutions is unreasonable.
if you just want to approximate the effect then you can reduce the
effect to a certain radius around the Body.
This can be accomplished by adding another body that Is tied to the
first body used for collision detection.
The logic would be similar to the ExplosionLogic instead of an
expanding circle make it a static circle that has a joint with the
body its being a detector for.
Reply all
Reply to author
Forward
0 new messages