"center of gravity" of a AcDbPolyLine

"center of gravity" of a AcDbPolyLine

Anonymous
Not applicable
546 Views
4 Replies
Message 1 of 5

"center of gravity" of a AcDbPolyLine

Anonymous
Not applicable
Hello,

I am not a mathematician. Has anybody a algorithm to calculate the "center
of gravity" of a closed Polyline ?

Regards

Robert
0 Likes
547 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
"Robert Nihl" wrote in message
news:[email protected]...
> Hello,
>
> I am not a mathematician. Has anybody a algorithm to calculate the "center
> of gravity" of a closed Polyline ?
>
> Regards
>
> Robert
>
>

Hi,

gx = ( x0 + x1 + ... + xn ) / n

n - numVerts

x0...xn - x coordinates of the polyline vertexes

And apply the same formula for gy and gz.



Regards,

Bogdan
0 Likes
Message 3 of 5

Anonymous
Not applicable
> gx = ( x0 + x1 + ... + xn ) / n
> n - numVerts
> x0...xn - x coordinates of the polyline vertexes
>
> And apply the same formula for gy and gz.
>

That is much easier as I expected 🙂

Thanx

Robert
0 Likes
Message 4 of 5

Anonymous
Not applicable
Hi, Bogdan!
You wrote to newsgroup Thu, 16 Oct 2003
02:22:49 -0700:
B> Hi,
B>
B> gx = ( x0 + x1 + ... + xn ) / n
B>
B> n - numVerts
B>
B> x0...xn - x coordinates of the polyline vertexes
B>
B> And apply the same formula for gy and gz.

It's not exactly for polyline with arc segments!

Best Regards,
Alexander Rivilis
0 Likes
Message 5 of 5

Anonymous
Not applicable
Agree, I've written the answer without thinking at arcs.
Also, there is another error in my previous post: the last x value should
have the indices n-1.
If the polyline has arc segments an AcDbRegion could be made from the
polyline and use getAreaProp(...) method to find the centroid of the region.

Regards,
Bogdan

"Alexander Rivilis" wrote in message
news:[email protected]...
> Hi, Bogdan!
> You wrote to newsgroup Thu, 16 Oct 2003
> 02:22:49 -0700:
> B> Hi,
> B>
> B> gx = ( x0 + x1 + ... + xn ) / n
> B>
> B> n - numVerts
> B>
> B> x0...xn - x coordinates of the polyline vertexes
> B>
> B> And apply the same formula for gy and gz.
>
> It's not exactly for polyline with arc segments!
>
> Best Regards,
> Alexander Rivilis
>
>
0 Likes