# baricentric coordinate of a 2d shape

This topic is 2170 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

hello.
I have 2d shapes with variant number of vertices .
All the vertices are in a list of of 2d vertices.
How i can find the baricentric coordinate of the shape?
is difficult?

thanks.

##### Share on other sites

You probably want to compute the centroid for the shape, also called the barycenter, or in physical context the center of gravity. For this you have to add the positions of all vertices, weighted by their respective mass, and normalizing the sum then by using the sum of masses. Perhaps the masses are given as constant 1 for each vertex, so that the sum of all positions simply needs to be divided by the count of vertices.

Barycentric co-ordinates itself are something different. For a given point you have to compute the particular weights for all vertices so that that the centroid is exactly at the given point.

That said, the centroid as computed in the first paragraph above shows equal scalars in its barycentric co-ordinates.

##### Share on other sites

sorry, but what you intend for mass?
I would calculate the barycenter for identify with a line(on the barycenter) the presence of a column without drawing the column in 3d, it's a simplification for understand where are the columns in a simple architectural 3d cad system.

Thanks.

##### Share on other sites

In a physically based context the vertices are meant as positions of concentrated masses. This can be generalized to weights that are attached to the vertices. As already mentioned, if you don't have a use case for weights (and so it seems), simply treat them as 1.

Hence: centroid.position := sum( vertices.position ) / count( vertices )

Notice please that the above is independent on the dimensionality of the space in use. The centroid's co-ordinates will be given w.r.t. the same space as the vertex positions, of course.

##### Share on other sites

very thanks.
This is only valid if the shape is closed?
There are problems if the shape is for example a T or an H(profiles for architecture)?
T and H are not a shape closed.

Thanks again.

##### Share on other sites

This is only valid if the shape is closed?

The computation relies on discrete positions, not edges or faces. It would even work if only a couple of points were available.

However, as soon as you begin to interpret vertices distinctively with respect to their connectivity, you perhaps need to consider weights again.

• 18
• 29
• 11
• 21
• 16