POV-Ray : Newsgroups : povray.general : Object "center of mass" macro : Re: Object "center of mass" macro Server Time
30 Jul 2024 12:31:50 EDT (-0400)
  Re: Object "center of mass" macro  
From: waggy
Date: 7 Sep 2009 15:00:00
Message: <web.4aa557b7708de865f99d05c80@news.povray.org>
CShake wrote:
> waggy wrote:
> I've now written my moment of inertia macro, and couldn't find an
> optimized way to do it in n^2, so here it is in n^3. My issue here is
> that I'm getting the wrong values for the moments for everything but a
> box, and I can't figure out why. Spheres and Toruses are giving almost
> exactly half the official value. This macro would have even less of an
> audience than my last, but again any math help would be appreciated.
> I need to read up more on how to use moment of inertial tensors for
> calculating the moment about an arbitrary axis, and I left my dynamics
> textbooks at home this semester...
> Also, this macro requires the center of mass to already be computed.
>
> Chris
>
> (I'm interchanging volume and mass here in the terminology, sorry. It
> will be better once density is involved.)

This is very much right up my alley.  (I'm currently working on a research grant
to calculate the stress intensity factor around a crack tip using a
complex-perturbation numerical integration technique.)  I apologize I probably
won't have time until later this week to help with the math and look at your
factor-of-two error (if you haven't already found the problem by then).

I would like to see both your original kn^2 macro and an n^3 macro calculating
useful inertial and geometric properties of an arbitrary object.  (I used
intersecting open xy planes and trace() rather than inside(), for my n^3 macro.
 I'll test both later to see which is better for the pathological cases that
need to use an n^3 method.)

From what you've posted so far, it looks like a good approach.  I think you may
end up calculating the volume, center of mass, and inertial tensor with respect
to the origin all together.  Then, after the loops, find the stress tensor with
respect to the center of mass.  Now you can find the directions of the
principle axes by finding the transformation needed to diagonalize the stress
tensor.  As you're already doing, you should be able to leave factoring in the
density until the end (assuming the density is constant).

As far as using a different subdivision axis, I agree that you'll find it far
easier to rotate the object by the inverse of the desired axis rotation, use
the loops as they are, then transform the coordinate results.

~David


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.