POV-Ray : Newsgroups : povray.general : Sierpinski N-Gons Server Time
26 Nov 2024 07:26:45 EST (-0500)
  Sierpinski N-Gons (Message 1 to 3 of 3)  
From: Anthony D  Baye
Subject: Sierpinski N-Gons
Date: 1 Apr 2011 04:25:00
Message: <web.4d958a71fb25673b9c4fb0ad0@news.povray.org>
I've managed to write a macro to generate a a sierpinski polygon of n sides, but
I'm having a few problems.  First, I would expect the 4-sided polygon
(sierpinski square) to look like a Mengher sponge, but it doesn't.

This is not my main problem, however.

What I'm trying to do is something like this:
http://www.fractalsciencekit.com/gallery/orbital/f1058.jpg

which the site says is a sierpinski n-gon, but I can't figure out how they did
it, and they aren't really saying except that it was done with their software.

If anyone can help me, I'd appreciate it.

Regards,
A.D.B.

Code Listing:

#include "kolors.inc"
#include "math.inc"
#include "functions.inc"

light_source { <0.0, 0.0, -20.0> 1.0 }
camera {
     perspective
     location <0.0, -10.0, -1.5>
     up y
     right (image_width/image_height)*x
     look_at <0.0, -10.0, 0.0>
     }

#default { pigment { White } finish { ambient 0.3 diffuse 0.6 } }

#macro nGon(n, rad)
     prism {
          -0.0625, 0.0625, 2*n+1
          #local i = 0;
          #while(i <= 2*n)
               #if(i <= n)
                    rad*<sind( i * (360/n) ), cosd( i * (360/n) )>
               #else
                    (rad-0.015625) * <sind( i * (360/n) ), cosd( i * (360/n) )>
               #end
          #local i = i + 1;
          #end
               pigment { function { r(x,y,z,1) } color_map { [0 rgb 0] [1 rgb 1]
} }
               rotate -90.0*x
          }
#end

#macro sierpinski(n, rad, E, T)

#ifndef(fn)
#local fn = function(N){1/(2*(1+sum(k,1,N/4,cos(2*pi*k/N))))}
#end


object {
     union {
          union {
          #if(rad >= E)
               #local i = 0;
               #while(i <= n)
     #local T1 = (1 - fn(n) ) * rad * <sin(2*pi*(i)/n), cos(2*pi*(i)/n), 0>;
                    sierpinski(n, rad*fn(n), E transform { translate T1 })
               #local i = i + 1;
               #end
          #end
               }

          //nGon(n, r)
          sphere { 0.0, 0.00390625 }
          }
               transform { T }
     }

#end

sierpinski(8, 10, 1/64, transform { translate 0*x })


Post a reply to this message

From: Le Forgeron
Subject: Re: Sierpinski N-Gons
Date: 1 Apr 2011 07:40:35
Message: <4d95b9b3@news.povray.org>
Le 01/04/2011 10:18, Anthony D. Baye a écrit :
> I've managed to write a macro to generate a a sierpinski polygon of n sides, but
> I'm having a few problems.  First, I would expect the 4-sided polygon
> (sierpinski square) to look like a Mengher sponge, but it doesn't.
> 
> This is not my main problem, however.
> 
> What I'm trying to do is something like this:
> http://www.fractalsciencekit.com/gallery/orbital/f1058.jpg
> 
> which the site says is a sierpinski n-gon, but I can't figure out how they did
> it, and they aren't really saying except that it was done with their software.
> 
> If anyone can help me, I'd appreciate it.
> 
> Regards,

Sierpinski is associated with the Sierpinski triangle & carpet.

http://en.wikipedia.org/wiki/Sierpinski_carpet

The triangle is a red herring. It is built from with a different method.
(split a triangle in 4 sub-triangles, remove central, repeat).


As indicated within the wiki, you will need self replication to build
the carpets. N-gons are not self replicating excepted for very specific
N-gons.

 ( http://en.wikipedia.org/wiki/Self-replication )

The provided image is not a true carpet. So 4-gon is not a Mengher face!

In http://www.fractalsciencekit.com/types/orbital.htm
they discribe the process.

Their Sierpinski triangle is the set of point made as follow.
S(0) = { triangle vertices }. (3 points)

S(n+1) = S(n) U { f(S(n)) }

f(point)= midpoints between point and the original triangle vertices.

So, in fact, f() generates 3 new points per input point, if you try to
cover all the cases.
(but some points are duplicated, so the size of the set does not grow as
fast as 3^(n+1)... but not far).

Generalisation to n-gons: increase the number of initial points (to n),
increase the number of points generated by f. If ready for brute force,
just ignore duplicated points (do not detect them)

Your approach is based on the formula of the triangle, which is not
appropriate for n-gons. (Both provide the Sierpinski triangle, but that
just some kind of lucky side effects, IMHO).


Post a reply to this message

From: Le Forgeron
Subject: Re: Sierpinski N-Gons
Date: 2 Apr 2011 05:05:17
Message: <4d96e6cd$1@news.povray.org>
Le 01/04/2011 10:18, Anthony D. Baye nous fit lire :
> I've managed to write a macro to generate a a sierpinski polygon of n sides, but
> I'm having a few problems.  First, I would expect the 4-sided polygon
> (sierpinski square) to look like a Mengher sponge, but it doesn't.
> 
> This is not my main problem, however.
> 
> What I'm trying to do is something like this:
> http://www.fractalsciencekit.com/gallery/orbital/f1058.jpg
> 
> which the site says is a sierpinski n-gon, but I can't figure out how they did
> it, and they aren't really saying except that it was done with their software.
> 
> If anyone can help me, I'd appreciate it.

My bad. The initial point is 0, not the vertex.
(in fact, the initial point is pretty irrevelant, as very soon its
initial coordinates get reduced to small influence (1/8 at third
iteration, and 1/1024 at tenth)

The colour is probably fancy (or based on hsv/hsl with addition made of
composing vectors)
Nevertheless, the lightness/whiteness seems a function of the likeness
to hit the position. Or the first iteration might start with a L=1, and
it get reduced for each iteration.

Instead of being attracted to one of the original vertex
( npos = (oldpos+vertex)/2 )
they might be using the original vertex (on a circle) with a reducing
radius as the displacement for each iteration.
Or using npos = oldpos + (vertex-oldpos)/factor
with factor not being exactly 2.


Post a reply to this message

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