POV-Ray : Newsgroups : povray.text.scene-files : Source code for "Iso-Swirl" : Source code for "Iso-Swirl" Server Time
25 Apr 2024 22:54:38 EDT (-0400)
  Source code for "Iso-Swirl"  
From: Tor Olav Kristensen
Date: 19 Nov 2000 10:53:01
Message: <3A17F6F9.EF92E87E@online.no>
Yesterday I posted an iso-surface image to povray.binaries.images:

news://news.povray.org/3A16FA1C.5C3F456E%40hotmail.com

I'm not sure if the light settings, colours and "texture" are exactly
the same as in the posted image.

MegaPOV is required for this.

Tor Olav


// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Copyright 2000 by Tor Olav Kristensen
// mailto:tor### [at] hotmailcom
// http://www.crosswinds.net/~tok/tokrays.html
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#version unofficial MegaPov 0.5;

#include "colors.inc"

global_settings { ambient_light color White*1.5 }

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

$ SwirlRadius  = 2.0;
$ Yspacing     = 0.4;  // Also try 0.1
$ AngleSpacing = pi/8; // Also try pi/32 
$ WaveRadius   = 0.5;  // Also try 0.0
$ SphereRadius = 0.2;  // Also try 0.6

// Combinations of the alternative values are also interesting.
// It may be useful to comment out the noise3d line in the iso-surface
// statement below while experimenting with the values above.

$ HalfBoundingBoxSide = SwirlRadius + WaveRadius + SphereRadius;

$ SphereFunction =
function { sqrt(x^2 + y^2 + z^2) }

$ AngleFunction = 
function { if(-z, -1, 1)*acos(x/sqrt(x^2 + z^2)) + if(-z, 2*pi, 0) }

$ YFunction =
function { y % Yspacing + if(y, -1, 1)*Yspacing/2 }
           
$ YadjAngleFunction =
function { AngleFunction(x, y, z) + YFunction(x, y, z) }

/* // Also try
$ AngleSkew = pi/7;

$ YadjAngleFunction =
function {
  AngleFunction(x, y, z) + (y - YFunction(x, y, z))*AngleSkew
}
*/

$ StepAngleFunction =
function { 
  AngleFunction(x, y, z) - 
  (YadjAngleFunction(x, y, z) % AngleSpacing - AngleSpacing/2)
}

$ TrigFunction = 
function { WaveRadius*sin(3*y) }

/* //Also try
$ TrigFunction = 
function { WaveRadius*sin(3*(y - YFunction(x, y, z))) }
*/

$ Swirl =
isosurface {
  function {
   SphereFunction(
     x - (SwirlRadius + TrigFunction(x, y, z))
         *cos(StepAngleFunction(x, y, z)),
     YFunction(x, y, z),
     z - (SwirlRadius + TrigFunction(x, y, z))
         *sin(StepAngleFunction(x, y, z))
   )
   - 0.02*(1 - 2*noise3d(x*100, y*100, z*100))
  }
  threshold SphereRadius
  max_gradient 10 // It may be necessary to increase this
//  accuracy 1E-6
  contained_by {
    box {
      -<HalfBoundingBoxSide, 6, HalfBoundingBoxSide>,
       <HalfBoundingBoxSide, 6, HalfBoundingBoxSide>
    }
  }
  method 2
}

object {
  Swirl
  pigment { color Gray50 }
  no_shadow
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

light_source { 10*<-3, 2, -1> color (White + Blue)*2 }

#declare RR = seed(4);

#declare Cnt = 0;
#while (Cnt < 4)
  light_source {
    10*(<1, 1, 1>/2 - <rand(RR), rand(RR), rand(RR)>)
    color Red
    fade_distance 3
    fade_power 4
  }
  #declare Cnt = Cnt + 1;
#end // while

camera {
  location -8*z
  look_at <0, 0, 0>
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7


Post a reply to this message

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