Title: RE: [JAVA3D]

>Can somebody tell me how to find out the center of
>gravity of primitives in Java 3D API like cone,
>cylinder, sphere etc. I should be able to get the
>center of gravity of primitives at any point on the
>screen i.e if I have moved primitive from one place to
>another, I should be able to get center of gravity at
>that particular point.

Center of gravity is weight averaged body coordinate so it is x0 = Integral{m(x)dv}/M, where m(x) is mass density, M is total mass, x is vector coordinate over the body and volume integral is taken over the body, of course. From your description it is fare to suppose that your primitives have constant density and volume does not depend on the coordinate, so the formula becomes x0 = Integral{dv}/V, where V is the volume. You can compute it for every primitive in its local coordinates separately (try sphere first) and then apply primitive local-to-world transformation to the precomputed center of gravity.

- Yuri

Reply via email to