function f = rigid_body2( w, t )
% return the derivatives of the angular frequency for a rigid body.
% elements w(4:6) contains the coordinates of a fixed point in space
% given in body coordinates.

Ix = 1.0;  %   moments of inertial (relative)
Iy = 2.0;
Iz = 3.0;

fx = ( (Iy-Iz)/Ix )*w(2)*w(3);
fy = ( (Iz-Ix)/Iy )*w(3)*w(1);
fz = ( (Ix-Iy)/Iz )*w(1)*w(2);

r = w(4:6);   % this is a fixed point in space
vx = r(2)*w(3) - r(3)*w(2);
vy = r(3)*w(1) - r(1)*w(3);
vz = r(1)*w(2) - r(2)*w(1);

f = [ fx, fy, fz, vx, vy, vz ];