Smoothed polygons

The previous post constructed a triangular analog of the squircle, the unit circle in the p-norm where p is typically around 4. The case p = 2 is a Euclidean circle and the limit as p → ∞ is a Euclidean square.

The previous post introduced three functions Li(xy) such the level set of each function

{(x,y) mid L_i(x,y) = 1}

forms a side of a triangle. Then it introduced a soft penalty for each L being away 1, and the level sets of that penalty function formed the rounded triangles we were looking for.

Another approach would be to change the L‘s slightly so that the sides are the levels sets Li(xy) = 0. The advantage to this formulation is that the product of three numbers is 0 if and only if one of the numbers is zero. That means if we define

f(x, y) = L_1(x, y) L_2(x, y) L_3(x, y)
then the set of points

{(x, y) mid f(x,y) = c}

corresponds to the three lines when c = 0 and the level sets for small c > 0 are nearly triangles. The level sets will be smooth if the gradient is non-zero, i.e. c is not zero.

This approach is not unique to triangles. You could create smooth approximations any polygon by multiplying linear functions that define the sides. Or you could do something similar with curved arcs.

If we define our L’s by

begin{align*} L_1(x,y) &= y\ L_2(x,y) &= y - 2x - 2 \ L_3(x,y) &= 3y + x -3\ end{align*}

then our curves will be the level sets of

f(x, y) = y(y - 2 x - 2)  (3 y + x - 3)

A few level sets are shown below. The level set for c = 0 is the straight lines.

Note the level sets are not connected. If you’re interested in approximate triangles, you want the components that are inside the triangle.

 

The post Smoothed polygons first appeared on John D. Cook.

Liked Liked