I say that the only points that are on the midpoint of the line between
the closest points on the circle and square are the four points of
intersection of the circle and square (and maybe the center of the
circle, depending on which points you pick).
Henry Rich
On 8/15/2022 6:54 AM, Elijah Stone wrote:
Was about to go to bed, but this tickled my imagination, so I will say
a little something.
Rather than calculus, I would do this as an implicit curve.
Start off with the signed distance function of a circle:
sdc=. ]: -~ +/&.:*:
Then that of a box, taken from
https://iquilezles.org/articles/distfunctions2d/:
sdb=. (+/&.:*:@:(0&>.) + 0 <. >./)@:(]: -~ |)
Both of these are adverbs, taking a radius as an operand and then a
vector coordinate as an argument. (The latter can also be given a
vector, in which case it calculates the distance to an n-dimensional
rectangle, but that is irrelevant here.)
Then, we are looking for the case when the distance to the box is
equal to the distance to the circle. Such points will be inside the
square, but outside the circle, so the distance functions of those
shapes will have opposite sign, and we can just add them together:
sdsquircle=. 1 sdc + 1 sdb
sdsquircle is not, strictly speaking, a signed distance function.
However, like a signed distance function, it has a value of 0 when
applied to a coordinate on the squircle; and it is negative inside,
and positive outside. So it is trivial to render the shape from it.
I can expand further on this tomorrow, but I really must be getting to
bed now.
-E
On Mon, 15 Aug 2022, Richard Donovan wrote:
Hi
I want to construct and plot a Squircle in J.
There is a lengthy article in Wikipedia but in simple language I want
my Squircle to be defined as the continuous line between a unit
circle and the unit square that encloses it such that every point on
the Squircle is the mean of the nearest points of the circle and the
square.
Thus, the mean is zero at the four points where the circle and the
square touch, and a maximum of (-: @ <: @ %:2) at the four corners
of the square.
Each intermediate point between 0 degrees and 90 degrees will be
somewhere in the middle.
I suspect the calculation of the intermediate points is a calculus
function?
Has anyone a good idea for performing that calculation? Could the J
function “ plot “ then draw the Squircle?
Thanks
Richard Donovan
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
--
This email has been checked for viruses by AVG antivirus software.
www.avg.com
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm