Rigid Body Physics Rotations

2020-05-01 05:22发布

问题:

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 they affect the rotation of an object.

Let's say for example that I have a square with same length sides. The square will be accelerating towards ground level due to gravity (no air resistance). This would mean that there would be a vector force of (0,-9.8)m/s on every point in the square.

Now let's say that this square is rotated slightly. When this rotated square comes into contact with the ground (a flat surface) there will be an impulse velocity vector at the point of contact (most likely a corner of the square). However, what happens to the forces of the other corners on the square? From the original force of gravity, how are they affected?

I apologize if my question isn't detailed enough. I'd love to upload a diagram but I don't yet have the reputation.

回答1:

  1. rotation is form of kinetic energy

    first the analogy to movement

    • alpha - angular position [rad]
    • omega - angular speed [rad/s]
    • epsilon - angular acceleration [rad/s^2]
    • alpha(t)/(dt^2)=omega(t)/dt=epsilon(t)

    now the inertia

    • I - quadratic rotation mass inertia [kg.m^2]
    • m - mass [kg]
    • M - torque [N.m]

    and some equations to be exploited

    1. M=epsilon*I - torque needed to achieve acceleration or vice versa [N.m]
    2. acc=epsilon*radius - perimeter acceleration [m/s^2]
    3. vel=omega*radius - perimeter speed [m/s^2]

    equation #1 can be used to directly compute the force. Equations #2,#3 can be used to calculate friction based forces like wheels grip/drag. Do not forget about the kinetic energy Ek=0.5*m*vel^2+0.5*I*omega^2 so you can exploit the law of preserving energy.

  2. During continuous contact of object1 with object2 in rotation happens this

    Perimeter speed/acceleration create interaction force, this is slowing down the rotation of object2 creating drag force on the object2 and reacting force on the object1.

    if object1 is not fixed then this force also create torque and rotates the object1

    If the rotation is forced to stop suddenly then all rotational part of kinetic energy is moved to the collision reaction Force impulse.

    If object is in more complicated rotation motion then you should compute the actual rotation axis and alpha,omega,epsilon and use that because object can rotate with more rotations each with different center of rotation.

    Also if object is rotating and another rotation is applied in different axis then this creates gyroscopic torque creating also rotation in the third axis perpendicular to both.

    So when yo put all these together you have a idea of what structures you need. Sorry can not be more specific than this without further info about the structures and properties of your simulation ...



回答2:

Applied forces do not play a role in the calculation of contact impulses because the impulses are said to occur on a time scale much smaller than the simulation time step. Basically the change is velocity during an impact because of gravity or other forces is negligible.



回答3:

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.