# [ODE] Should ODE support Center of mass not centered at body frame

Remi Ricard remi.ricard at simlog.com
Thu Sep 14 06:14:08 MST 2006

```Hi Bram,

> Hi,
>
> I'm not convinced yet that c.o.m. != body origin is a good idea.
>
> First, there is chapter 13 in the ode docs:
> http://ode.org/ode-latest-userguide.html#sec_13_0_0
>
Documentation can be changed ;-)

> Second, what use would it have?
> You have to choose *some* origin for your body frame, and the center
> of mass is the most logical choice for this origin.
>
For us a good origin for a body is its axis of rotation .
Having the Frame at the axis of rotation, you only have to deal with
rotation.
Finding a value in world frame when the body as done a rotation is easier.

[P]_world_frame = Q * [Pt]_body_frame + position of axis.

When body frame is not at the  axis of rotation.
[P]_world_frame = Q * [Pt + Position of frame w.r.t axis]_body_frame +
position of axis.

The position of frame w.r.t axis in the body frame is not always easy or

> Third, someone mentioned that it introduces a new pitfall,
> w.r.t. the order in which you do things? We don't need an
>
This is different. It was for the calculation of dMass and setting the
center of mass in dMass to be zero.

If you calculate a dMass from many dMassSetSphere and dMassSetBox not
all centered a 0,0,0.
The center of mass in dMass is not at (0,0,0).

dMass massBody;
dMassSetZero(massBody);

Ex 3 box of 1Kg at (0,0,0), (0,2,0), (2,0,0)
dMass massBox[3];
dMassSetBox(massBox[0], 1, 1,1,1);

dMassSetBox(massBox[1], 1, 1,1,1);
dMassTranslate(massBox[1], 0,2,0)

dMassSetBox(massBox[1], 1, 1,1,1);
dMassTranslate(massBox[1], 2,0,0)

// Center of mass in massBody = 0,0,0

// Center of mass in massBody is now = 0,1,0

// Center of mass in massBody is now = 0.666, 0.666, 0

Then you do a dBodySetMass(bodyID, &massBody);

The body is at 0,0,0 in world frame where is the center of mass of the
body ??????

At 0.666, 0.666, 0 !!  (WRONG ANSWER)

Always at the body frame i.e. since  the body is at 0,0, the mass is at
(0,0,0)
The value of the center of mass in massBody is discarded. Since for the
body its center of mass is always at (0,0,0)

Remi
```