# Coordinate Translation in 2 Squares

• Aug 5th 2012, 01:41 PM
taquinas123
Coordinate Translation in 2 Squares
My brain is not working. I just can't get this right.

I have 2 rectangles (they are actually approximately squares).

One square (s1) is 984 units wide and 984 units tall.

The other square (s2) is 2952 units wide and tall.

There is a point somewhere in s2 (lets say 394, 581). I need the equation that gets the X and Y offset needed to overlay s2 over s1 so that the point in s2 is always in the center of s1 no matter where the point is in s2.

If that makes sense.

Think of it like I have a person standing on a location in a world. They are a point on a massive map. However, I can only display a small portion of the map and I want that person to always be in the center.

This seems like it should be super simple, but I am operating on 3 hours of sleep and it feels like an insurmountable task at this time. Please, someone save me.
• Aug 5th 2012, 03:29 PM
HallsofIvy
Re: Coordinate Translation in 2 Squares
I'm puzzled as to why you say "approximately squares" when what you give are exactly squares. You tell us how large S1 is but if we are going to translate it so that a given point is at its center, then we have to know where it is. If you mean, for example, that the lower left corner of S1 is at (0, 0) and two sides are along the x and y axes, so that its vertices are at (0, 0), (984, 0), (984, 984), and (0, 984), then its center is at (492, 492). To translate that to \$\displaystyle (x_0, y_0)\$, add \$\displaystyle x_0- 492\$ to x and \$\displaystyle y_0- 492\$ to y.