Thank you, Mark. That was exactly the answer I was looking for! Roger
> On Nov 3, 2021, at 12:29 AM, Mark Waddingham via use-livecode > <use-livecode@lists.runrev.com> wrote: > > Hi Roger, > > On 2021-11-02 22:27, Roger Guay via use-livecode wrote: >> Dear List, >> Bernd has produced an absolutely beautiful animation using a >> Lemniskate polygon that was previously provided by Hermann Hoch. Can >> anyone provide some help on how to create this polygon mathematically? >> Since the equation for a Lemniskate involves the SqRt of negative >> numbers, which is not allowed in LC, I am stumped. >> You can find Bernd’s animation here: >> https://forums.livecode.com/viewtopic.php?f=10&t=36412 >> <https://forums.livecode.com/viewtopic.php?f=10&t=36412> > > In general lemniscates are defined as the roots of a specific kind of quartic > (power four) polynomials of the pattern: > > (x^2 + y^2)^2 - cx^2 - dy^2 = 0 > > So the algorithms for solving them you are probably finding are more general > 'quartic polynomial' solvers - just like solving quadratic equations, the > full set of solutions can only be computed if you flip into the complex plane > (i.e. where sqrt(-1) exists) rather than the real plane. > > However, there is at least one type of Lemniscate for which there is a nice > parametric form - Bernoulli's lemniscate, which is a slightly simpler > equation: > > (x^2 + y^2)^2 - 2a^2(x^2 - y^2) = 0 > > According to https://mathworld.wolfram.com/Lemniscate.html, this can be > parameterized as: > > x = (a * cos(t)) / (1 + sin(t)^2) > > y = (a * sin(t) * cos(t)) / (1 + sin(t)^2) > > Its not clear what the range of t is from the article, but I suspect it will > be -pi <= t <= pi (or any 2*pi length range). > > So a simple repeat loop where N is the number of steps you want to take, and > A is the 'scale' of the lemniscate should give you the points you want: > > repeat with t = -pi to pi step (2*pi / N) > put A * cos(t) / (1 + sin(t)^2) into X > put A * sin(t) * cos(t) / (1 + sin(t)^2) into Y > put X, Y & return after POINTS > end repeat > > Warmest Regards, > > Mark. > > -- > Mark Waddingham ~ m...@livecode.com ~ http://www.livecode.com/ > LiveCode: Everyone can create apps > > _______________________________________________ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode