Follow

Implemented a double helix #DistanceEstimate based on an idea from #FragM's `Knot.frag` (not knighty's, the other one, based on forum posts by DarkBeam).

Not sure how to #fractal-ize it, wanted to turn it into a #helix of helices of helices etc. Nor how to make it a single helix (I only managed to colour the two halves individually...).

I think each strand is an Archimedean Serpentine, but I'm not 100% sure on terminology..

```

#version 330 compatibility

#define providesColor

#include "MathUtils.frag"

#include "Complex.frag"

#include "DE-Raytracer.frag"

#group Helix

uniform float HelixD; slider[0.0,2.0,10.0]

uniform float HelixR; slider[0.0,1.0,10.0]

uniform float Helixr; slider[0.0,0.5,10.0]

uniform float time;

float DE(vec3 q)

{

q.z += HelixD * time;

float t = (mod(q.z / HelixD + 0.5, 1.0) - 0.5) * 2.0 * PI;

q.xy *= mat2(cos(t), sin(t), -sin(t), cos(t));

q.z = 0;

float s = atan(HelixD / (2.0 * PI), HelixR);

q.yz *= mat2(cos(s), -sin(s), sin(s), cos(s));

return length(vec2(length(q.xy) - HelixR, q.z)) - Helixr;

}

vec3 baseColor(vec3 q, vec3 n)

{

q.z += HelixD * time;

float t = (mod(q.z / HelixD + 0.5, 1.0) - 0.5) * 2.0 * PI;

q.xy *= mat2(cos(t), sin(t), -sin(t), cos(t));

return vec3(0.5) + 0.5 * sign(q.x) * n;

}

```

Just realized I made a mistake in my realization that happens to result in ok images when the rise per revolution is small. Correcting: the line is perpendicular to the tangent of the curve which is not parallel to the axis when the curve is "tilted" as in a helix...

Managed to fractalize a variant based on a sheared stack of toruses (such that the ends join up into a helix). Still has assumptions about the rise per revolution being small, but it turned out well. Rendered with "Raymond", my physically-inspired raytracer, using a material similar to water but more extreme in both index of refraction and absorption coefficients.

Render at 3840x2160 with 256 subframes took about 1.5 hours. Exported from FragM in EXR format, colour balance adjusted in Darktable, cropped/framed in GNU IMP.

Show thread

claude@mathr@post.lurk.orgFigured out the single helix version, by realizing that the line through a point to the nearest point on the surface must lie on a plane containing the axis of the helix. There are three candidate points, conceptualized as the two neighbouring arcs above and below, and the arc opposite:

```

#version 330 compatibility

#define providesColor

#include "MathUtils.frag"

#include "Complex.frag"

#include "DE-Raytracer.frag"

#group Helix

uniform float HelixD; slider[0.0,2.0,10.0]

uniform float HelixR; slider[0.0,1.0,10.0]

uniform float Helixr; slider[0.0,0.5,10.0]

uniform float time;

float DE(vec3 q)

{

q.z += time * 2.0 * PI * HelixD;

float dz = mod(q.z + HelixD * atan(q.y, q.x) + PI * HelixD, 2.0 * PI * HelixD) - PI * HelixD;

float xy = length(q.xy);

float d1 = length(vec2(xy - HelixR, dz - PI * HelixD));

float d2 = length(vec2(xy + HelixR, dz));

float d3 = length(vec2(xy - HelixR, dz + PI * HelixD));

return min(min(d1, d2), d3) - Helixr;

}

vec3 baseColor(vec3 q, vec3 n)

{

return vec3(0.5) + 0.5 * cross(n, normalize(vec3(-1.0, 1.0, -1.0)));

}

```