# Lemniscate Polygon

Wed Nov 3 03:29:30 EDT 2021

```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 ~ mark at livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps

```
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}