One well-known symbol of the philosophy of duality known as yin and yang is the taijitu.



Task

   Create a function that, given a parameter representing size, generates such a symbol scaled to the requested size.
   Generate and display the symbol for two different (small) sizes.


 
// ====== General Scene setup ====== 
#version 3.7;
global_settings { assumed_gamma 2.2 }
 
camera{ location <0,2.7,4> look_at <0,.1,0> right x*1.6 
        aperture .2 focal_point <1,0,0> blur_samples 200 variance 1/10000 }
light_source{<2,4,8>, 1 spotlight point_at 0 radius 10}
sky_sphere {pigment {granite scale <1,.1,1> color_map {[0 rgb 1][1 rgb <0,.4,.6>]}}}
#default {finish {diffuse .9 reflection {.1 metallic} ambient .3}
          normal {granite scale .2}}
plane { y, -1 pigment {hexagon color rgb .7 color rgb .75 color rgb .65} 
        normal {hexagon scale 5}}
 
// ====== Declare one side of the symbol as a sum and difference of discs ====== 
 
#declare yang = 
difference {
  merge {
    difference {
      cylinder {0 <0,.1,0> 1}               // flat disk
      box {-1 <1,1,0>}                      // cut in half
      cylinder {<.5,-.1,0> <.5,.2,0> .5}    // remove half-cicle on one side
    }
    cylinder {<-.5,0,0> <-.5,.1,0> .5}      // add on the other side
    cylinder {<.5,0,0> <.5,.1,0> .15}       // also add a little dot
  }
  cylinder {<-.5,-.1,0> <-.5,.2,0> .15}     // and carve out a hole
  pigment{color rgb 0.1}
}
 
// ====== The other side is white and 180-degree turned ====== 
 
#declare yin = 
object {
  yang
  rotate <0,180,0>
  pigment{color rgb 1}
}
 
// ====== Here we put the two together: ====== 
 
#macro yinyang( ysize )
  union {
    object {yin}
    object {yang}
    scale ysize   
  }
#end
 
// ====== Here we put one into a scene: ====== 
 
object { yinyang(1)
         translate -y*1.08 }
 
// ====== And a bunch more just for fun: ====== 
 
#declare scl=1.1;
#while (scl > 0.01)  
 
  object { yinyang(scl) 
        rotate <0,180,0> translate <-scl*4,scl*2-1,0> 
        rotate <0,scl*360,0> translate <-.5,0,0>}
 
  object { yinyang(scl) 
        translate <-scl*4,scl*2-1,0> 
        rotate <0,scl*360+180,0> translate <.5,0,0>}
 
  #declare scl = scl*0.85;
#end