What Bezier command?
What would that âsimple conversionâ be? Or are you only assuming such a simple conversion exists?
The function implicitly defined by a polynomial equation is generally not a polynomial function.
Sorry, I should have said âvia the Curve command using an appropriate degree setting to produce a BĂ©zier curve instead of a B-spline curve.â I think of it as the BĂ©zier command.
Iâm not a mathematician so I might be assuming as you suggest, but it seems to me that the equation x^4 + y^4 = 1 is a Pythagorean polynomial in x^2 and y^2 which should map as a circle on log-log paper. A change of variables and a bit of rearranging ought to make at least a quadrant of it amenable to parametrization via Sederbergâs change of basis algorithm given on page 42 here:
https://scholarsarchive.byu.edu/cgi/viewcontent.cgi?article=1000&context=facpub#page58
If a cubic Bézier curve can approximate a quarter circle to essentially exact tolerance (ibid., pp. 34), surely the coefficients of a quintic Bézier curve could be found by algebraic means to yield a nearly exact quadrant of a squircle, since a quintic can span both the cubic needed for the quarter circle and the exponents needed to rectify the log-log paper, no?
You tell me, Iâm just an amateur in these parts and likely naĂŻve, but I didnât see any effort at all in the direction of a direct mathematical analysis of the problem or calculation of coefficients or weights, only eyeball approximations by (apparently) manual iteration.
Pascalâs attempt using a degree-4 curve seemed âcloseâ and the symmetry about the apex makes it tractable to manual iteration, but I believe a degree-5 curve is the minimum necessary to suffice for accuracy without all the curvature squiggles bound to appear in a degree-3 NURBS interpolation of n points as results from Python or GH point-generation and spline-interpolation approximation codes.
Chuckâs comment regarding the weights he used in his test command seem to imply that thereâs an algebraic solution lurking behind his code (I havenât looked at the code) which might imply that Iâm not the only one thinking along these lines.
Again, this isnât my area of expertise but it appears to me that the groundwork is in place for a diligent mathematician to be able to derive a rational degree-5 (or higher?) prototype for a quadrant of a squircle from the implicit polynomial given. A pure BĂ©zier representation of a quadrant of a squircle would surely be within the capabilities of Rhino to generate and display, superior to spline interpolations of points.
Perhaps just my amateur perspective outlined here could be enough to point the way forward for someone to use code to iterate to the ideal rational degree-5 (or higher?) coefficients and weights, but Iâd much rather see a mathematician approach the problem analytically and say, âyes, thatâs the way,â or, âno, it doesnât work that way, junior.â I didnât see either.
A non-linear change of variables/mapping is different than a change of basis functions.
The exact representation of a circular arc is a rational Bezier function, which is the ratio of two polynomial Bezier functions. The rational aspect is what causes the complications. It introduces non-linearity.
An incorrect assumption.
But if someone believes otherwise then a basic knowledge of algebra would be sufficient to be the âdiligent mathematicianâ who obtains the solution. No calculus or similar is needed.
I donât see anything in Sederbergâs basic exposition of Bezier curves that applies here. As David Cockey said, itâs not that simple. The only reasonable thing to do is look for the best approximation wrt location, curvature, and simplicity.
Given that Pascalâs solution was close enough to a true squircle to be indistinguishable by eye, the OPâs need has been met anyway.
There is no imperative for another solution, other than the intellectual stimulus our subsequent discussions bring. Anyone for a superformula (qv) exploration (ideally in a separate thread)?
well⊠one idea which might be more interesting than accurate whatever the definition of accuracy would mean since a squircle to my understanding is nothing more than an interpretation⊠would be the command smooth. if you rebuild a square into 60 points for instance as a basis for smooth you can get something pretty even. then change degree to 4 and well you decide.
Take a look at âNURBs in Structured Grid Generationâ, section 30.3.5.
Same reference as previously posted in Need advice to sketch squircle - #12 by jeremy5
It provides an approximate, not exact representation of a superellipse.
Pascalâs method (degree-4 with equal weights on all control points) yields a best-fit when the intermediate control point is located at 62.73%, but the mean error is 0.464%. However, it gives the advantage of a smooth curvature graph and the curvature goes monotonically to zero at the endpoints of the curve. Mirroring that curve will yield curvature continuity at the joins, but the rate of change of curvature (flow) at the joins may leave a visual artifact.
A rational degree-4 approach using the intermediate control point located at 62% and having a weight of 1.55 and setting the weight of the control point at the âcornerâ to 1.1 reduces the deviation from the âsquircleâ to 0.094%. This is appealing because of the fidelity to the objective but requires setting control point weights. Also, as a degree-4 curve, it still has no control of the flow at the endpoints.
A degree-5 non-rational curve (all control points having the same weight) was developed but did not improve on the accuracy of the degree-4 curves and did not offer a very good curvature graph, so was abandoned.
A degree-6 solution was found that is non-rational and has easy-to-remember control point locations. The mean error of this curve to the âsquircleâ to less than 0.011%. Further, it has a smooth curvature graph that offers not just curvature of zero at the endpoints but also curvature that goes asymptotically to zero â flow goes to zero at the endpoints. Here are itâs coordinates: (1,0), (1,0.37), (1,0.64), (1,1), (0.64,1), (0.37,1), (0,1). Easy-peasy.
In the attached image Iâve run CrvDeviation to compare this degree-6 curve with the 2000-point spline curve offered in another comment above, but the accuracy cited here is based on a least-squares comparison to the implicit polynomial from Wikipedia. The maximum deviation from that polynomial is 0.0125%. Of course, put this in a button script and make squircles all day â itâs a NURBS curve so can be scaled, etc.
Hi David,
Might you explain how? That would be most interesting.
Regards
Jeremy
Least squares minimization on a two DOF function.