Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I have a rectangle defined by four (x, y) points. It is angled and not aligned with the (x, y) axes.

For example, say I have this rectangle:

lowerLeft   {x=178.77817 y=213.27817 }
lowerRight  {x=207.06244 y=184.99390 }
upperLeft   {x=171.00000 y=205.50000 }
upperRight  {x=199.28426 y=177.21573 }

I want to set its center point to another position, say (419.0, 671.0). How can I determine the new (x, y) points for this rectangle based on its new center position?

I know that I can make an axis aligned rectangle with the same center point and rotate it, but how can I determine the number of degrees to rotate?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Determine the original center point (intersection of diagonals). Use that to determine the translation needed to move it to the new position. Then apply the translation to your 4 other points.

share|improve this answer
    
I think that may have solved my problem. Thanks a lot! –  user59032 Jan 20 '13 at 21:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.