sql 在SQL中绘制Mandelbrot集

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql 在SQL中绘制Mandelbrot集相关的知识,希望对你有一定的参考价值。

-- I have no idea where this came from :( A work colleage showed me it.

WITH RECURSIVE
x(i)
AS (
    VALUES(0)
UNION ALL
    SELECT i + 1 FROM x WHERE i < 101
),
Z(Ix, Iy, Cx, Cy, X, Y, I)
AS (
    SELECT Ix, Iy, X::FLOAT, Y::FLOAT, X::FLOAT, Y::FLOAT, 0
    FROM
        (SELECT -2.2 + 0.031 * i, i FROM x) AS xgen(x,ix)
    CROSS JOIN
        (SELECT -1.5 + 0.031 * i, i FROM x) AS ygen(y,iy)
    UNION ALL
    SELECT Ix, Iy, Cx, Cy, X * X - Y * Y + Cx AS X, Y * X * 2 + Cy, I + 1
    FROM Z
    WHERE X * X + Y * Y < 16.0
    AND I < 27
),
Zt (Ix, Iy, I) AS (
    SELECT Ix, Iy, MAX(I) AS I
    FROM Z
    GROUP BY Iy, Ix
    ORDER BY Iy, Ix
)
SELECT array_to_string(
    array_agg(
        SUBSTRING(
            ' .,,,-----++++%%%%@@@@#### ',
            GREATEST(I,1),
            1
        )
    ),''
)
FROM Zt
GROUP BY Iy
ORDER BY Iy;

以上是关于sql 在SQL中绘制Mandelbrot集的主要内容,如果未能解决你的问题,请参考以下文章

让 C# mandelbrot 绘图更高效

改进我的 Mandelbrot 集代码

将颜色层添加到 mandelbrot 集

Mandelbrot 集函数未按预期执行

[原创+分享]Mandelbrot Explorer

在数据库中存储 Mandelbrot 值的最佳方法可能是啥?