POV-Ray : Newsgroups : povray.binaries.images : Cool mathematical object : Re: Cool mathematical object Server Time
28 Apr 2024 15:14:42 EDT (-0400)
  Re: Cool mathematical object  
From: scam
Date: 31 May 2006 07:45:00
Message: <web.447d804452ae62aa5c947f990@news.povray.org>
"Bill Pragnell" <bil### [at] hotmailcom> wrote:
>
> I too would be grateful for a peek at the source!
>
> Bill

Ask and you shall receive. I upload it on one condition though: I want to
see what you do with it!

The main parameter is the size of the tiling. A setting of 4 is fine for
renders from a distance.

----------------------------------------------

#include "rand.inc"
#include "colors.inc"
#include "rad_def.inc"
#include "functions.inc"


#declare num_phi1=8;
// number of points along 90 degrees of the
// major torus axis
#declare ninetydeginrads=3.14159265358/2;

#declare mytexture=     texture {
   pigment { color rgb <1, 1, 1> }
   finish {
     ambient color rgb <0, 0, 0>
     diffuse 1
   }
 }



// The functions defining the transformation of the 3D Trouchet tiling

#declare point_trans_x=function(x,y,z) {
 x/max(1e-8,x*x+y*y+z*z)
}
#declare point_trans_y=function(x,y,z) {
 y/max(1e-8,x*x+y*y+z*z)
}
#declare point_trans_z=function(x,y,z) {
 z/max(1e-8,x*x+y*y+z*z)
}

// This generates points of one quarter torus
// trans, rot is used for positioning the torus whithin the origin tile
// trans2, rot2 is used for translating/rotating the final tile

#macro _quarter_torus_tris(trans,rot,trans2,rot2)
  #declare _phi1 = -ninetydeginrads/num_phi1;
  #while (_phi1<=ninetydeginrads+ninetydeginrads/num_phi1)
    #declare p1 =
vrotate(vrotate(<sin(_phi1),-cos(_phi1)+1,0>,rot)+trans,rot2)+trans2;
    #declare p1 =
<point_trans_x(p1.x,p1.y,p1.z),point_trans_y(p1.x,p1.y,p1.z),point_trans_z(p1.x,p1.y,p1.z)>;
    p1,0.2*max(1e-8,pow(p1.x,2)+pow(p1.y,2)+pow(p1.z,2))
    #declare _phi1 = _phi1 + ninetydeginrads/num_phi1;
  #end
#end


// This generates the sphere sweeps for one complete
// tile with 3 quarter tori
#macro Trouchet_Tile(trans,rot)
union {
 sphere_sweep {
  cubic_spline
  num_phi1+3,
     _quarter_torus_tris(<-1,0,0>,0,trans,rot)
  tolerance 0.01
  texture{ mytexture}
 }

 sphere_sweep {
  cubic_spline
  num_phi1+3,
     _quarter_torus_tris(<1,0,-0>,<90,180,0>,trans,rot)
  tolerance 0.01
  texture{ mytexture}
 }
 sphere_sweep {
  cubic_spline
  num_phi1+3,
    _quarter_torus_tris(<0,0,1>,<0,90,180>,trans,rot)
  tolerance 0.01
  texture{ mytexture}
}
 scale 30

}
#end


// The seed for the 3D tiling
#declare rotseed=seed(2345143);
// This is the size of the tiling in cubes along
// each axis. Should be a multiple of 2.
#declare _size=4;

union{

#declare _x=-_size/2;
#while (_x<=_size/2)
 #declare _y=-_size/2;
 #while (_y<=_size/2)
   #declare _z=-_size/2;
   #while (_z<=_size/2)
     #declare rx=int(RRand(0,3,rotseed))-1;
     #declare ry=int(RRand(0,3,rotseed))-1;
     #declare rz=int(RRand(0,3,rotseed))-1;
// Here I remove the central tile before the
// inversion operation for aesthetic reasons
     #if (_x=0)
       #if (_y=0)
         #if(_z=0)
         #else
           Trouchet_Tile( <_x,_y,_z>*2 , <rx,ry,rz>*90 )
         #end
       #else
         Trouchet_Tile( <_x,_y,_z>*2 , <rx,ry,rz>*90 )
       #end
     #else
       Trouchet_Tile( <_x,_y,_z>*2 , <rx,ry,rz>*90 )
     #end
     #declare _z=_z+1;
   #end
   #declare _y=_y+1;
 #end
 #declare _x=_x+1;
#end

}


camera {
 location vnormalize(< 6, 2, -14>)*90
 look_at <0, 0, 0>
}

sky_sphere {
 pigment {
   gradient y
   color_map {
     [ 0.0 color rgb <1.1, 1.1, 2.> ]
     [ 0.5 color rgb <0,0,0> ]
     [ 1.0 color rgb <1.1, 1.1, 2.> ]
   }
   scale <1, 2, 1>
   translate y
 }
}


// Basic lighting

light_source { <6, 2, -14>*90 color White }

// Or for radiosity comment out the above
// light source, and use the following:

/* light_source {
  <3, -5, -2>*20
  color rgb <0.95, 0.78, 0.42>
  area_light
  10*x, 10*z,
  4, 4
  jitter
  orient
}

light_source {
    <0, 0, 0>
    color Red
    shadowless
    fade_distance 10
    fade_power 2

  }

global_settings { radiosity { Rad_Settings(Radiosity_Normal, off, off) } }

*/


Post a reply to this message

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