Rigid Body Physics Rotations

前端 未结 3 1412
旧巷少年郎
旧巷少年郎 2021-01-26 16:10

I\'m wanting to create a physics engine within Java. However it\'s not the code I\'m bothered about. It\'s simply the math of rigid body physics, specifically forces and how the

3条回答
  •  爱一瞬间的悲伤
    2021-01-26 16:40

    If I understand correctly, you worry about the different corners of the square - one with an impact, three without.

    However, since you want to do rigid body dynamics, it is more helpful to think about the rigid body as having a center of mass (in this case, the square's center), a position, a rotation, and a geometry (in this case the square, but it could be anything).

    The corners of the vertices are in constant position and rotation with regards to the center of mass - it's only the rigid body's position and rotation which change all four corners position in the world at once. An advantage of this view is that it is independent of the geometry - you could have 10 or 20 corners, and the approach would be the same.

    With regard to computing the rotation: Gravity is working as before. However, you now have another force (from the impulse over the time it acts) - and you have to add the effects of the two in order to get the complete outcome of the system.

    The impulse will be due to one of the corners being in collision in the case you describe. It has to be computed at the contact point, with a contact normal - in this case the normal of the flat surface.

    If the normal points in a different direction than the center of mass, this will lead to a rotation (as well as a position change).

    The amount of the position change is due to how you model the contact computation and resolution, material properties, numerical stepper, impact velocity, time step, ...

    As others mentioned, reading up on physics (rigid body dynamics) and physics simulations might be a good starting point to understand the concepts better.

提交回复
热议问题