POV-Ray : Newsgroups : povray.binaries.images : Cornescu spiral : Re: Cornescu spiral Server Time15 Aug 2024 23:52:22 EDT (-0400)
 Re: Cornescu spiral
 From: Bald Eagle Date: 23 Jul 2024 06:40:00 Message:
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#web.669f8804dae111c01f9dae3025979125%40news.povray.org",
"dateCreated": "2024-07-23T10:40:00+00:00",
"datePublished": "2024-07-23T10:40:00+00:00",
"author": {
"@type": "Person",
"name": "Bald Eagle"
}
}
yesbird <sya### [at] gmailcom> wrote:
> On 23/07/2024 04:08, Bald Eagle wrote:
> > I could probably spend a bit more time getting a better formula for the pigment
> > as a function of arc-length . . .
>
> Interesting... And maybe a line width too ?
> Could you share the code ?

Yes, I already have some modulation of the line width so that I have some
differentiation of the inner spiral region.

Also, I read somewhere that the convergence points were +/- sqrt(pi/2)/2
but that doesn't seem to be the case here.
No idea how to compute what the actual coordinates are - that's probably a
Matlab / Mathematica sort of thing to solve the infinite integrals.

Now the cool thing to do with this is start using it to play with some of the
practical applications.   IIRC, some physical phenomena correlate to the curve
by plotting (X^2) against it.

// +d +p +q9 +am3 +a0.1 +ac0.9 +r6

#version 3.8;
global_settings {
assumed_gamma 1.0
}
#default {finish {emission 1}}
#declare E = 0.00001;

camera {
location <0, 0, -1.5>
right x*image_width/image_height
up y
look_at <0, 0, 0>
}

//sky_sphere {pigment {rgb 1}}

light_source {<100, 100, -500> rgb 1}

#declare eps = 1e-15;
#declare xa = function (_X) {abs (_X)}
#declare px = function (_X) {pi * xa (_X)}
#declare  T = function (_X) {0.5 * px (_X) * xa (_X)}
#declare t2 = function (_X) {T(_X) * T(_X)}

#macro FCS (X)
// Computes Fresnel Integrals C(x) and S(x)
// Input: real x Output: C, S function values

// (c) Shanjie Zhang & Jianming Jin
// Computation of Special Functions
// Wiley, 1996
// Modified July 17 2012

// Ported to SDL July 22 2024
// by Bill "Bald Eagle" Walker
#if (xa (X) = 0)
#local c = 0;
#local s = 0;

#elseif (xa (X) < 2.5)
#local r = xa (X);
#local c = r;
#for (k, 1, 50)
#local r = -0.5 * r * (4*k-3)/ k / (2*k-1)/(4*k+1)*t2(X);
#local c = c + r;
#if (abs(r) < abs(c)*eps)
#break // exit for loop
#end
#end // end for
#local s = xa(X) * T(X)/3;
#local r = s;
#for (k, 1, 50)
#local r = -0.5 * r * (4*k-1)/ k / (2*k+1)/(4*k+3)*t2(X);
#local s = s + r;
#if (abs(r) < abs(s)*eps)
#if (X < 0)
#local c = -c;
#local s = -s;
#end
#break // exit macro
#end
#end // end for

#elseif (xa (X) < 4.5)
#local m = int (42 + 1.75*T(X));
#local su = 0;
#local c= 0;
#local s = 0;
#local f1 = 0;
#local f0 = 1e-100;
#for (k, m, 0, -1)
#local f = (2*k+3)*f0/T(X)-f1;
#if (k = int (k/2)*2)
#local c = c+f;
#else
#local s = s+f;
#end
#local su = su + (2*k+1)*f*f;
#local f1 = f0;
#local f0 = f;
#end
#local q = sqrt (su);
#local c = c*xa(X) / q;
#local s = s*xa(X) / q;

#else
#local r = 1;
#local f = 1;
#for (k, 1, 20)
#local r = -0.25*r*(4*k-1)*(4*k-3)/t2(X);
#local f = f + r;
#end
#local r = 1/(px(X)*xa(X));
#local g = r;
#for (k, 1, 12)
#local r = -0.25*r*(4*k+1)*(4*k-1)/t2(X);
#local g = g + r;
#end
#local t0 = T(X) - int (T(X)/tau)*tau;
#local c = 0.5 + (f*sin(t0)-g*cos(t0))/px(X);
#local s = 0.5 - (f*cos(t0)+g*sin(t0))/px(X);
#end

#if (X < 0)
#local c = -c;
#local s = -s;
#end

#local Result = <c, s>;

Result

#end // end macro FCS

//--------------------------------------------------------------------------------------------------

#declare Line = 0.0015;

#local E = 0.000001;
#local Range = 10;
#local Index = 0;
#local Pos =
union {
#for (N, 0, Range, 0.01)
#local Line2 = Line * (1-N/Range);
#local CS = FCS (N);
#local C = CS.x;
#local S = CS.y;
#local Current = <C, S, 0>;
#local Color = <1-N/Range, abs (0.5-N/Range), N/Range>;
sphere {Current Line2 pigment {rgb Color}}
#if (Index > 0)
cylinder {Last, Current, Line2 pigment {rgb Color}}
#end
#local Last = Current;
#local Index = Index+1;
#end
//pigment {rgb y}
}

#local Neg = object {Pos scale -1*<1, 1, 1>}

object {Pos}
object {Neg}
#declare CP = sqrt (pi/2)/2;
#declare ConvergencePoint = <CP, CP, 0>;
//sphere { ConvergencePoint Line*3 pigment {rgb x}}
//sphere {-ConvergencePoint Line*3 pigment {rgb x}}
```