   Finding centre of a 2D shape for rotation?
  Hi.  I have a 2d shape and i want to find out its centre about which i can rotate it. I also want to use this centre point for scaling without affecting its position. I would use this to first translate the shape so that its centre concides with origin, scale it, and then translate it back.Any simple algorithm to calculate the centre, knowing the vertices of the shape? Thanks. 
  simple algo. Vector Centre;for(int i = 0; i < num_vertices; i ++){    Centre += vertices[i];}Centre /= (float) num_vertices;;  Many different types of 'center' ...I'd just get it's maximum and minimum X and Y coords ... then CenterX = (MinX+MaxX) *0.5CenterY = (MinY+MaxY) *0.5for 3d just add CenterZ = (MinZ+MaxZ) *0.5//edit - was: CenterZ = (MinX+MaxX) *0.5  [edited by - PyroSA on April 5, 2004 4:29:01 PM];  Biggest problem with the average algorithm is that it screws up if there''s a high concentration of points in one area.  It used mostly for problems involving varying mass density across an object (as a function of these control points) and centers of mass.  But if you have something like a spaceship and you want to find the center, use the bounding box algorithm. ;  he said ''simple'' ;  Well, bounding boxes are simple too   And fun.  Don''t forget fun. ;  "Well, bounding boxes are simple too And fun. Don''t forget fun"  If thats what they are, can u please tell me the method? Thanks. ;quote:Original post by PyroSA  Many different types of ''center'' ...I''d agree. There are lots of ways to decide the center. For more complex methods, most standard Computer Graphics textbooks outline good ways of doing this, since it''s a pretty old problem. ;quote:Original post by Astroguru  "Well, bounding boxes are simple too And fun. Don''t forget fun"  If thats what they are, can u please tell me the method? Thanks.   Sure.  Find the maximum and minimum values for the X and Y coordinates out all all the points you have.  Then take the average of each set to get the center, i.e CenterX = (maxX + minX) / 2, CenterY = (maxY + minY) / 2. 