I have a rotated rectangle inside a bounding box. It can be rotated to any angle.

I know the coordinates of the "top left" corner of the inside rectangle (and I am able to work out the other 3 points, and the centre point). I also know the full length of the top of the bounding box.

I need to be able to figure out the coords of the bounding box corners or the length of the edges, where the inner rectangles corners intersect.

See the image, I need to find out what the ? is.


In your case, each coordinate of each corner of the bounding axis-aligned rectangle is obtained by taking the minimum or maximum as appropriate of the corresponding coordinate of your original (rotated) rectangle.

  • $\begingroup$ Oh, what an elegant answer. I almost started doing trig, but now I see that OP has already done all the trig they need. $\endgroup$ – hexaflexagonal Jun 25 '15 at 16:11
  • $\begingroup$ So, to get the length, I'd do something like x1 - x2? (x1 being the known coords, x2 being the bounding bx corner coords) $\endgroup$ – Paul Canning Jun 26 '15 at 8:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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