POV-Ray : Newsgroups : povray.binaries.images : Isosurface spiral emulation Server Time
24 Apr 2024 20:17:34 EDT (-0400)
  Isosurface spiral emulation (Message 1 to 4 of 4)  
From: Bald Eagle
Subject: Isosurface spiral emulation
Date: 29 Sep 2017 23:20:02
Message: <web.59cf0d20e6e56be5cafe28e0@news.povray.org>
#version 3.7;
//------------------------------------------
// SDL for emulating the plotting of an isosurface based on a POV-Ray internal
function
// Bill Walker - September 2017
//------------------------------------------
global_settings {assumed_gamma 1}
#include "colors.inc"

light_source { <-1,8,2> color White}

camera {
 location <0, 10, -10>
 look_at  <0, 0, 0>
}

plane {y, -1 pigment { checker Grey, White }}

/*
isosurface{ function{f_spiral(
   x, // PARAM _X
   y, // PARAM _Y
   z, // PARAM _Z
   6, // PARAM (0) distance between windings,
   0.2, // PARAM (1) thickness,
   15, // PARAM (2) outer diameter of the spiral,
   0, // PARAM (3) not used,
   0, // PARAM (4) not used,
   0.5 // PARAM (5) spiral cross-sectional shape 0-round, 1-square, etc
   )}
   accuracy 0.01
   threshold 0 // default value
   max_gradient 21 // high value = more precision = more render time (ideal
value indicated in "messages")
   contained_by {sphere {<0,0,0>, 15}}
   texture {pigment {Red}}
   }
*/

//sphere {<0,0,0>, 15 pigment {rgbt <0.9, 0, 0, 0.4>}}

#macro F_SPIRAL (X, Y, Z, Spacing, Thickness, Dia, Unused1, Unused2, Shape)
     #declare r = sqrt (X*X + Z*Z); // Cartesian distance from origin to point
in x-z plane

     #if (X = 0 & Z = 0)    // Fudges that first awkward starting point by
nudging x from 0 to Epsilon
          #declare X = 0.000001;
     #end

 #declare Theta = atan2 (Z, X);    // calculates the angle around the y-axis of
the current point
 #declare r = r + Spacing * Theta/tau;   // calculates the radius of the current
point on the spiral surface
 #declare r2 = mod (r, Spacing) - (Spacing/2); // determines what layer of the
winding is being plotted

 //######################################################################################
 //  This whole block just determines how to plot the cross sectional shape of
the spiral
 //  Round, square, or somewhere in between
 #if (Shape = 1)
  #declare r2 = sqrt(r2*r2 + Y*Y);

     #elseif (Shape != 0)
          #declare temp = 2/Switch;
          #declare r2 = pow( (pow(abs(r2), temp) + pow(abs(Y), temp)), 1/temp);

     #else
          #declare r2 = max (abs(r2), abs(Y));
          #declare r = sqrt(X*X + Y*Y + Z*Z);

 #end
 //######################################################################################
     #declare VALUE = -min( Dia - r, Thickness - min(r2, r) );

     #declare D1 = sqrt(X*X + Y*Y + Z*Z);
     #declare D2 = sqrt(X*X + Y*Y + Z*Z + VALUE*VALUE);

     #if (abs (D1 - D2) < STEP)
      //If the value is close'nough (TM) [less than the granularity of my plot
(STEP)], plot a sphere
      sphere {<0, 0, 0>, 0.03 translate <X, Y, Z> rotate y*Theta}
     #end

#end // end macro F_SPIRAL

#declare _Spacing = 3;
#declare _Thickness = 0.1;
#declare _Dia = 4;
#declare _Unused1 = 1;
#declare _Unused2 = 0;
#declare _Shape = 1;

#declare STEP = 0.05;

