Polygon.Center question

Hi all

i have question about Polygon.Center. it get the Center (CG) for open section such as channel not as i expect
here is an example to prof:

i expect the location of the CG is = 0.161 m calculate based in the below equation but it 0.275 m from dynamo node

also i test for angel cross section, the cg is not as i expect

thanks
Mohareb

Center of a polygon is calculated by the average of the points, not the distribution of the mass (polygons can self intersect if memory serves, though that might only be polycurves…).

3 Likes

Hi, I understand that this is a cross-sectional property and not related to mass. However, it appears to be located incorrectly—it seems to be shifted along the direction of the principal axis.

I don’t see dimensions for the second shape and haven’t run this into a calculator, but for the first one [0,0.5,0.5,0.1,0.1,0.5,0.5,0] sums to 2.2, which divided by 8 gets us 0.275, which is what you showed, right?

1 Like

The centroid of a polygon is determined using the geometry of its shape and vertex coordinates, not by simply averaging the point positions.

Jacob beat me to it, but here’s a visual of what he’s saying: the “center” is weighted by point distribution - the same polygon with additional points will not have the same “center”.

It might be worth renaming the node but the description accurately states it finds the average position of points. This may not be the “mathematical” center of a polygon but it’s what the node does.

3 Likes

@jacob.small @Nick_Boyts I agree—if it’s just the average position, then to me it doesn’t really hold much meaning. But as @Nick_Boyts pointed out, that’s not the true center of the polygon.

@jacob.small @Nick_Boyts

As @jacob.small pointed out, it’s written in the node’s description:

Right - but centroid is not the same as ‘center’. A Dynamo Polygon also can break form the plane, which makes the formula above invalid (or I think it does).

Case in point this is a valid Dynamo polygon but not a valid mathematical polygon (though I believe it’s still a polytope):

Autodesk.Polygon.ByPoints(
	Autodesk.Point.ByCoordinates(
		[0,1,0,1],
		[0,0,1,1],
		[0,1,2,1]
	)
);
2 Likes

hi
I think you know how to do it, but you never know.


Edit:
Oh yeah, I forgot. Genius Loci has one for surfaces, but you don’t need any curved edges for it to work (the algorithm used is written in the node).
cordially
christian.stan

1 Like