POV-Ray : Newsgroups : povray.binaries.images : n-foil : Re: n-foil Server Time
20 May 2024 00:07:58 EDT (-0400)
  Re: n-foil  
From: Samuel B 
Date: 6 Aug 2023 19:10:00
Message: <web.64d0281f357dd001f8c47d526e741498@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "Samuel B." <stb### [at] hotmailcom> wrote:
> > "Samuel B." <stb### [at] hotmailcom> wrote:
> > > Pattern function for an n-foil
> >
> > Ideally, the center would be empty [...]
>
> [Bald Eagle's code]
>
> Gives me an N-sided hole in the center.
> Not sure how to get it to be an actual circle....
>
> - BW

It's not an easy function to alter, but your solution looks pretty good! I bet
it would help when making rose windows.

I was hoping to make a more traditional shape, but 'tradition' can be a flexible
idea :P

Here's what I came up with this afternoon (with added border):

/*
 N = angular symmetry
 CT = circle/frame thickness
 YC = y-cutoff
 PO = texture z offset
*/
#macro N_Foil(N, CT, YC, 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) - CT;

 // 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]
     }
    }
   }
  }

 // function before repetition
 #local F =
  function{
   max(
    PF(0, sqrt(x*x+pow(max(y-Scale, -YC), 2))-(Dst/2)*Scale-CT, 0),
    PF(0, -sqrt(x*x+y*y)+1-2*CT, 0)
   )
  }

 // 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

The eventual plan was to make this work for height_fields or isosurfaces.

Sam


Post a reply to this message


Attachments:
Download 'fnfoilb.jpg' (38 KB)

Preview of image 'fnfoilb.jpg'
fnfoilb.jpg


 

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