I have been working on fairly simple physics simulation with a constraint solver. I've ran into a bit of a snag. I received great help here with the Jacobian matrix and I hope someone can point me in the right direction once again. The paper "Iterative Dynamic with Temporal Coherence" by Erin Catto was great an I'm essentially trying to implement the same system. After writing all the code, it seems to work but I believe the results are wrong. I have simplified the problem to the basics - simulating a single body acting as a pendulum hanging from the origin with a length of 1.0. The object has a mass of 1.0. I'm solving the equation:
Code: Select all
J * M^-1 * J^t * lamba = -J * (1/dt*V + M^-1 * Fext)
With mass = 1.0 and the body starting at rest, that eliminates the M^-1 and 1/dt*V. I'm using a 6x1 vector to represent Fext; the first 3 values represent force and the last 3 values twist. This is a distance constraint so twist should remain unaffected. Also, I'm keeping the z value 0. My constraint 6x3 Jacobian is:
Code: Select all
J = [ 1 0 0 0 -z y
0 1 0 z 0 -x
0 0 1 -y x 0 ]
I got this from "Iterative Dynamics" and it seemed to agree with a Game programming gem article by Russ Smith. I implemented a Conjugate Gradient algorithm described in "An Introduction to the Conjugate Gradient Method Without the Agonizing Pain" by Jonathan Richard Shewchuk. Some test LCP problems confirmed it working. With all the pieces together and running, the initial case simulation I got:
and
If i read this correct, that would apply a force upward with a rotation around the Z-axis. Wouldn't a distance constraint force try to pull the object back toward the origin? That would be a force parallel to the X-axis not Y. I think i have all my pieces in line. If someone could please confirm my method and math concepts are correct, then it may be a bug in code or a problem between monitor and chair. Sorry for the long post. Lengthy problem require lengthy descriptions. Any help or suggestions are very welcome.
Thanks,
Bil