#include "colors.inc"
#include "shapes.inc"
#include "shapes2.inc"
#include "shapesq.inc"
#include "metals.inc"
#include "glass.inc"
#include "stones.inc"

camera { location <0,0,-90> look_at <0,0,0> rotate <0,0,0> translate <0,0,0>}

//background {color rgb <152/255, 251/255, 152/255>*1.5 }
background { color White * 0.5 }

light_source {<100,50,-100> color White*2 shadowless }


union{

//Pseudopetals
#declare petals = 5;
#declare petal = 1;
#while (petal <= petals)
union{
difference{
sphere_sweep{ b_spline 8,
 <0,0,0>, 1.5
 <1.0,0,0>, 2.5
 <2,0,0>, 2.7
 <2.5,0,0>, 2.8
 <3,0,0>, 2.7
 <4,0,0>, 2.4
 <5,0,0>, 1.6
 <6,0,0>, 0.2
 pigment {color White }
 //scale <5,0.5,2>
 }
sphere_sweep{ b_spline 8,
 <0,0,0>, 1.5
 <1.0,0,0>, 2.5
 <2,0,0>, 2.7
 <2.5,0,0>, 2.8
 <3,0,0>, 2.7
 <4,0,0>, 2.4
 <5,0,0>, 1.6
 <6,0,0>, 0.2
 pigment {color White }
 translate <-0.2,0.5,0>
 }        
box { <-2,-3,-3>, <7,3,-0.2> pigment {color White } }
rotate <-5,0,0>
scale <5,0.75,2.5>        
}
difference{
sphere_sweep{ b_spline 8,
 <0,0,0>, 1.5
 <1.0,0,0>, 2.5
 <2,0,0>, 2.7
 <2.5,0,0>, 2.8
 <3,0,0>, 2.7
 <4,0,0>, 2.4
 <5,0,0>, 1.6
 <6,0,0>, 0.2
 pigment {color White }
 //scale <5,0.5,2>
 }

sphere_sweep{ b_spline 8,
 <0,0,0>, 1.5
 <1.0,0,0>, 2.5
 <2,0,0>, 2.7
 <2.5,0,0>, 2.8
 <3,0,0>, 2.7
 <4,0,0>, 2.4
 <5,0,0>, 1.6
 <6,0,0>, 0.2
 pigment {color White }
 translate <-0.2,0.5,0>
 }        
box { <-2,-3,-3>, <7,3,-0.2> pigment {color White } }
rotate <-5,0,0>   
scale <0,0,-1>
scale <5,0.75,2.5>        
}
rotate <0,0,10>
translate <10,0,0>
rotate <0,(360/petals)*petal,0>
//rotate <0,90,0>
rotate <-90,0,0>        
}
#declare petal = petal + 1;
#end

#declare sepals = 5;
#declare sepal = 1;
#while (sepal <= sepals)
union{
difference{
sphere_sweep{ b_spline 11,
 <-1,0,0>, 1.5
 <1.0,0,0>, 2.5
 <2,0,0>, 2.7
 <2.5,0,0>, 2.8
 <3,0,0>, 2.7
 <4,0,0>, 2.4
 <5,0,0>, 1.6
 <6,0.5,0>, 0.2
 <7,0,0>, 0.1
 <7.5,-2,0>, 0.1
 <6,-4,0>, 0.1
 pigment { rgb <152/255, 251/255, 152/255> }
 //scale <5,0.5,2>
 }
sphere_sweep{ b_spline 8,
 <-1,0,0>, 1.5
 <1.0,0,0>, 2.5
 <2,0,0>, 2.7
 <2.5,0,0>, 2.8
 <3,0,0>, 2.7
 <4,0,0>, 2.4
 <5,0,0>, 1.6
 <6,0,0>, 0.2
 pigment {color White }
 translate <-0.2,0.5,0>
 }        
box { <-2,-3,-3>, <7,3,-0.2> pigment {color White } }
rotate <-5,0,0>
scale <5,0.75,2.5>        
}
difference{
sphere_sweep{ b_spline 8,
 <-1,0,0>, 1.5
 <1.0,0,0>, 2.5
 <2,0,0>, 2.7
 <2.5,0,0>, 2.8
 <3,0,0>, 2.7
 <4,0,0>, 2.4
 <5,0,0>, 1.6
 <6,0,0>, 0.2
 pigment { rgb <152/255, 251/255, 152/255> }
 //scale <5,0.5,2>
 }
sphere_sweep{ b_spline 8,
 <-1,0,0>, 1.5
 <1.0,0,0>, 2.5
 <2,0,0>, 2.7
 <2.5,0,0>, 2.8
 <3,0,0>, 2.7
 <4,0,0>, 2.4
 <5,0,0>, 1.6
 <6,0,0>, 0.2
 pigment {color White }
 translate <-0.2,0.5,0>
 }                
box { <-2,-3,-3>, <6.1,3,-0.2> pigment {color White } }
rotate <-5,0,0>
scale <0,0,-1>
scale <5,0.75,2.5>        
}
rotate <0,0,5>
translate <10,-5,0>
rotate <0,((360/sepals)*sepal + 36),0>
//rotate <0,90,0>
rotate <-90,0,0>
translate <0,0,-3>        
}
#declare sepal = sepal + 1;
#end

//Coronal filaments - should be 72
#declare petals = 40;
#declare petal = 1;
#while(petal <= petals)

sphere_sweep{ b_spline 8,
 <0.5,0,0>, 0.25
 <1.0,0.1,0>, 0.23
 <2,0.3,0>, 0.21
 <2.5,0.5,0>, 0.19
 <3,1,0>, 0.17
 <4,1.5,0>, 0.15
 <5,2,0>, 0.13
 <6,3,0>, 0.1
 pigment {
  gradient x       
  color_map {
 [0.04  color Red]
 [0.2  rgb <160/255,82/255,45/255>*0.5 ]
 [0.5  color White]
 [0.8  rgb <123/255,104/255,238/255> ]
  } scale 4.5 translate <0.8,0,0>
 }
 translate <0.5,1-1,0>
 scale <3.5,3,3>
 
 rotate <0,(360/petals)*petal,0>
 rotate <-90,0,0>
 }

#declare petal = petal + 1;
#end

#declare petals = 32;
#declare petal = 1;
#while(petal <= petals)

sphere_sweep{ b_spline 8,
 <0.5,0,0>, 0.25
 <1.0,0.1,0>, 0.23
 <2,0.3,0>, 0.21
 <2.5,0.5,0>, 0.19
 <3,1,0>, 0.17
 <4,1.5,0>, 0.15
 <5,2,0>, 0.13
 <6,3,0>, 0.1
 pigment {
  gradient x       
  color_map {
 [0.04  color Red]
 [0.2  rgb <160/255,82/255,45/255>*0.5 ]
 [0.5  color White]
 [0.8  rgb <123/255,104/255,238/255> ]
  } scale 4.5 translate <0.8,0,0>
 }
 translate <0.5,1.3-1,0>
 scale <3.5,3,3>
 
 rotate <0,0,5>
 rotate <0,(360/petals)*petal+4,0>
 rotate <-90,0,0>
 }

#declare petal = petal + 1;
#end

//Stalk
cylinder { <0,0,20>, <0,0,1>, 2.5 pigment { colour Green } }
//Receptacle
cylinder { <0,0,1>, <0,0,0>, 5 pigment { color White } }//pigment { rgb <240/255,1,240/255>*1.5 } }

#declare nectaries = 60;
#declare nectary = 1;
#while(nectary <= nectaries)

sphere { <0,0,0> 1 scale <0.1,0.1,0.3>*2 pigment { color Black }
translate <4,0,0>
rotate <0,0,(360/nectaries)*nectary>
}

#declare nectary = nectary + 1;
#end

#declare processes = 60;
#declare process = 1;
#while(process <= processes)

sphere_sweep{ b_spline 8,
 <0.80,    0, 0.0>, 0.25
 <0.87,  0, -0.2>, 0.23
 <0.7,  0, -0.4>, 0.21
 <0.6,  0, -0.6>, 0.19
 <0.5,  0, -0.7>, 0.17
 <0.3,  0, -0.8>, 0.15
 <0,    0, -0.9>, 0.13
 <-0.2, 0, -1.0>, 0.1
 pigment {
  gradient x       
  color_map {
 [0.04  rgb <1,228/255,225/255> ]
 [0.5  rgb <160/255,82/255,45/255>*0.5 ]
 //[0.5  color White]
 //[0.8  rgb <123/255,104/255,238/255> ]
  } scale 4.5 translate <0.8,0,0>
 }
 translate <0.8,-0,-5>
 scale <2,3,3>
 
 rotate <0,0,(360/processes)*process>
 translate <0,0,15>
 //rotate <180,0,0>
 }

#declare process = process + 1;
#end

sphere_sweep{ b_spline 5,
 <0,    0.5, 0.0>, 1
 <0,  1, 0.0>, 0.8
 <0,  1.5, 0.0>, 0.75
 <0,  2, 0.0>, 0.7
 <0,  2.5, 0.0>, 0.7
 pigment { rgb <240/255,2,240/255> }
 scale 2
 rotate <-90,0,0>
 }

//Filaments
#declare filaments = 5;
#declare filament = 1;
#while(filament <= filaments)

difference{
sphere_sweep{ b_spline 8,
 <0,    0,   0.0>, 0.25
 <0.2,  0,   0.0>, 0.24
 <0.4,  0,   0.0>, 0.23
 <0.6,  0.1, 0.0>, 0.22
 <1.0,  0.2, 0.0>, 0.22
 <1.4,  0.3, 0.0>, 0.21
 <1.8,  0.4, 0.0>, 0.2
 <2.0,  0.4, 0.0>, 0.2
 pigment { rgb <240/255,2,240/255> }
 translate <0,6.5,0>
 scale <3,1,4>*1
 rotate <-90,0,0>
 rotate <0,0,(360/filaments)*filament>        
}
sphere { <0,0,0>, 0.3 scale <0.6,0.6,2>*2
pigment { rgb <240/255,2,240/255> }
translate <5.7,0,-6.5>
rotate <0,0,(360/filaments)*filament>  
}
}
difference{
sphere { <0,0,0>, 1 scale <1,3,1> translate <6,0,-6>
pigment { rgb <240/255,2,240/255> }
normal { bumps 0.5 scale <1,3,1> }
}
sphere { <0,0,0>, 1 scale <1,3,1> translate <6,0,-6+0.6>
pigment { color Yellow }
}
rotate <0,0,(360/filaments)*filament>
}

#declare filament = filament + 1;
#end

sphere { <0,0,0>, 1 scale <2,2,2.9> translate <0,0,-8.3>
pigment { rgb <240/255,2,240/255> }
}

#declare styles = 3;
#declare style = 1;
#while(style <= styles)

union{
sphere_sweep{ b_spline 8,
 <0.1, 0.0, 0>, 0.2
 <1.0, 0.0, -0.3>, 0.23
 <2.0, 0.0, -0.6>, 0.26
 <2.5, 0.0, -1>, 0.3
 <3.0, 0.0, -1.2>, 0.33
 <4.0, 0.0, -1.5>, 0.35
 <5.0, 0.0, -1.7>, 0.37
 <6.0, 0.0, -2>, 0.45
 translate <-0.8,0,-7>
 scale 1.5
 pigment {
  gradient x
  color_map {
  [ 0.8 rgb <160/255,82/255,45/255>*0.5 ]
  [ 1.0 rgb <240/255,2,240/255> ]
  } scale 6.1 translate <1,0,0>
 }
}
difference{
cylinder { <-0.5,0,0>, <0.5,0,0>, 2 }
cylinder { <-0.5,0,0>, <0.5,0,0>, 1.9 }
box { <-2,-4,4>, <2,4,-1.5> }
pigment { rgb <240/255,2,240/255> }
rotate <0,90,0>
translate <8.8,0,-13>
}

//Stigmas
sphere { <0,0,0>, 1 scale <2,3,2>*0.4 translate <8.0,0.8,-13>
pigment { rgb <240/255,2,240/255> }
}
sphere { <0,0,0>, 1 scale <2,3,2>*0.4 translate <8.0,-0.8,-13>
pigment { rgb <240/255,2,240/255> }
}  

rotate <0,0,(360/styles)*style>
}

#declare style = style + 1;
#end
 
//rotate <55,0,0>
//rotate <90,0,0>
}
Flowers - 3D Computer Models
Passion Flower Computer Model
Passion flower 2
Passion flower 3
This Passion Flower model was made using constructive solid geometry (CSG). Using sphere-sweeps in
POV-Ray. Essentially, the computer calculates the surface formed by tracing the path of a sphere moving
through space (by calculating the mathematical formulae for us). The radius of the sphere can be changed
as it moves through space, to give, for example, a tapering shape. Subtracting (taking the difference of) two
or more sphere_sweeps it is possible to form more complex shapes, such as petals.
Another approach is to use formulae that we explicitly derive ourselves (perhaps by trial-and-error). This
method was used to create the (fictitious) flower shown below, again rendered in Pov-Ray.
Flower model 2
#include "metals.inc"
#include "shapes.inc"
#include "glass.inc"
#include "rand.inc"
#include "stones.inc"
#include "woods.inc"
#include "rand.inc"
#include "math.inc"

