Calculate $x_1$ $x_2$ $y_1$ $y_2$ from center coordinates,height and width

408 Views Asked by At

What i have here is a rectangle or square.I have the center coordinates $x$,$y$, width and height.How do i go about finding the $x_1$, $x_2$,$y_1$ and $y_2$ from these.

1

There are 1 best solutions below

0
On

Only if the rectangle or square is not rotated, then:

assuming the +y direction is up and the +x direction is right

$top-left = (x - width/2, y + height/2)$

$top-right = (x + width/2, y + height/2)$

$bottom-left = (x - width/2, y - height/2)$

$bottom-right = (x + width/2, y - height/2)$