POV-Ray : Newsgroups : povray.binaries.images : n-foil : n-foil Server Time
19 May 2024 23:12:28 EDT (-0400)
  n-foil  
From: Samuel B 
Date: 5 Aug 2023 17:45:00
Message: <web.64cec2981790fd63f8c47d526e741498@news.povray.org>
Pattern function for an n-foil (like a trefoil, but with more Ns). Fits within a
unit circle.

// +fn -f +a0.3 +am2 +r2

#version 3.7;
global_settings{assumed_gamma 1.}
#default{ finish{emission 1} }

#declare CScale = 1.2;
camera{
 orthographic
 right x*2 up y*2
 location -32*z
 look_at 0
 scale CScale
}

/*
 N  = angular symmetry
 CT = circle thickness
 PO = texture z offset
*/
#macro N_Foil(N, CT, PO)

 // angle map for rotation & repetition
 #local A =
  function(x, y){
   floor(atan2(x, y)/pi/2*N+.5)/N*pi*2
  }

 // distance between two rotated points
 #local Dst = vlength(<0, 1>-vrotate(<0, 1>, z*360/N));

 // adjustment for radius and y-translation
 #local Scale = (1-CT) / (1+Dst/2);

 // pattern function
 #local PF =
  function{
   pattern{
    pigment_pattern{
     pigment_pattern{
      planar
      translate -y
      scale CT
     }
     pigment_map{
      [0 rgb 0]
      [.025/CT granite scale .5 translate PO*z]
     }
     translate y*((Dst/2)*Scale+CT)
    }
   }
  }

 // function before repetition
 #local F =
  function{
   pattern{
    function{
     PF(0, sqrt(x*x+pow(max(y, 0), 2)), 0)
    }
    rotate -z*180/N
    translate y*Scale
   }
  }

 // function repeated radially with mirrored x
 F(abs(x*cos(A(x, y)) - y*sin(A(x, y))), x*sin(A(x, y)) + y*cos(A(x, y)), 0)
#end

plane{
 z, 0
 pigment{
  function{N_Foil(7, .075, 1)}
 }
}

torus{1, 1. * CScale / image_width rotate x*90 pigment{rgb<1, .05, .1>}}


Post a reply to this message


Attachments:
Download 'nfoil.jpg' (70 KB)

Preview of image 'nfoil.jpg'
nfoil.jpg


 

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