Sujet : Alien Code...
De : chris.m.thomasson.1 (at) *nospam* gmail.com (Chris M. Thomasson)
Groupes : sci.mathDate : 21. Aug 2024, 07:17:50
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <va40qf$3ov1e$1@dont-email.me>
User-Agent : Mozilla Thunderbird
Here is some older code of mine that I call "Alien Code". It's pretty interesting. Here is an animation of it:
https://youtu.be/4VrMT18Rr84Here is a fresh render along with some of my example code:
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);
}
}
}
}
__________________