Hacker News new | ask | show | jobs
by xg15 15 days ago
Can someone explain the difference to me between a rounded rectangle and a squircle?
9 comments

The sides of a squircle never become completely straight, they are curved at every point.

One consequence of that is that they scale more nicely for nesting: https://thatsmaths.com/wp-content/uploads/2016/07/squircles-... (right half of the image)

Of course, Apple’s squircles deviate from that by inserting straight line segments. What remains is that the corners still have a non-constant curvature.

A highway or railway curve between two straight segments is usually not a simple circle arc. If it were, the sudden discontinuity in higher derivatives (acceleration and jerk) at the transition point from straight to curved would feel uncomfortable, be harder to anticipate and slow down appropriately by a driver, and cause unwanted shear stresses to mechanical parts. So transition curves are used that smoothly vary the curvature from zero to that of the circular segment and back to zero again. The typical transition curve in engineering is called a clothoid, which is one of the squircle types mentioned in the article.

In digital graphic design curvature discontinuities don’t usually cause mechanical issues, but discontinuities in curved shapes can still look jarring – for whatever reason the visual system is rather good at detecting such sudden changes in shapes, even those that naively "should" look smooth.

Ha! Must you tease me so ?

This is one of my pet fascinations (nerd snipe pits) - deciphering transition curve markings along railway tracks while travelling by train, preferably peeling an orange [*]. These transition curves are usually some approximation of an Euler Spiral (aka Cornu Spiral, Clothoid), typically a cubic parabola. To compute the Euler spiral as a closed form one gets into Fresnel integrals. Cubic parabolas are a lot easier to compute and for short arc lengths almost indistinguishable.

These get used in roller-coasters too, for pretty much the same reason (to avoid the "jerk")

What is not so well known is that Markov (of Markov chains) worked on the problem of optimal curves for joining straight railway tracks constrained by steering dynamics of trains. I think this was before his work on chains. His formulation was later rediscovered independently by Dubins.

[*] I am so glad you asked why an orange https://arxiv.org/html/1202.3033v1

Train track transition curve diagrams are also where you would still encounter the mow archaic trigonometric function the versine except that they standardize it to some standard radius that is not unity.
On a rounded rectangle, the shape of the corner is continuous, but the curvature is not - it jumps from 0 to R. Rounded rectangles look fine, but if you're attuned to it, this subtle discontinuity can look just a little bit off.

A squircle is one (actually several variations) approach to making the curvature continuous.

I would say it's still a subjective aesthetic difference, but you can use math jargon to explain why you like one better than the other.

A regular rounded rectangle is G1 continuous while a squircle (superellipse) is G2 continuous, which means that it is not only continuous on position and tangent for its outline, but the curvature rate of change for the outline is also continuous, so it's smoother and doesn't have hard difference between "line" and "rounded corner" on the shape.
A standard rounded rectangle has quarter-circle corners. A squircle starts curving earlier and more gently, with a gradual transition from its flatter sides into its corners.

Personally, I prefer regular old round rectangles. Squircles are ugly.

Like Raph's post says: squircles do not have a single agreed-upon mathematical definition. I don't think "rounded rectangle" does either.
I think a rounded rectangle is defined as 4 straight line segments joined with G1 continuity to quarter circle arcs. I'm unaware of any other definition. The only variation I know is whether the radii have to be the same or can be different. Flexible implementations do allow the latter.
So a letter "D" is an extreme rounded rectangle with different radii on the left and right side? That makes some sense.
I like that he asked this question because that was not a question I thought to even ask
Rounded rectangle is a rectangle with fixed radius corners, a “squircle” is some shape where the corner’s radius is not constant.

(My interpretation)

Wow, I wasn't expecting so many interesting responses in return of that question. Thanks a lot!