Calculating Centre of changing shape

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

Recommended Posts

you have the length of each side, but the number of sides is ever changing

for example a triangle will turn into a square and then into a octagon. How would i go about finding the centre point each time?

Thanks

Share on other sites
Are the edges described in some order (i.e. clockwise)? Are the polygons convexes? In what coordinate system should the centre be described? Do you know something else?

Share on other sites

Are the edges described in some order (i.e. clockwise)? Are the polygons convexes? In what coordinate system should the centre be described? Do you know something else?

Sorry if i wasn't descriptive. I start off with a 3d triangle in 3d space (x,y,z).
The polygons are convexes.

The things i would know = Centre point of the 3d triangle. The dimensions of each polygon. All the polygons will be the same height and width.
A new polygon (4 vertices) will be added up until there are 360 sides.

Share on other sites
What do you mean by "A new polygon will be added up"?

Share on other sites
Just iterate over the vertices and average the result.

Share on other sites
Dirk Gregorius meant that you should add all point to each other and divide components of point by their number

create temporary var ( with components such as x y and z)

set them to 0.0; (all of them)

then go through all verts and add them to temporary var

then divide temporary components by the number of verts

sth like this:

t3dpoint sum(LIGHT_TRAIL tab)
{
int i;
t3dpoint result;
result.x = 0.0f;result.y = 0.0f;result.z = 0.0f;

for (i = 0; i < tab.Length; i++) {
}

result.x = result.x / float(tab.Length);
result.y = result.y / float(tab.Length);
result.z = result.z / float(tab.Length);

return result;

}

[/quote]

it only works for convex polys

Share on other sites
Thank you for all the replies, I have solved it myself fortunately using the law of sines, right triangle and a ormula I developed,

Oh and what I meant by a new polygon being added up, was that I would start off with 3 polygons for the triangle (no top face or bottom face). And then add another polygon to the scene to turn it into a
square and so on, until there 360 polygons.

Share on other sites

Just iterate over the vertices and average the result.

Assuming the polygon is a regular polygon (Which OP may be hinting at).

To OP, it doesn't matter how many edges you have or how long they are, the equation is the same:
http://en.wikipedia.org/wiki/Centroid#Centroid_of_polygon

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• Forum Statistics

• Total Topics
633293
• Total Posts
3011237
• Who's Online (See full list)

There are no registered users currently online

×