### Rounded Corners and Squircles

October 13, 2011 When I was still doing experiments that required specialized hardware, I would enlist the services of our able machinists in their fully equipped machine shop. I would proudly show them my skillfully crafted CAD drawings, at which they were too polite to laugh, and they would ask me questions about the many details that I had left out. One question they would often ask is whether they should chamfer the edges. A chamfer is a beveled or rounded edge. The expression, "Nature abhors a vacuum," may be the paramount universal principle, but "Nature doesn't like hard edges or sharp corners," may be a close second. My son, unlike his amateur programming father, is an actual computer professional. He pointed out an interesting Steve Jobs story in his blog. Steve was a firm believer in the no-sharp-corners principle.[1] Bill Atkinson programmed QuickDraw, which was part of the Macintosh graphical user interface. The Motorola 68000 processor in the Macintosh was, as all microprocessors of the era, quite slow. There were, of course, no hardware floating-point operations, and integer multiplication and divisions were slow. Bill had devised a way to draw ovals that eschewed all the fancy math and used just additions and subtractions. As explained in Ref. 1, Bill used the fact that the sum of a sequence of odd numbers starting at one always equals a square; for example, 1 + 3 + 5 + 9 + 11 = 36. In general, Steve, who was known to be a demanding character, was not that impressed. What Steve wanted was rectangles with rounded corners, and he quickly pointed out many examples in their office and outside environments. Bill went back to his development station, and in just a few hours he devised an algorithm that drew rectangles with rounded corners that was almost as fast as his ovals algorithm.*Steve Jobs and Bill Gates at 'D5: All Things Digital' conference in Carlsbad, California, 2007.(Photo by Joi Ito, via Wikimedia Commons))*

Descartes would be proud of the extent that we've extended his concept of the graphical representation of algebraic equations in two dimensions to make our graphical user interfaces. Something like a rounded rectangle is one example of a superellipse poetically called a squircle. A squircle is an object that has qualities of both a square and a circle. The general equation for a superellipse, as shown below, was devised by the French mathematician, Gabriel Lamé, who is well known to mechanical engineers because of the Lamé parameters in elasticity. Lamé's second parameter is better known as the shear modulus. This equation generates a wide variety of closed curves, including the ordinary ellipse for n = 2. The ellipse, of course, becomes a circle when a = b. Other parameters will generate shapes that closely approximate a rectangle with rounded corners. For example, for a unit squircle, the parameters

**a**and

**b**are one, and the degree of "squareness" is set by the exponent,

**n**. Large values of n give you shapes that look more like a square.

*Squircles for n=4 (blue) and n=16 (red)*

Squircles will give you rectangles with rounded corners, but they're too computationally intensive for most purposes. I don't know how Bill Atkinson programmed rounded corners for QuickDraw, but I decided this would be an interesting programming exercise. Whenever an electrical engineer wants to smooth something, he puts it through a low pass filter. I decided to take this approach and feed a rectangle's corner multiple times through a simple low pass filter. You can see the result in the figure. The low pass filter was just,

xand the corner was passed through this filter five time. More rounding can be achieved with a larger number of passes through the filter. The actual effect will depend on the granularity of the input data points. This process is most likely not original with me, but how would I know? I'm just a computer amateur._{i}= 0.0625x_{i-2}+ 0.0125x_{i-1}+ 0.625x_{i}+ 0.125x_{i+1}+ 0.0625x_{i+2}

y_{i}= 0.0625y_{i-2}+ 0.0125y_{i-1}+ 0.625y_{i}+ 0.125y_{i+1}+ 0.0625y_{i+2}

*Rounded corner obtained by passing a rectangle's data points through a low pass filter.Graph via Gnumeric using data from a C program by the author.(C program source code))*

### Reference:

*Permanent Link to this article*

Linked Keywords: Experiment; machinist; CAD drawing; chamfer; Nature abhors a vacuum; amateur; Steve Jobs; Bill Atkinson; QuickDraw; Macintosh<; graphical user interface; Motorola 68000 processor; microprocessor; hardware floating-point operations; sequence; rectangle; algorithm; Joi Ito; Wikimedia Commons; Descartes; graphical representation of algebraic equations in two dimensions; superellipse; squircle; square; circle; equation; French; mathematician; Gabriel Lamé; Lamé parameters; elasticity; shear modulus; ellipse; electrical engineer; low pass filter; granularity; Gnumeric; C program source code.

### Google Search

Latest Books by Dev Gualtieri

**Previews Availableat Tikalon Press**

*STEM-themed novel for middle-school students*

*Mathematics-themed novel for middle-school students*

*Complete texts of LGM, Mother Wode, and The Alchemists of Mars*

Other Books

- Adhesives, December 4, 2023

- MOND and Planet Nine, November 27, 2023

- Earthquake Light, November 20, 2023

- Antimatter Gravitation, November 13, 2023

- Koch Snowflake, November 6, 2023

- Shared Dessert, October 30, 2023

- Quantum Uncertainty, October 23, 2023

- Sulfur Hexafluoride, October 16, 2023

- Cement Supercapacitors, October 9, 2023

- Fifth Force, October 2, 2023

- The Birthday Problem, September 25, 2023

- Iron as a Fuel, September 18, 2023

- Cosmic Asymmetry, September 11, 2023

- Work, September 4, 2023

- The Monty Hall Problem, August 28, 2023

- Memristors, August 21, 2023

- Aperiodic Tiling, August 14, 2023

- Fondant Physics, August 7, 2023

- The Gravitational Constant, July 31, 2023

- Length of a Day, July 24, 2023

- Random Walks, July 17, 2023

- Gravitational Lensing, July 10, 2023

- Tiny Bubbles, July 3, 2023

- Thales' Measure of the Sun, June 26, 2023

- Tetrataenite Magnets, June 19, 2023

- Utilitarian Music, June 12, 2023

- Medieval Volcanism, June 5, 2023

- Rare Earths from Bacteria, May 29, 2023

- Georges Lemaitre, May 22, 2023

- Reading Old Manuscripts, May 15, 2023

- The IQ Flynn Effect, May 8, 2023

- Cosmic Water, May 1, 2023

### Deep Archive

Deep Archive 2006-2008

**Blog Article Directory on a Single Page**