camera { location <0,0,-50> look_at <0,0,0> rotate <0,0,0> }  
background {color White*1}

global_settings { ambient_light rgb <1,1,1>*(1.5) }

light_source { <-50,50,-180> color White*2 }

#declare fn_A = function { sqrt(pow(x,2) + pow(y,2)*exp(y/3) + pow(z,2)) -2 }
#declare fn_B = function { sqrt(pow(x,2) + pow(y,2)*exp(y/3) + pow(z,2)) -2 }

union{

//Petals
difference{

union{

#declare valve = 1;
#declare valves = 4;
#while (valve <= valves)

#declare R1 = SRand(1)*0.2;

difference{

isosurface {
function { max( fn_A(x,y,z), - fn_B(1.01*x,1.01*y,1.01*z) ) }
//function { 1.5 - pow(0.5, fn_A(x,y,z)) - pow(0.5, fn_B(1.01*x,1.01*y,1.01*z) ) }
contained_by { box { <0,-5+3,0>, <5,5,5> } }
max_gradient 4
all_intersections //otherwise inside of shell is transparent/invisible!

texture {
radial
texture_map {
[0.3  pigment{ rgbt <238/255,130/255,238/255,0> } finish { ambient 0.5 phong 0.9 phong_size 60 reflection
{0.0} } ]
[0.6  pigment{ rgbt <218/255,112/255,214/255,0.0> } finish { ambient 0.5 phong 0.9 phong_size 60
reflection {0.0} } ]    
[0.7  pigment{ rgbt <238/255,130/255,238/255,0> } finish { ambient 0.5 phong 0.9 phong_size 60 reflection
{0.0} } ]
[0.99  pigment{ rgbt <218/255,112/255,214/255,0.0> } finish { ambient 0.5 phong 0.9 phong_size 60
reflection {0.0} } ]
} frequency 10 rotate<0,-90,0> //turbulence 0.8+R1
}
 
//pigment { rgbt <1,0,0.5,0.3> } finish { ambient 0.5 phong 0.9 phong_size 60  }

//normal { bumps 1 scale <10,1,1> }
//finish { F_MetalC }
//pigment { rgbt <1,0,0.5,0.0> }
//texture { T_Copper_3A  }

scale 7
//scale <6.5,7,7>
}

scale <1,1,0.8>

translate <4,0.2*(valve-1),20> rotate <0,40+25,0> rotate <0,0,120> translate <0,-16,0>

rotate <0,(360/valves)*(valve-1),0> //translate <0,0.1*(valve-1),0>
}

#declare valve = valve + 1;
#end

}

rotate <0,0,0>
rotate <90,0,0>

}

//Sepals

difference{

union{

#declare valve = 1;
#declare valves = 4;
#while (valve <= valves)

#declare R2 = SRand(1)*0.2;

difference{

isosurface {
function { max( fn_A(x,y,z), - fn_B(1.01*x,1.01*y,1.01*z) ) }
contained_by { box { <0,-5,0>, <5,5-6,5> } }
max_gradient 4
all_intersections //otherwise inside of shell is transparent/invisible!

texture {
radial
texture_map {
[0.3  pigment{ rgbt <0.4,1,0.0,0.0> } finish { ambient 0.5 phong 0.9 phong_size 60 } ]
[0.3  pigment{ rgbt <0.4,1,0.0,0.0> } finish { ambient 0.5 phong 0.9 phong_size 60 } ]    
[0.5  pigment{ rgbt <0.5,1,0.0,0.0> } finish { ambient 0.5 phong 0.9 phong_size 60 } ]
[0.9  pigment{ rgbt <0.5,1,0.0,0.0> } finish { ambient 0.5 phong 0.9 phong_size 60 } ]
} frequency 1 turbulence 0.8+R2
}

scale <8,7,8>
}

translate <0,-1,0> rotate <0,45-5,0> rotate <0,0,90+30>

rotate <0,(360/valves)*(valve-1)+45,0> //translate <0,0.1*(valve-1),0>

}

#declare valve = valve + 1;
#end

}

//box { <-10,10,-10>, <10,1.4,10> pigment { rgbt 1 } scale 7 }
scale 1.0 translate <0,1,0>

rotate <0,0,0>
rotate <90,0,0>

}

//Pedicel
cylinder { <0,0,30>, <0,0,0>, 2 pigment { rgbt <0.2,1,0.0,0.0> } finish { F_MetalC } }

//Ovary
union{

isosurface {
function { max( fn_A(x,y,z), - fn_B(1.01*x,1.01*y,1.01*z) ) }
contained_by { box { -5,5 } }
max_gradient 4
all_intersections //otherwise inside of shell is transparent/invisible!
scale <2,3,3>*0.65
}
isosurface {
function { max( fn_A(x,y,z), - fn_B(1.01*x,1.01*y,1.01*z) ) }
contained_by { box { -5,5 } }
max_gradient 4
all_intersections //otherwise inside of shell is transparent/invisible!
scale <3,3,2>*0.65
}

texture {
cylindrical
texture_map {
[0.3  pigment{ rgbt <0.2,1,0.0,0.4>*1.2 } ]
[0.4  pigment{ rgbt <0.4,1,0.4,0.0> } ]    
[0.6  pigment{ rgbt <0.2,1,0.0,0.4>*1.2 } ]
[0.9  pigment{ rgbt <0.4,1,0.4,0> } ]
} frequency 0.5 scale 5 turbulence 0.05
}

rotate<90,0,0>

}
//Style
cylinder { <0,0,0>, <0,0,-8>, 0.4 pigment { rgbt <1,0.3,0.0,0.0> } finish { F_MetalC } }
//Stigma
union{
sphere { <0,0,-8>, 0.4 pigment { rgbt <1,0.0,0.0,0.0> } translate <0.25,0,0> }
sphere { <0,0,-8>, 0.4 pigment { rgbt <1,0.0,0.0,0.0> } translate <0.25,0,0> rotate <0,0,90> }
sphere { <0,0,-8>, 0.4 pigment { rgbt <1,0.0,0.0,0.0> } translate <0.25,0,0> rotate <0,0,180> }
sphere { <0,0,-8>, 0.4 pigment { rgbt <1,0.0,0.0,0.0> } translate <0.25,0,0> rotate <0,0,270> }
finish { ambient 0.5 phong 0.9 phong_size 60 reflection {0.0} }
normal { bumps 2 scale 0.1 }
}

//Androecium
union{

//Filament
sphere_sweep { b_spline 7
<-2,0,7>, 0.4
<0,0,6>, 0.4
<2,1,5>, 0.4
<3,0,4>, 0.4
<6,-1,0>, 0.4
<7.5,0,-4>, 0.4
<9,0,-8>, 0.4
pigment { rgbt <0.4,0.4,0.8,0.0> } finish { F_MetalB }

rotate <0,0,45>
translate <0,0,0>
}
//Anther
union{
sphere { <8,0,-4>, 1 scale <0.5,0.5,2> pigment { rgbt <0.4,0,1.0,0.0> } finish { F_MetalC } translate
<0.4,0.5,4> }
sphere { <8,0,-4>, 1 scale <0.5,0.5,2> pigment { rgbt <0.4,0,1.0,0.0> } finish { F_MetalC } translate
<0.4,-0.5,4> }
translate <3,0,0>
rotate <0,0,45>
}

//Filament
sphere_sweep { b_spline 7
<-2,0,7>, 0.4
<0,0,6>, 0.4
<2,1,5>, 0.4
<3,0,4>, 0.4
<4,-1,0>, 0.4
<6,0,-4>, 0.4
<8,0,-8>, 0.4
pigment { rgbt <0.4,0.4,0.8,0.0> } finish { F_MetalB }
rotate <0,0,45+90>
translate <0,0,0>
}
//Anther
union{
sphere { <8,0,-4>, 1 scale <0.5,0.5,2> pigment { rgbt <0.4,0,1.0,0.0> } finish { F_MetalC } translate
<0.4,0.5,4> }
sphere { <8,0,-4>, 1 scale <0.5,0.5,2> pigment { rgbt <0.4,0,1.0,0.0> } finish { F_MetalC } translate
<0.4,-0.5,4> }
translate <2,0,0>
rotate <0,0,45+90>
}

//Filament
sphere_sweep { b_spline 7
<-2,0,7>, 0.4
<0,0,6>, 0.4
<2,1,5>, 0.4
<3,0,4>, 0.4
<5,-1,0>, 0.4
<6,0,-4>, 0.4
<8,0,-8>, 0.4
pigment { rgbt <0.4,0.4,0.8,0.0> } finish { F_MetalB }
rotate <0,0,45+180>
translate <0,0,0>
}
//Anther
union{
sphere { <8,0,-4>, 1 scale <0.5,0.5,2> pigment { rgbt <0.4,0,1.0,0.0> } finish { F_MetalC } translate
<0.4,0.5,4> }
sphere { <8,0,-4>, 1 scale <0.5,0.5,2> pigment { rgbt <0.4,0,1.0,0.0> } finish { F_MetalC } translate
<0.4,-0.5,4> }
translate <2,0,0>
rotate <0,0,45+180>
}

//Filament
sphere_sweep { b_spline 7
<-2,0,7>, 0.4
<0,0,6>, 0.4
<2,1,5>, 0.4
<3,0,4>, 0.4
<5,-1,0>, 0.4
<7,0,-4>, 0.4
<8,0,-8>, 0.4
pigment { rgbt <0.4,0.4,0.8,0.0> } finish { F_MetalB }
rotate <0,0,45+270>
translate <0,0,0>
}
//Anther
union{
sphere { <8,0,-4>, 1 scale <0.5,0.5,2> pigment { rgbt <0.4,0,1.0,0.0> } finish { F_MetalC } translate
<0.4,0.5,4> }
sphere { <8,0,-4>, 1 scale <0.5,0.5,2> pigment { rgbt <0.4,0,1.0,0.0> } finish { F_MetalC } translate
<0.4,-0.5,4> }
translate <3,0,0>
rotate <0,0,45+270>
}


}


rotate <0,0,25> rotate <0,0,0>
}