[ODE] Four little things

Russ Smith russ at q12.org
Tue Apr 13 21:01:58 MST 2004


> Thing 2:
> There seems to be a minor bug in dMassSetCappedCylinder().  The
> contribution to the inertia tensor from the two half-spheres seems to
> be wrong.  (It looks like maybe someone made some false assumptions
> about the symmetry of two separate half-spheres vs. a sphere?)
> Someone should probably double-check my math, but I've done it a few
> different ways so I'm pretty convinced.
> 
> Old: (ode/src/mass.dpp:141)
> <  Ia = M1*(REAL(0.25)*a*a + (REAL(1.0)/REAL(12.0))*b*b) +
> <       M2*(REAL(0.4)*a*a + REAL(0.5)*b*b);
> New:
> >  Ia = M1*(REAL(0.25)*a*a + (REAL(1.0)/REAL(12.0))*b*b) +
> >       M2*(REAL(0.4)*a*a + REAL(0.375)*a*b + REAL(0.25)*b*b);


good spotting! yes, my original implementation is wrong - i somehow
assumed that the center of mass did not change when a sphere was chopped
into a half-sphere. i verified your change using the matlab code below.
i'll check this change into CVS shortly.

russ.

--

% matlab code to compute part of the inertia tensor of the caps of a
% capped cylinder.

% define sphere mass and radius, cylinder length (2*half-sphere
translation
% distance)
syms m r l

% compute sphere inertia tensor
I = eye(3) * 0.4 * m * r^2

% compute half-sphere inertia tensor and mass
I2 = I/2		% by symmetry of integration, along any axis
m2 = m/2

% compute half-sphere center of mass. half-sphere is defined by x>=0.
%c = [0 0 0]		% incorrect
c = [3/8*r 0 0]		% correct

% translate half-sphere inertia by [l/2 0 0] using the rule:
%	new_inertia = old_inertia + mass*(crossmat(c)^2 - crossmat(c+a)^2)
%	where
%		c = center of mass
%		a = translation
%	and
%		crossmat(a)=[0 -a(3) a(2); a(3) 0 -a(1); -a(2) a(1) 0]
%
I3 = I2 + m2*(crossmat(c)^2 - crossmat(c+[l/2 0 0])^2)

% compute inertia for two such half spheres, symmetrically placed
I4 = I3 * 2

% read out the inertia
pretty(simplify(I4(2,2)))

prints --> 2/5*r^2*m+3/8*m*r*l+1/4*m*l^2


-- 
Russell Smith
http://www.q12.org


More information about the ODE mailing list