|
|
Below is the source code for the image that I posted
to povray.binaries.images 28. Dec. 2001. (My PC's month
setting was wrongly set to November, so that message
may appear to be posted in that month.)
Here's links to that thread:
news://news.povray.org/3C04C246.6EF2A5AB%40hotmail.com
http://news.povray.org/povray.binaries.images/20965/
Tor Olav
P.S.:
The code also contains settings for several other
"Sphere Spirals" images.
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Copyright 2001 by Tor Olav Kristensen
// Email: tor### [at] hotmailcom
// http://www.crosswinds.net/~tok
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
#version 3.5; // Beta
#include "colors.inc"
#include "functions.inc"
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
#macro SphereSpiralsFunction(Rmaj, Rmin, PhiFn, NrOfBands, GapRatio)
#local DivAngle = 2*pi/NrOfBands;
#local GapAngle = DivAngle*GapRatio;
/*
#local CosAlpaFn =
function { x/sqrt(x^2 + z^2) }
#local SinAlpaFn =
function { z/sqrt(x^2 + z^2) }
*/
#local CosBetaFn =
function { sqrt(x^2 + z^2)/sqrt(x^2 + y^2 + z^2) }
#local SinBetaFn =
function { y/sqrt(x^2 + y^2 + z^2) }
#local AngleFn = function { atan2(z, x) }
#local AdjAngleFn = function(a) { a + select(a, 2*pi, 0) }
#local ModAngleFn =
function {
mod(AdjAngleFn(AngleFn(x, y, z) - PhiFn(x, y, z)), DivAngle)
}
#local Angle0Fn =
function { AngleFn(x, y, z) - ModAngleFn(x, y, z) }
#local Angle2Fn = function { Angle0Fn(x, y, z) + GapAngle }
function {
select(
ModAngleFn(x, y, z) - GapAngle,
select(
ModAngleFn(x, y, z) - GapAngle/2,
f_sphere(
x - Rmaj*CosBetaFn(x, y, z)*cos(Angle0Fn(x, y, z)),
y - Rmaj*SinBetaFn(x, y, z),
z - Rmaj*CosBetaFn(x, y, z)*sin(Angle0Fn(x, y, z)),
Rmin
),
f_sphere(
x - Rmaj*CosBetaFn(x, y, z)*cos(Angle2Fn(x, y, z)),
y - Rmaj*SinBetaFn(x, y, z),
z - Rmaj*CosBetaFn(x, y, z)*sin(Angle2Fn(x, y, z)),
Rmin
)
),
abs(f_sphere(x, y, z, Rmaj)) - Rmin
)
}
#end // macro SphereSpiralsFunction
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Set up different functions to control the twisting of the bands.
// Then call the macro above with these functions as parameters and
// different settings for the number of bands and the ratio between
// the gaps and the bands.
#declare Rmajor = 3.0;
#declare Rminor = 0.2;
// Decrease Rminor above to e.g. 0.02 to see clearer the effect of
// the GapRatio parameter.
#declare PhiFns =
array[6] {
function { 0 },
function { y/Rmajor*pi },
function { exp(y/3) },
function { y/4 + f_noise3d(0, y, 0) },
function { y/2 - f_noise3d(x, y, z) }
function {
1 - 2*
f_noise3d(
Rmajor*x/f_sphere(x, y, z, 0),
Rmajor*y/f_sphere(x, y, z, 0),
Rmajor*z/f_sphere(x, y, z, 0)
)
}
}
#declare SphereSpiralsFns = array[6]
#declare SphereSpiralsFns[0] =
SphereSpiralsFunction(
Rmajor, Rminor, function { PhiFns[0](x, y, z) }, 8, 2/3
)
#declare SphereSpiralsFns[1] =
SphereSpiralsFunction(
Rmajor, Rminor, function { PhiFns[1](x, y, z) }, 20, 2/3
)
#declare SphereSpiralsFns[2] =
SphereSpiralsFunction(
Rmajor, Rminor, function { PhiFns[2](x, y, z) }, 6, 2/3
)
#declare SphereSpiralsFns[3] =
SphereSpiralsFunction(
Rmajor, Rminor, function { PhiFns[3](x, y, z) }, 12, 3/4
)
#declare SphereSpiralsFns[4] =
SphereSpiralsFunction(
Rmajor, Rminor, function { PhiFns[4](x, y, z) }, 20, 3/5
)
#declare SphereSpiralsFns[5] =
SphereSpiralsFunction(
Rmajor, Rminor, function { PhiFns[5](x, y, z) }, 20, 1/2
)
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Define the iso-surface and texture it.
#declare FnChoice = 2; // Also try the other values; from 0 to 5
#declare SphereRemainsIso =
isosurface {
function { SphereSpiralsFns[FnChoice](x, y, z) }
// max_gradient 10
contained_by { sphere { <0, 0, 0>, Rmajor + Rminor } }
}
object {
SphereRemainsIso
texture {
pigment { color Blue + White }
finish {
ambient 0
diffuse 1
specular 1
roughness 0.02
brilliance 2
}
}
}
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
background { color (Blue + Cyan)/4 }
light_source {
<-2, 3, -2>*100 // *0
color White
shadowless
}
camera {
location <-9, 0, -5>
look_at <0, 0, 0>
}
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
/*
// For the curious:
// Try to replace the function returned in the SphereSpiralsFunction
// macro with this code and then render with FnChoice set to 0.
#local Angle1Fn =
function {
Angle0Fn(x, y, z) +
select(ModAngleFn(x, y, z) - DivAngle/2, 0, DivAngle)
}
function {
min(
f_sphere(
x - Rmaj*CosBetaFn(x, y, z)*cos(Angle1Fn(x, y, z)),
y - Rmaj*SinBetaFn(x, y, z),
z - Rmaj*CosBetaFn(x, y, z)*sin(Angle1Fn(x, y, z)),
Rmin
),
f_sphere(
x - Rmaj*CosBetaFn(x, y, z)*cos(Angle2Fn(x, y, z)),
y - Rmaj*SinBetaFn(x, y, z),
z - Rmaj*CosBetaFn(x, y, z)*sin(Angle2Fn(x, y, z)),
Rmin
)
)
}
*/
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
Post a reply to this message
|
|
|
|
// Here's the code for my variant on the 'peel' sphere ...
// peel.pov by Mike Andrews 2002-01-03
#include "functions.inc"
// +w320 +h240 +a0.3 +fn
global_settings {
max_trace_level 20
assumed_gamma 1
ambient_light 1
#if (0)
radiosity {
pretrace_start 16/image_width
pretrace_end 4/image_width
count 50
nearest_count 6
error_bound 0.25
recursion_limit 1
low_error_factor .2
gray_threshold 0.0
minimum_reuse 0.01
brightness 1
adc_bailout 0.01/2
}
#end
}
#declare BC = <7/4,7/5.5,1>^(-4);
sky_sphere {
pigment {
gradient y
colour_map {[0 color rgb 0.5*(1+BC)][1 rgb 0.5*BC]}
}
}
fog {
fog_type 2
colour rgb BC*0.3
distance 100
fog_alt 6
fog_offset -7
}
fog {
fog_type 2
colour rgb (1-BC)*0.5
distance 500
fog_alt 15
fog_offset -7
}
camera {
up y
right x*image_width/image_height
direction 3.5*z
location <-1,1.5,-10>
look_at 0
}
light_source {
0*x
color rgb 1-0.1*BC
translate 50*vnormalize(<1,2,-2>)
scale 400
}
#declare fn_Rad = function {
(1-5*abs(f_r(x,y,z)-1))
* abs(sin(2*f_th(x,y,z)+3*(f_ph(x,y,z)-pi/2)*(1+abs(f_r(x,0,z)-1))))
}
#declare fn_Peel = function {
((0.6-fn_Rad(x,y,z)) + 0.2*max(0, min(1, 1-f_r(x,0,z))))
* max(0, min(1, f_r(x,0,z)))
- 0.01*(1-100*abs(f_r(x,y,z)-1))
}
isosurface {
function { fn_Peel(x, y, z) }
max_gradient 6
accuracy 0.00002
contained_by { sphere { 0, 1.3 } }
pigment { spherical colour_map {[0 rgb 1][0.001 rgb x]} }
rotate -30*x
}
Post a reply to this message
|
|