# [ODE] RE: velocity constraints vs. acceleration constraints

Mike Cline mbcusenet at fastmail.fm
Tue Jan 11 09:42:01 MST 2005

```Hi Achim,

I would say that one reason for using
"acceleration constraints" is that it the most natural
way to think about the problem.  The Newton-Euler
equations ("f=Ma") are given in terms of accelerations
and forces, so combining these with acceleration
constraints ("Ja+c=0") and solving for constraint
forces is the most natural way to think about it,
IMHO.

The main problem with using acceleration constraints
and solving for constraint forces is that you get
constraint drift on the velocity and position level --
due to integration error, you will fail to exactly
satisfy the velocity and position constraints after
taking a time step.

In order to use velocity constraints instead of
acceleration constraints, you need to have an equation
of motion that works on velocities, rather than
accelerations.  For example, rather than using f=Ma
and Ja+c, you can use f=M((v-vPrevious)/timeStep) and
solve this along with the velocity constraint equation
Jv+c=0.

This has the advantage that v will always satisfy
the velocity constraints, but the disadvantage that we
are stuck with the first order integration step
(v=vPrevious+a*timeStep) that's built into the motion
equations. A higher order method would be better.
You might be able to do the same trick with a higher
order method (e.g. combining Runge Kutta method with
the Newton-Euler equations), but the math would get
hairy I think.

Most of the time for games and such, people are
fine with using Euler method for integration, and are
willing to sacrifice accuracy for stability.  So the
second option (using velocity constraints) is probably
preferable.

I'm not sure if you could build an entire rigid
body simulation system that was based on position
constraints only, and use neither velocity or
acceleration constraints.  In my work, I used the
position-level constraints to solve for a small
position-correction that was done after each
iteration, but this was just intended as an error
correction step, while the bulk of the action happened
when solving equations on the velocity level.

One place where I've seen something that works only
on position constraints is in this Gamasutra "Advanced
Character Physics" article
(http://www.gamasutra.com/resource_guide/20030121/jacobson_04.shtml),
where the author just uses an iterative "relaxing"
algorithm to reposition particles after doing a
non-constrained forward integration step.  I'm not
sure how physically realistic this is or how well it
extends to rigid bodies (they just use it for particle
systems in the article, I believe).   But the
advantage there is that you are always guaranteed to
end up in a configuration where all of the position
constraints are satisfied.

--

mbcusenet at fastmail.fm

```