How to calculate similarity between two rectangles?

27 Views Asked by At

How to find similarity between two rotated rectangles, while considering the rotational symmetry into account?

Assume we have two 2D rectangles of same dimension rotated around the center, $R_a$ and $R_b$. $R \in \{x,y,\theta\}$. Here, $\{x, y\} \in \mathbb{R}^{2}$, and $\theta \in (0,360.0)$ Example: $R_a =\{x,y,350.0\}$, $R_b = \{x,y,171.0\}$. The absolute rotational error difference is 180 deg. However, when the rectangles are plotted(link below), we can see that they are "closely aligned" due to rotational symmetry of rectangles. How do we quantify this similarity?

$\textbf{Idea:}$ Find the sum of Euclidean norm for the corner coordinates. \begin{equation} Rot_{err} = \sum_{i=1}^{n} || {a}_{c_i} - {b}_{c_i} || \end{equation} Here, ${a}_c$ is the corner of the rectangle $R_a$, ${b}_c$ is the corner of the rectangle $R_b$, and $n=4.$ In this case, $Rot_{err} = 0.28$. But, this seems to be finding the Euclidean position error between two rectangles in a different sense. Probably, I am wrong here.

Is there any better way to handle this?

Two rectangles: yellow and blue colored