Night Owl
Night Owl

Reputation: 55

How do you determine the upper-left coordinates of a rectangle based on the center coordinates?

Based on the coordinate system, how would you determine the upper left coordinates of a rectangle if you are only given the center coordinates of the rectangle and the width and height?

For example, the center coordinates for a rectangle are (40,40) and the rectangle has a width of 90 and a height of 60.

Upvotes: 3

Views: 4966

Answers (2)

Juan
Juan

Reputation: 21

The answer provided corresponds to the BOTTOM LEFT corner... For UPPER LEFT corner in a xy coordinate system would be (x-w/2, y+h/2)

Upvotes: 0

peter.petrov
peter.petrov

Reputation: 39437

If center is (x,y) width = w height = h

Assuming the rectangle is sitting flat relative to the coordinate plane, the upper left corner is exactly (x-w/2, y-h/2).

Upvotes: 3

Related Questions