Showing posts with label POVRay. Show all posts
Showing posts with label POVRay. Show all posts

Wednesday, March 18, 2015

Spherical Lissajous Curves using POVRay






Some examples of spherical Lissajous curves created with POVRay. Pretty sure the code is Perl.

##############################################################################
# This program created by Hans Mikelson February 1998
# This program generates a POV file so that 3D graphs can be
# rendered using the POV ray tracing package.  The surface is mapped
# as a sphere for each data point sampled.  This was configured for
# use on a Win95 computer.  Some changes may need to be made for use on
# other systems.  This program assumes that POVRay has been installed
# and that there is a path to it.
##############################################################################

# Define files for the template (header/footer), the data and the POV file.
$povfile="plotter.pov";
$scale   =.25;
$radius  = $scale;

# open the POV file.
open (POV, ">$povfile");

# Print the header
print POV "#version 3.0\n";
print POV "global_settings { assumed_gamma 2.2 }\n\n";
print POV "#include \"colors.inc\"\n";
print POV "#include \"shapes.inc\"\n";
print POV "#include \"textures.inc\"\n";
print POV "#include \"glass.inc\"\n";
print POV "#include \"stones.inc\"\n\n";
print POV "#include \"metals.inc\"\n\n";
print POV "camera {\n";
print POV "location <-2,-9,-2>\n";
print POV "  look_at <-2,0,-2>}\n\n";
print POV "// Light sources \n";
print POV "light_source {<-30, 21,  40> color White}\n";
print POV "light_source {< 0, -8, -4> color White}\n";
print POV "light_source {< 2,  30,  3> color White}\n";
print POV "background { color rgb <1, 1, 1> }\n\n";

@ul = (.3,.3,.6);
@vl = (.2,.2,.9);

for ($j=0; $j<1; $j++)
 {
  for ($k=0; $k<1; $k++)
   {
$u = $ul[$j];
$v = $vl[$k];
$rad = 2;

# Print the data.
for ($i=0; $i<800; $i++)
 {
  $t = $i * .1;
  # Cosines
  $cosu = cos($u*$t);
  $cosv = cos($v*$t);

  # Sines
  $sinu = sin($u*$t);
  $sinv = sin($v*$t);

  # Compute X and Y
  $xval = $rad*$sinu*$cosv;
  $yval = $rad*$sinu*$sinv;
  $zval = $rad*$cosu;


  $colr=1/(1+$xval*$xval);
  $colg=1/sqrt(1+abs($yval));
  $colb=1/(1+$zval*$zval*$zval*$zval);
  
  $xval += $j*5; $yval += $k*5;

  print POV "sphere { <$xval, $zval, $yval>, $radius\n";
  print POV "    texture { pigment {color rgb <$colr, $colg, $colb>}}\n";
  print POV "    finish {caustics 1.0 phong 1 phong_size 300 reflection 0.15}\n";
  print POV "}\n\n";

  if ($i>0)
   {
    print POV "cylinder { <$xval, $zval, $yval>, <$xold, $zold, $yold> $radius\n";
    print POV "    texture { pigment {color rgb <$colr, $colg, $colb>}}\n";
    print POV "    finish {caustics 1.0 phong 1 phong_size 300 reflection 0.15}\n";
    print POV "}\n\n";
   }
  $xold = $xval;
  $yold = $yval;
  $zold = $zval;
 }

}}
close(POV);

# End of script

Electron Orbitals using POVRay Graphics


This image was created using POVRay and the wave function for electron orbitals.  1s, 2s, 3s on the left, p orbitals on the right, 2p on top and 3p on the bottom.