grain dynamics rigid body integrator midpoint method random generator Euler-Rodrigues parameters