Question


I have a Math issue. I'm trying to find the coordinates and size of a bounding rectangle knowing another bounding rectangle and a thickness...

I know everything about the WHITE rectangle (bounding box GREEN, size, rotation, position).

The difference between the BLACK and the WHITE rectangles is the thickness (T). I want to find the size of the GREY rectangle (which is the bounding box of the BLACK rectangle).

So I know:

  • x,y
  • w,h
  • T
  • rot
  • r1 (position and size)

I want to find r2 (the bounding box of the BLACK rectangle).

Thanks for your answers :) and your time !!!!

Link to a image describing what I said enter image description here

Was it helpful?

Solution

If I am correct in my understanding given (x,y) and w, h and rotation rot for the white rectangle then you can calculate the green rectangle.

The black rectangle has the same rotation rot as the white rectangle so presumably if you know (X,Y) and W and H for the black triangle you can use the same method to find the grey rectangle as you did to find the green from the white.

Consider the white and black rectangles before rotation, ie width is horizontal

The X=x-T, Y=y-T W=w+2T, H=h+2T, so now you have (X,Y) W, H and rot for black rectangle so can calculate the grey one.

EDIT

If (x,y) is after rotation, then start with the white rectangle with its width horizonal and the top left corner at (lx,ty) it follows that the top left corner of the black rectangle is at (lx-T, ty-T) and its width W and Height H is given by W=w+2T H=h+2T.

Now whenever you rotate the white rectangle rotate the black rectangle by the same amount using the same centre of rotation. This gives you (x,y) for new coordinates of the top left corner of the white rectangle and (X,Y) as the new coordinates of the top left corner of the black rectangle from which you can calculate the bounding rectangles.

EDIT rotating (x,y) about (0,0) by angle theta, with (x,y) rotating to (lx,ty)

lx=xcos(theta)-ysin(theta)

ty=xsin(theta)+ycos(theta)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top