POV-Ray : Newsgroups : povray.text.scene-files : Source code for "Iso-bonds again" Server Time
28 Jun 2024 22:55:22 EDT (-0400)
  Source code for "Iso-bonds again" (Message 1 to 1 of 1)  
From: Tor Olav Kristensen
Subject: Source code for "Iso-bonds again"
Date: 3 Jun 2002 14:04:19
Message: <3CFBAED3.9285580@hotmail.com>
I believe that the code below will produce an image that is
similar to the image that I posted to the povray.binaries.images
group 13. Des. 2001:

http://news.povray.org/povray.binaries.images/20682/
news://news.povray.org/3C181BF5.5AE55B6A%40hotmail.com

I have cleaned up the code some, but unfortunately I do not
have a fast enough PC at hand to verify that the output image
hasn't changed much.


Tor Olav


// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Copyright 2002 by Tor Olav Kristensen
// Email: t o r _ o l a v _ k [ a t ] h o t m a i l . c o m
// http://hjem.sol.no/t-o-k/povray
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#version 3.5;

#include "functions.inc"
#include "rad_def.inc"

global_settings {
  assumed_gamma 1
  radiosity { Rad_Settings(Radiosity_OutdoorLight, off, off) }
}

light_source {
  <-1.5, 2, -0.5>*1000
  color rgb <1.00, 0.92, 0.77>
  shadowless
}

camera {
  location vnormalize(< 7, 8, -14>)*80
  look_at <0, 0, 0>
}

default {
  texture {
    finish {
      ambient 0
      diffuse 0.65
    }
  }
}

sphere {
  <0, 0, 0>, 1
  texture {
    pigment {
      gradient y
      color_map {
        [ 0.0 color rgb <0.880, 0.935, 0.976> ]
        [ 0.2 color rgb <0.300, 0.450, 0.950> ]
      }
    }
    finish {
      diffuse 0
      ambient 1
    }
  }
  hollow on
  no_shadow
  scale 30000
}

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

#macro TransformFunction(Fn, Transform)

  #local TT = function { transform { Transform inverse } }

  function { Fn(TT(x, y, z).x, TT(x, y, z).y, TT(x, y, z).z) }

#end // macro TransformFunction

#declare SquashFn =
  function(f, s) { select(s, -1, 1)*(1/(1 + exp(-abs(s)*f)) - 1) }

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

#declare XTorusFn =
  function(x, y, z, Rmaj, Rmin, A, B) {
//    (x^B + ((y^A + z^A)^(1/A) - Rmaj)^B)^(1/B) - Rmin
    pow(pow(x,B) +pow(pow(pow(y,A) +pow(z,A),1/A) -Rmaj,B),1/B) -Rmin
  }

#declare NoiseFn =
  function { 0.5 - f_noise3d(x, y, z) }

#declare SNoiseFn =
  TransformFunction(
    NoiseFn,
    transform { scale 1.5 }
  )

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

#declare StrgthI = 2;
#declare StrgthO = 6;

#declare Rmaj = 10;
#declare Rmin = 0.7;

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

#declare RmajA = 10;
#declare RminA = 1.7;
#declare RadA = 3.2;
#declare BigRadA = 150;

#declare ScaleC = 2.5;
#declare ScaleD = 1.0;

#declare Torus1AFn =
  TransformFunction(
    function { XTorusFn(x, y, z, RmajA, RminA, StrgthI, StrgthO) },
    transform { rotate -60*y }
  )

#declare Torus2AFn =
  TransformFunction(
    function { XTorusFn(x, y, z, RmajA, RminA, StrgthI, StrgthO) },
    transform { }
  )

#declare Torus3AFn =
  TransformFunction(
    function { XTorusFn(x, y, z, RmajA, RminA, StrgthI, StrgthO) },
    transform { rotate  60*y }
  )

#declare UpperSphereAFn =
  TransformFunction(
    function { f_sphere(x, y, z, RadA) },
    transform {
      scale <ScaleC, ScaleD, ScaleC>
      translate  0.9*RmajA*y
    }
  )

