How to calculate center coordinate of rectangle

132 Views Asked by At

How to calculate center of rectangle? Info available is rectangle's width and length and bottom left corner coordinate and angle theta between x-axis and the line from bottom left corner to bottom right corner.

ie: bottom left corner coordinate is (100,900), width is 800, height is 600, theta is 1 degree. What is the center coordinate?

example image

method I tried is

  1. find the other 3 corner coordinates assuming the rectangle is aligned to x-axis
  2. calculate the center coordinate of the axis aligned rectangle
  3. rotate the center coordinate back by angle theta using the bottom left corner as origin.

This however doesn't seem to work. Any help appreciated.