Need advice to sketch squircle

Doesn’t the flat part have zero lenght (just the middle point) ?
We shouldn’t see a flat zone then, no ? :slight_smile:

Anyway, I let an online calculator (https://www.derivative-calculator.net/) find the second derivative of the curve defined by

y^4 + x^4 = r^4

It also seems to be zero at X=0, if I’m not wrong … :confused:

I don’t know if this also implies a zero curvature there … :confused: :slight_smile:

2 Likes

I added rational degree 2 curves with corner weights of 2.146 and 2.143, and a set of “exact” points. Unfortunately the rational degree 2 curves are not particularly good matches.
squircle DC10.3dm (1.5 MB)

1 Like

Yes, zero curvature at x=0. Also zero curvature at y=0.

2 Likes

You can use Python to create it from the equation: y^4 = 1-x^4
This create a quarter squircle than use polar array

! _-RunPythonScript (
import math
import rhinoscriptsyntax as rs

def squircle(n):
    points = []
    for i in range(n+1):
        x = i/n
        xx = 1-math.pow(x,4)
        y = math.sqrt(math.sqrt(xx))
        pt1 = (x,y,0)
        pt2 = (y,x,0)
        points.append(pt1)
        points.append(pt2)
    points = rs.CullDuplicatePoints(points,0.1)
    points = rs.SortPoints(points,True,0)
    return rs.AddPoints(points) ,rs.AddInterpCurve(points,3,1)

count = int(rs.GetReal("Points count",100))
if count:
    squircle(count)
)

3 Likes

There is a test command, testSuperEllFromExp. You have to type it out completely. Try with exp 4 or 5. I think I wrote it a few years ago. Not sure if it’s useful.


SuperEllipse.3dm (47.2 KB)

5 Likes

Lofting a bunch of those makes a nice thing -

-Pascal

2 Likes

Looks like all I did for the test command was make a rational quadratic with the right weight to match the 45 degree point. I wonder if there’s a more exact NURBS solution. My first thought on that is that the exponent would have to be even, and the degree would match the exponent. I’ll mess around with it when I have time.

If you look at the points that show the deviation from the mathematical definition in the test function, you can see that the correct answer is flatter at the extremes and has 0 curvature as was mentioned. I wonder if for, say, degree 4, you put the middle cv for the quadrant in the obvious place and line up the others along the rectangle’s side with weight 1 or something based on the degree, you could figure out the weight of the corner point and get a very good answer.

2 Likes

@chuck That is the approach described in the reference I linked above: Need advice to sketch squircle - #13 by davidcockey It is not exact. I have a very vague recollection of reading that there is not a NURBS representation for general superellipses, but I cannot find a reference.

A series of gradually changing superellipses have been used to create geometry for air ducts and passages where gradual shape transistion is critical, such as jet engine inlets and engine manifolds and ports.

1 Like

Here’s a rational degree 4 solution. The weights are all 1 except at the corners where they should be the solution to (7 + 6w)/(10 + 6w) = fourth root of 1/2. I used an approximation of 1.478.
D4.3dm (42.8 KB)

1 Like

Hi Chuck,

I’ve added your curve to the curvature graphs for the interpolated squircle, rounded rectangle and Pascal’s degree 4 curve. Your curve is closer to the squircle than the rounded rectangle, but not as close as Pascal’s.

squircle 001.3dm (361.0 KB) (n.b. R8 format)

Regards
Jeremy

Mine is just a simple attempt at matching the degree 4 superellipse at the mid parameter by adjusting only the weight at the corner. I started looking into optimizing all 3 interior weights but had other commitments. A good project for another day.

Hi all.
Made some attempts at going near to jeremy’s squircle.
Galapagos did most of the work…


squircle 001.3dm (177.3 KB)

Hi Riccardo,

All three are good fits to the squircle and, unlike previous examples, you have smooth curvature graphs in the middle of the sides (e.g. at a):

Care to share your gh file?

Regards
Jeremy

I haven’t understood how you got the squircle reference curve, but that curve is very little off the 20x20 volume…

Currently galapagos is approaching that curve.


squircle.gh (33.7 KB)

Running galapagos to approach the mathematically correct coordinates, instead, might give better results…

… maybe…

Edit: oh, I’ve seen, it’s the x^4+y^4=r^4 … it give the same results…

Yes, it is here in Grasshopper, but dimensioning the baked curve in Rhino, with resolution pumped up to 0.00000001, shows it as 20.00000000x20.00000000. Don’t know why Rhino and GH show different values, but the difference is below the document tolerence. If I generate a new curve from the same GH script as before it is exactly 20x20 in both environments, so the old curve’s difference may be a consequence of copying/moving/arraying/layer changing operations.

My, my. A room full of mathematicians and no one has thought to do a simple conversion of the polynomial x^4 + y^4 = 1 into Bezier form and directly enter the coefficients into Rhino via the Bezier command…? Tsk, tsk.

“It takes an engineer to build a village.”

1 Like

That makes me feel even more stupid now. :rofl:

I found this Squircle GH cluster here several years ago and have used it many times with no problems.

squircle.gh (9.6 KB)