#declare LowerSphereAFn =
  TransformFunction(
    function { f_sphere(x, y, z, RadA) },
    transform {
      scale <ScaleC, ScaleD, ScaleC>
      translate -0.9*RmajA*y
    }
  )

#declare BigSphereAFn = 
  TransformFunction(
    function { f_sphere(x, y, z, BigRadA) },
    transform {
      translate -(BigRadA + RmajA + RadA - 1.2)*y
    }
  )

#declare IsoA =
  isosurface {
    function {
      SquashFn(Torus1AFn(x, y, z), 8)
     +SquashFn(Torus2AFn(x, y, z), 8)
     +SquashFn(Torus3AFn(x, y, z), 8)
     +SquashFn(UpperSphereAFn(x, y, z), 2)
     +SquashFn(LowerSphereAFn(x, y, z), 2)
     +SquashFn(BigSphereAFn(x, y, z), 2)
     +0.1*SNoiseFn(x, y, z)
    }
    threshold -0.5
    max_gradient 4
    contained_by { sphere { <0, 0, 0>, 60 } }
  }

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

#declare RmajB = 10;
#declare RminB = 1.5;
#declare RadB = 3;

#declare ScaleE = 1;
#declare ScaleF = 2;

#declare Torus1BFn =
  TransformFunction(
    function { XTorusFn(x, y, z, RmajA, RminA, StrgthI, StrgthO) },
    transform {
      scale <0.6, 1.0, 1.0>
      rotate -60*y
    }
  )

#declare Torus2BFn =
  TransformFunction(
    function { XTorusFn(x, y, z, RmajA, RminA, StrgthI, StrgthO) },
    transform {
      scale <0.6, 1.0, 1.0>
    }
  )

#declare Torus3BFn =
  TransformFunction(
    function { XTorusFn(x, y, z, RmajA, RminA, StrgthI, StrgthO) },
    transform {
      scale <0.6, 1.0, 1.0>
      rotate  60*y
    }
  )

#declare UpperSphereBFn =
  TransformFunction(
    function { f_sphere(x, y, z, RadB) },
    transform {
      scale <ScaleE, ScaleF, ScaleE>
      translate  RmajB*y
    }
  )

#declare LowerSphereBFn =
  TransformFunction(
    function { f_sphere(x, y, z, RadB) },
    transform {
      scale <ScaleE, ScaleF, ScaleE>
      translate -RmajB*y
    }
  )

#declare TorusBFn =
  TransformFunction(
    function { f_torus(x, y, z, Rmaj, Rmin) },
    transform {
      scale <ScaleE, ScaleF, ScaleE>
    }
  )

#declare IsoB =
  isosurface {
    function {
      SquashFn(Torus1BFn(x, y, z), 5)
     +SquashFn(Torus2BFn(x, y, z), 5)
     +SquashFn(Torus3BFn(x, y, z), 5)
     +SquashFn(UpperSphereBFn(x, y, z), 8)
     +SquashFn(LowerSphereBFn(x, y, z), 8)
     +SquashFn(TorusBFn(x, y, z), -3)
     +0.1*SNoiseFn(x, y, z)
    }
    threshold -0.5
    max_gradient 10
    contained_by { sphere { <0, 0, 0>, 15 } }
  }                                     

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

#declare IsoC =
  isosurface {
    function {
      f_torus(x, y, z, Rmaj, Rmin)
      +0.04*SNoiseFn(x, y, z)
    }
    max_gradient 4
    contained_by {
      box {
       -1.04*<Rmaj + Rmin, Rmin, Rmaj + Rmin>,
        1.04*<Rmaj + Rmin, Rmin, Rmaj + Rmin>
      }
    }
  }                                     

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

object {
  IsoA
  scale <ScaleD, ScaleC, ScaleD>
  rotate -15*y
  pigment { color rgb <1, 1, 1> }
}

object {
  IsoB
  scale <ScaleF, ScaleE, ScaleF>
  rotate  15*y
  pigment { color rgb <1.95, 1.78, 1.42>/2 }
}

object {
  IsoC
  scale ScaleE*ScaleF*<1, 1, 1>
  pigment { color rgb <1.0, 0.7, 0.6> }
}

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


Post a reply to this message

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