1

I want to sort some rectangles from biggest to smallest, but with a tunable advantage favoring squarer rectangles. I'm sure this is super easy but I'm not getting it. I think it's related to topics of dimensionality reduction, distortion, transformations.

The areas of the rectangles from origin to each of p might be equal, but squareness of the rectangle should be given a higher score by some tunable factor. Among rectangles of the same aspect ratio, bigger wins. But a smaller rectangle with a squarer aspect ratio can get a higher score than a bigger area that is less square.

https://www.desmos.com/calculator/emetuclvju

enter image description here

When the squareness weight indicates that squareness is irrelevant, we're just sorting by basic area (and ties are to be dealt with some other way). Everything along the red line here scores the same. Thinking geometrically, when squareness is given a positive weighting, then the curves would distort to be, what, sharper? So that the curve shows that points away from the purple line would be considered tie-scores with smaller squares?

So there's AREA, SQUARENESS, and a SQUARENESS_WEIGHT (0.0 ..1.0 ?) as inputs to a formula that should spit out a score. I'm sure I'm over thinking this. And I'm SURE this is a common need for sorting data as an alternative to sorting by height, width or area alone.

I'm also getting hung up on whether the resulting score should relate to anything geometrically/intuitively or whether the scale of the domain is arbitrary. Like, should a square get the same score as the area, with skinnier rectangles downgraded? Or should 1x rectangles keep the area-score but squares get a boosted score?

1 Answers1

1

As I understood your question, given a rectangle $R$ we should to assign to it some score $s(R)$ satisfying the required conditions. Suppose that the squareness weight is $w\in [0,1]$ and the rectangle $R$ has area $A_R$ and the perimeter $P_R$. Then we can consider $S_R=\frac{16A_R}{P_R^2}\in [0,1]$ as the squareness of $R$ and assign $s(R)=A_R(1+wS_R)$.

Alex Ravsky
  • 90,434
  • Your squareness function is an interesting alternative to $ \min\left(\frac{w}{h},\frac{h}{w}\right) $! But why add $1 + $ to $wS_r$? Is the resulting score more useful or intuitive than $AwS_r$? – Jason Kleban Jan 08 '24 at 00:31
  • And then, why scale it all by $w$? – Jason Kleban Jan 08 '24 at 00:46
  • 1
    @JasonKleban We scale by $w$ and add "+1" in order to ensure that "When the squareness weight indicates that squareness is irrelevant, we're just sorting by basic area ... Everything along the red line here scores the same". So when the area $A_R$ is fixed then the contribution of the squareness $S_R$ to the score is proportional to the squareness weight $w$. – Alex Ravsky Jan 08 '24 at 05:58