On Wed, 8 Dec 2004, Trent Buck wrote:
Up spake bulia byak:
AFAIK, you can't use the gravitic center (my terminology), only the bounding-box center. If there's already an RFE, submit one. It sounds a useful feature.
Will it be useful not only for triangles?
Well, I can't think of anything that I'd use it for, but is that any reason not to do something?
Actually I've run into several cases with technical drawing where snap to centroid would have been useful. I ended up just manually fiddling it into position.
Imagine for example a drawing of a lamp with a power cord strung out behind it. Obviously you want the image to snap to the center of the lamp, and with centroids, the 'weight' of the cord would be negligible so you'd get (pretty close to) the true center. However with bounding-box centering you get a different centering location.
This may seem like kind of a corner case, but it actually comes up a surprising amount of the time when you're trying to create flow charts, network diagrams, and so on, where you're attaching irregular shapes to lines.
If you use a gravity center for an arbitrary path, its curved parts with many nodes will be heavier than smooth parts. Is this what you want?
I was thinking of center of gravity being based on area.
Let O be the object. Let G be the center of gravity of O. Let Ri be a ray from G to infinity such that the minor angle between the base ray and Ri is i. Let Rj be another such ray, such that the minor angle between Ri and Rj is j. Let Aij be the area of O between Ri and Rj.
G is the point that best satisfies the following condition:
(approximates (quotient (sum (n in 0 to (product 2 Pi)) ;; interval is 1 (radian) (sum (m in 0 to (product 2 Pi)) ;; interval is 1 (radian) Anm)) (product 2 Pi 2 Pi)) 0)
That's rather messy, slow and probably incorrect. It's two days past my bedtime.
If I remember from engineering class, there's several different schemes for calculating different sorts of centroids, including approximation methods (for highly complex shapes, centroids can be relatively expensive to calculate.) I imagine that it would probably be worthwhile to implement this in a way that would allow for more than one centroid calculation algorithm.
Bryce