Re: Rigid Body dynamics and solution methods
- From: Preben <64bitNONOSPAMno@xxxxxxxxx>
- Date: Thu, 22 Feb 2007 19:17:09 +0100
Just to sum up what I really have done... It seems like this could be an advantage for me and you.
Definitions:
G : Constraints
dG : Derivative's of the constraints
ddG : Double derivative of the constraints
m : mass-vector
q : coordinates
v : velocities
V : potential
dV : derivative of the potential (vector)
F :
T : both represent forces - see calculation below
Now I do the following calculations:
Calculate M:
unsigned int Msize = dG.size1(); // Number of constraints
ublas::matrix<double> M(Msize, Msize);
for (unsigned int alpha = 0; alpha < Msize; ++alpha) {
for (unsigned int beta = 0; beta < Msize; ++beta) {
double temp = 0;
for (unsigned int j = 0; j < N; ++j) {
temp += pow(m(j),-1) * dG(alpha,j) * dG(beta,j);
}
M(alpha, beta) = temp;
}
}
Calculate - F - T
unsigned int N = m.size();
unsigned int Msize = dG.size1(); // number of constraints
ublas::vector<double> F(Msize);
ublas::vector<double> T(Msize);
// Calculate F
for (unsigned int alpha = 0; alpha < Msize; ++alpha) {
double temp = 0;
for (unsigned int j = 0; j < N; ++j) {
temp -= pow(m(j),-1) * dG(alpha,j) * dV(j);
}
F(alpha) = temp;
}
// Calculate T
for (unsigned int alpha = 0; alpha < Msize; ++alpha) {
double temp = 0;
for (unsigned int j = 0; j < N; ++j) {
for (unsigned int k = 0; k < N; ++k) {
temp += ddG[alpha](j,k) * v(j) * v(k);
}
}
T(alpha) = temp;
}
return (- F - T);
Now I solve the systems of equations:
M * mu = - F - T
to find the constraint force multipliers and next calculate the accelerations :
ublas::vector<double> accel = -dV + prod(trans(dG), mu);
for (unsigned int i = 0; i < m.size(); ++i) {
accel(i) = accel(i)/m(i);
}
now it should be possible to use a method for solving the equations of motion!
Is this a bad method?
.
- Follow-Ups:
- Re: Rigid Body dynamics and solution methods
- From: Keith Refson
- Re: Rigid Body dynamics and solution methods
- Prev by Date: Re: Poisson Eq - how to solve efficiently?
- Next by Date: Finite differences for a PDE
- Previous by thread: Re: Rigid Body dynamics and solution methods
- Next by thread: Re: Rigid Body dynamics and solution methods
- Index(es):
Relevant Pages
|
Loading