Rigid Body Simulation
Defining the Transformation
Reviewing cloth simulation and deformable objects, we simulate a deformation from reference \(X\) to world space \(x\) as
so that we can have the strain
where \(F^TF-I\) is the Green Lagrange Strain.
For a rigid object, the object cannot be deformed so that \(F^TF-I = 0\Rightarrow F^TF=I\Rightarrow F\in O(3)\), i.e. \(F\) is an orthogonal matrix.
For common 3D transformations, rotation matrices and reflection matrices are both orthogonal. However, reflection will have the object's topology passing through itself, which is not rigid.
Therefore, we limit \(F\in SO(3)\), i.e. rigid bodies can only rotate, and \(SO(3)\) is called the special orthogonal Group,
In addition, rigid bodies can translate. Therefore, we have the rigid transformation from reference to world space as
\(\mathbf x, \mathbf X \in \mathbb R^3\), \(R\in SO(3)\) is the rotation and \(\mathbf p\in \mathbb R^3\) is the translation (often written in \(\mathbf t\) but we don't want this to be confused with time \(t\)).
Generalized Coordinates
Consider the mapping
clearly, only \(R, \mathbf p\) is about time, so that our generalized coordinates is
Note that \(\mathbf q\) is a set instead of a unified stacked vector.
Generalized Velocity
Consider the time derivative of the transformation on a single point
\(\dot{\mathbf p(t)}\) is called the linear velocity since it's just the velocity of the origin of the object moves,
\(\dot{R(t)}\) is the time derivative of rotation matrix, and it's more complex, we can represent it with
where \([\cdot]_\times\) is the cross product matrix,
\(\omega\in\mathbb R^3\) is the angular velocity, \(\|\omega\|\) (magnitude) encodes the speed or rotation and angle encodes the axis of rotation.
Since \(R, \mathbf X\) is constant about \(t\), we can define our generalized velocity \(\dot{\mathbf q}\in\mathbb R^6 = [\omega, \dot{\mathbf p}]^T\). and we define \(A = \begin{bmatrix}R^T&0\\0&R^T\end{bmatrix}\) to simplify the expression.
Kinetic Energy
As usual, we can find kinetic energy as
where \(M\) is the mass matrix, \(M = A^T \big(M_0\big)A\) and \(M_0 \in \mathbb R^{6\times 6}\) is a constant matrix integrating over the whole volume.
Center of Mass
The center of mass is defined as the weighted average of points of the volume,
With the center of Mass, we can transfer our reference space to the center-of-mass coordinates system
This is convenient for the computation of \(M_0\),
Consider the off-diagonal entries,
So that we only need to compute the diagonal
Surface Integral via Divergence Theorem
Note that \(M_0\) is an integral over the volume, naturally, we can use tetrahedral mesh so that we can do this integral. However, a more efficient method will use only the surface mesh.
Divergence Theorem states that
so that we can turn a volume integral to a surface integral Therefore, consider the entries of \(M_0\)
\(\mathcal I\) is called the inertia matrix and we can integrate \(M_0\) over each entry.
Since each entry is simple enough, we can pick some integral of it and then apply divergence theorem. For example
Then, because we are using triangle meshes, we can integrate over \(T\) through the barycentric coordinates via
Then, define \(h: (\phi_0, \phi_1, \phi_2)\rightarrow \mathbb R\) and integrate as
Therefore, we can obtain
where \(\mathcal I\) is the inertia matrix
Final Form of Kinetic Energy
Put every thing together
Potential Energy
Since the object is rigid and cannot deform,
Newton-Euler Equations (The Lagrangian)
Since \(V = 0\), we have \(L = T\) so that the Euler-Lagrange Equation gives Newton-Euler Equations
-
Conservation of Angular Momentum
\[(R\mathcal I R^T)\dot\omega = \omega \times ((R\mathcal IR^T)\omega) + \tau_{ext}\]Where \(\dot\omega\) is the angular acceleration, \(\tau_{ext}\) is the external torque and \(\omega \times ((R\mathcal IR^T)\omega)\) is the quadratic velocity vector 2. Conservation of Linear Momentum
\[mI\ddot{\mathbf p} = \mathbf f_{ext}\]where \(\ddot{\mathbf p}\) is the acceleration and \(\mathbf f_{ext}\) is the external force.
External Torques and Forces
For a force applied to some position \(\mathbf x\) as \(\mathbf f(\mathbf x)\), this will result in a rotation as well as a translation. Note that
Let \(J \in\mathbb R^{3\times 6} = R \begin{bmatrix}{[X]_{\times}}^T&I\end{bmatrix}\begin{bmatrix}R^T&0\\0&R^T\end{bmatrix}\) be the rigid body Jacobian matrix, which converts the generalized velocity to the velocity on some point
Therefore, given \(\mathbf x\) in the world space, we first inverse it back to reference space w.r.t. the center-of-mass
and then we can compute \(f(\bar{\mathbf X})\) and \(J(\bar{\mathbf X})\) so that
Time Integration
The NE Equations are 2 second order ODEs, and they are not inter-related. Therefore, we can derive update equations independently.
Update on Translation
The update for linear momentum is simple. Note that this is just the translation of the center of mass, we can think this as the update of the point mass, the rule is simply
Update on Rotation
For the angular velocity update, we can simply using the Forward Euler, i.e. approximate
so that the update is
However, when we update the rotation, we cannot simply use the \(x^{t+1} = x^t + \Delta t v^T\), since this will destroy the orthogonality.
Alternatively, we can view this as solving an initial value problem.
integrating yields that
With this, we can view \(\mathbf v^t\) as the velocity of rotation around \(\mathbf p\) so that