union {
 #for (Y, -_Thickness, _Thickness, STEP)
  #for (X, -_Dia, _Dia, STEP)
   #for (Z, -_Dia, _Dia, STEP)
    // for every <X, Y, Z> point, return a value of the isosurface function
    F_SPIRAL (X, Y, Z, _Spacing, _Thickness, _Dia, _Unused1, _Unused2, _Shape)
   #end
  #end
 #end
 texture {pigment {rgb <0, 0, 0.5>} finish {specular 0.4} }
 no_shadow
}


Post a reply to this message


Attachments:
Download 'emulated_spiral_0.png' (245 KB)

Preview of image 'emulated_spiral_0.png'
emulated_spiral_0.png


 

From: Bald Eagle
Subject: Re: Isosurface spiral emulation
Date: 29 Sep 2017 23:30:00
Message: <web.59cf0efcbb0a68ac5cafe28e0@news.povray.org>
Square cross-section:



(Yes, clearly something's gone all wonky, but this super quick-n-dirty code
gives a fast insight into why that "sphere" is there.)

The real isosurface still shows a sphere at the origin, and so it seems to be an
inherent characteristic of this internal function - there is no "sphere".

That sounds all Matrixy....


Post a reply to this message


Attachments:
Download 'emulated_spiral_1.png' (259 KB)

Preview of image 'emulated_spiral_1.png'
emulated_spiral_1.png


 

From: omniverse
Subject: Re: Isosurface spiral emulation
Date: 30 Sep 2017 00:40:01
Message: <web.59cf1fe3bb0a68ac9c5d6c810@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:

> (Yes, clearly something's gone all wonky, but this super quick-n-dirty code
> gives a fast insight into why that "sphere" is there.)
>
> The real isosurface still shows a sphere at the origin, and so it seems to be an
> inherent characteristic of this internal function - there is no "sphere".
>
> That sounds all Matrixy....

Great to see the SDL! Way beyond me. I was getting nowhere with it, only plotted
points (spheres) along a line.

I was convinced it must be the line (my SDL):

#declare r2 = mod(r, PARAM0) - PARAM0 * 0.5;

All because the 0.5 is what changed the sphere diameter I was using to try
plotting out the spiral arms.

In yours I see you replaced that with /2, so same thing there.

I needed to replace tau with 2*pi since I'm back to version 3.7.0, and was
Switch meant to be Shape?
That was what I had to change to get a render.

Interesting about the isosurface aspect of it, that hadn't occurred to me. Only
that I figured the function code might be going through another thing to get the
final result.

Turned into something else to play with now that you provided this program code
to SDL conversion.
Gee wouldn't that be something to see, all the internal functions in SDL form!
Talk about some work! So I'm not asking.

Bob


Post a reply to this message

From: Bald Eagle
Subject: Re: Isosurface spiral emulation
Date: 2 Oct 2017 21:05:00
Message: <web.59d2e19ebb0a68ac5cafe28e0@news.povray.org>
"omniverse" <omn### [at] charternet> wrote:

> Turned into something else to play with now that you provided this program code
> to SDL conversion.
> Gee wouldn't that be something to see, all the internal functions in SDL form!
> Talk about some work! So I'm not asking.

Oh, I suppose a few of those could be worked out here and there by special
request  ;)

I posted code for a user-defined function over in the other thread:
http://news.povray.org/povray.newusers/message/%3Cweb.59d2dffc808cf4025cafe28e0%40news.povray.org%3E/#%3Cweb.59d2dffc80
8cf4025cafe28e0%40news.povray.org%3E

Here's the output for a plain-vanilla 5-arm spiral.
That ought to be a good start, and illustrate why that sphere might be there.

I'll see if I can re-think my approach and rewrite my code to plot the internal
function as a user-defined isosurface, and then it can be experimented with
"natively".  Which is what I probably ought to have done initially, but
sometimes I have to do some wheel-reinventing along the way.


Post a reply to this message


Attachments:
Download 'newspiral.png' (188 KB)

Preview of image 'newspiral.png'
newspiral.png


 

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.