0
$\begingroup$

Let's say we have a circle (position of its center and radius are known) and a rotated rectangle (width, height and rotation are known).

The rectangle has 8 "anchor points": 4 at its corners, 4 at the mid-point of its edges.

Now imagine there's a given radius at a specific angle, and we want to move the rectangle along with that line starting from the center of the circle to the edge until one of its eight "anchor points" reaches the perimeter of the circle. How do I compute the center point of the rectangle at this position?

Moreover, if we keep moving the rectangle until the last of its anchor point located on the perimeter, what is the center point of the rectangle?

Here's the image demo

$\endgroup$
0
$\begingroup$

Referring to the picture provided, let us assume $\alpha = 0, \beta = 0$. Now we will assume the rectangle moves with the radius as if it is fixed to the radius, so $\alpha = \beta$.

enter image description here

Suppose you rotated the radius by $\alpha$ anticlockwise and so now $\beta = \alpha$. Now in this position we rotate back the rectangle by $\gamma$ clockwise, such that $\beta = \alpha - \gamma$ is the desired angle you wanted to rotate the rectangle.

Now going back to the picture above we see that in this position if it moves outwards then both 3 and 5 will touch the perimeter together, 4 will never touch first; for this matter no points on the mid of the sides will touch the perimeter first as it is concave inside a circle.

In this position if we start rotating the rectangle say clockwise then we see immediately 3 will become the point which will touch the perimeter first.This will continue till we rotate full 90 degree. At that point both 3 and 1 will touch the perimeter first.

Now to summarize, the points will touch; $\gamma = 0\rightarrow (3,5), 0 <\gamma < 90 \rightarrow (3), \gamma = 90\rightarrow (3,1), 90 <\gamma < 180 \rightarrow (1), \gamma = 180\rightarrow (1,7), 180 <\gamma < 270 \rightarrow (7), \gamma = 270\rightarrow (7,5), 270 <\gamma < 360 \rightarrow (5)$ , Note that we calculated $\gamma$ in earlier equation ($\gamma = \alpha - \beta$).

Now to find out the last point while going out we observe circle is convex outside so (referring to same picture above) 8 will be the last point when $\gamma = 0$, to summarize

$\gamma = 0\rightarrow (8),0 <\gamma < 90 \rightarrow (7), \gamma = 90\rightarrow (6), 90 <\gamma < 180 \rightarrow (5), \gamma = 180\rightarrow (4), 180 <\gamma < 270 \rightarrow (3), \gamma = 270\rightarrow (2), 270 <\gamma < 360 \rightarrow (1)$

Now to determine the center of the rectangle, let us assume length of its longer side is a and shorter side is b. So for the picture where $\gamma = 0$ the distance from center will be $\sqrt{r^2 - (b/2)^2} - (a/2)$, Note that here you only need to know this distance as the angle subtended by the radius ($\beta$) is already given (and the center of the rectangle lies on the line of the radius).

Now in the following picture enter image description here

The rectangle is rotated by $\gamma$ clockwise. Let $g= \sqrt{(a/2)^2+(b/2)^2}$ and $\sin\delta = \dfrac{b/2}{g}$, we can calculate $\delta$ from here. So above length of line segment drawn from 3 on O4, which is perpendicular to O4 is $h = g\sin(\delta - \gamma)$, so distance from center O is $\sqrt{r^2-h^2} - g\cos{(\delta - \gamma)}$. Note that when $\gamma = 0$, this falls back to earlier equation. Now this is valid for $0 \leq\gamma \leq 90$

For $90 \leq\gamma \leq 180$, we note that g will remain same, $\sin\delta = \dfrac{a/2}{g}$, $\gamma = \gamma - 90$.

So $h = g\sin(\delta - (\gamma - 90) ) = g\sin(\delta + 90 -\gamma )$; diatance = $\sqrt{r^2-h^2} - g\cos{(\delta +90 - \gamma)}$

For $180 \leq\gamma \leq 270$, g will remain same, $\sin\delta = \dfrac{b/2}{g}$, $\gamma = \gamma - 180$.

For $270 \leq\gamma \leq 360$, g will remain same, $\sin\delta = \dfrac{a/2}{g}$, $\gamma = \gamma - 270$.

$\endgroup$
  • $\begingroup$ Thank you for your help! However, finding out the anchor point is only the first step to solving the problem, I still need to calculate the position of the rectangle (defined by the coordinates of its center). $\endgroup$ – Kenny Liu Jun 2 at 3:52
  • $\begingroup$ @KennyLiu I missed that earlier. I just edited my answer. $\endgroup$ – amitava Jun 2 at 6:50
  • $\begingroup$ Also please check with some random values of angles, radius and dimension of the rectangle. $\endgroup$ – amitava Jun 2 at 7:10

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.