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)
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.
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.
@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.
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)
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.
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.
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.