python ball physics simulation

后端 未结 1 1698
余生分开走
余生分开走 2021-01-05 06:21

I have seen the great tutorial by Peter Colling Ridge on
http://www.petercollingridge.co.uk/pygame-physics-simulation/
and I am extending the PyParticles script

相关标签:
1条回答
  • 2021-01-05 06:49

    A rod in 2D has 3 degrees of freedom (2 velocities/positions + 1 rotation/angular freq).
    I would represent the position of the center which is modified by forces in the usual way and calculate the position of the particles using the rotation (for simplicity, about the center of the system) variable.
    The rotation is modified by forces by

    ang_accel = F * r * sin (angle(F,r)) / (2*M * r^2)
    

    Where

    ang_accel is the angular acceleration

    F is a force acting on a particular ball so there is 2 torques* that add up as there is two forces that add up (vector-wise) in order to update the position of the center.

    r is half of the length
    angle(F,r) is the angle between the force vector and the radius vector (from the center to the particle that suffers the force),

    So that
    F * r * sin (angle(F,r)) is the torque about the center, and
    2*M * r^2 is the moment of inertia of the system of two points around the center.

    0 讨论(0)
提交回复
热议问题