Discussion:
Alien Code...
(too old to reply)
Chris M. Thomasson
2024-08-21 06:17:50 UTC
Permalink
Here is some older code of mine that I call "Alien Code". It's pretty
interesting. Here is an animation of it:



Here is a fresh render along with some of my example code:

Loading Image...

_________________
namespace ct_alien_code
{
void
iterate_0(
ct::plot::cairo::plot_2d& scene,
unsigned long ri,
unsigned long rn,
glm::vec2 origin,
unsigned long n
) {
if (ri > rn) return;

float angle_start = 1.f / (n - 1.f) * CT_PI2;

glm::vec2 pt = { 1, 0 };

glm::vec2 ptx = {
(glm::cos(angle_start) + glm::floor(glm::sin(angle_start))
* 2.f + 1.f) * .5f,
glm::sin(angle_start) * .5f
};

glm::vec2 dif = ptx - pt;

float dis = abs(dif.x * dif.x + dif.y * dif.y);

for (unsigned long i = 0; i < n; ++i)
{
float ir = i / (n - 1.f);
float angle = CT_PI2 * ir;

glm::vec2 np = {
(glm::cos(angle) + glm::floor(glm::sin(angle)) * 2.f +
1.f) * .5f,
(glm::sin(angle)) * .5f
};

np += origin;

glm::vec2 dif_np = np - ptx;

float ddd = glm::abs(dif_np.x * dif_np.x + dif_np.y *
dif_np.y);

if (ddd <= dis && i > 1)
{
glm::vec2 offset = { 1, -1 };

scene.line(ptx, np, CT_RGBF(1, 0, 0));
scene.line(-ptx, -np, CT_RGBF(1, 1, 0));
}

{
iterate_0(scene, ri + 1, rn, np, n);
}

ptx = np;
}
}

void
manifest(
ct::plot::cairo::plot_2d& scene
) {
std::cout << "ct_alien_code::manifest()\n\n";

{
{
iterate_0(scene, 0, 1, { 0, 0 }, 100);
}
}
}
}
__________________
Chris M. Thomasson
2024-08-21 06:19:23 UTC
Permalink
On 8/20/2024 11:17 PM, Chris M. Thomasson wrote:

I forgot to include comp.lang.c++. DAMN!!!
Post by Chris M. Thomasson
Here is some older code of mine that I call "Alien Code". It's pretty
http://youtu.be/4VrMT18Rr84
https://i.ibb.co/bWqrLhj/ct-p2.png
_________________
namespace ct_alien_code
{
    void
    iterate_0(
        ct::plot::cairo::plot_2d& scene,
        unsigned long ri,
        unsigned long rn,
        glm::vec2 origin,
        unsigned long n
    ) {
        if (ri > rn) return;
        float angle_start = 1.f / (n - 1.f) * CT_PI2;
        glm::vec2 pt = { 1, 0 };
        glm::vec2 ptx = {
            (glm::cos(angle_start) + glm::floor(glm::sin(angle_start))
* 2.f + 1.f) * .5f,
            glm::sin(angle_start) * .5f
        };
        glm::vec2 dif = ptx - pt;
        float dis = abs(dif.x * dif.x + dif.y * dif.y);
        for (unsigned long i = 0; i < n; ++i)
        {
            float ir = i / (n - 1.f);
            float angle = CT_PI2 * ir;
            glm::vec2 np = {
                (glm::cos(angle) + glm::floor(glm::sin(angle)) * 2.f +
1.f) * .5f,
                (glm::sin(angle)) * .5f
            };
            np += origin;
            glm::vec2 dif_np = np - ptx;
            float ddd = glm::abs(dif_np.x * dif_np.x + dif_np.y *
dif_np.y);
            if (ddd <= dis && i > 1)
            {
                glm::vec2 offset = { 1, -1 };
                scene.line(ptx, np, CT_RGBF(1, 0, 0));
                scene.line(-ptx, -np, CT_RGBF(1, 1, 0));
            }
            {
                iterate_0(scene, ri + 1, rn, np, n);
            }
            ptx = np;
        }
    }
    void
    manifest(
        ct::plot::cairo::plot_2d& scene
    ) {
        std::cout << "ct_alien_code::manifest()\n\n";
        {
            {
                iterate_0(scene, 0, 1, { 0, 0 }, 100);
            }
        }
    }
}
__________________
Loading...