• Advertisement
Sign in to follow this  

Calculating Centre of changing shape

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 = vectors_add(result,tab);
}


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 this post


Link to post
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 this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement