# Shape Centers as Vectors: Local space or World space?

Given a shape (any shape) in a 2D world where all positions, locations, and centers are two dimensional vectors, should the shape's center be described in local space or world space?

EXAMPLE:

World Space center of a Rectangle: Position: (100, 100); Dimensions: (200, 200); Center: (200, 200);

Local Space center of a Rectangle: Position: (200, 200); Dimensions: (100, 200); Center: (50, 100);

World Space center of a Circle: Position: (100, 100); Dimensions: (50, 50) (diameter); Center: (100, 100);

Local Space center of a Circle: Position: (50, 50); Dimensions: (200, 200); Center: (0, 0);

• Depends on your use case, good arguments can be made for either. What are you planning to DO with these polygons? Aug 16, 2012 at 6:06
• It's a general question of common practice, really. It's not what I plan on doing, but what others plan on doing and if going one way or the other will make their life easier during development of a game. Aug 16, 2012 at 6:32
• I think we need to know a bit more about what you need these coordinates for. Dimensions is obvious, but what about position? Is the position the position of the center and the center is an offset to a corner of the rectangle? What point on the rectangle is specified with "position"? And what do you use center for? Some engines (such as cocos2d) use fractions (eg. 0..1) for center coordinates. Aug 16, 2012 at 6:35
• @bummzack It depends on the shape. A circle's position is also its center. In world space these are the same, but in local space the position is the center and the "center" is an offset of (0, 0). Aug 16, 2012 at 15:39

If at all possible, make a shape's center and its origin in local space be the same point. That is, describe the center in local space, but don't bother storing it—make it always (0, 0).

This is simply an attempt to reduce the number of unique spaces you have to think about. If your shape's center differs from its origin, you will probably at some point have to think about all of these:

1. world space vector from world origin to object origin;
2. world space vector from world origin to object center;
3. local space vector from object origin to object center;
4. local space vector from object origin to some other point on the object; and
5. local space vector from object center to some other point on the object.

If you make "object origin" and "object center" be the same thing, you can hopefully reduce that to 2 unique kinds of vectors (vector from world origin to object origin and vector from object origin to some other point on the object).

I assume your object's position in the world is not the same as its "center" (otherwise, if you specified the center in local coordinates it would always be the zero vector).

It all depends on your requirements, but I would imagine that specifying the "center" (whatever you define the center to be) in local coordinates would be easier since whenever your object moves you would not need to update its center vector as well.