Star Polygons in POV

Below, the code which produced the above irregular star 24-gon. Render to a 4:3 aspect ratio.


/*
Star Polygons created within POV 3.0, by Russell Towle, December 1998.
email: Russell Towle <rtowle@inreach.com>

Star Polygons: With two user-defined parameters, N and S, we may create a variety of both regular convex polygons and star polygons, with cylinders on their sides and spheres on their edges. The radii of the spheres (R1) and cylinders (R2) may be set independently. With two additional parameters, F and E1, we may construct star polygons in which every Fth vertex is at distance E1 from the center of the polygon, otherwise, at distance 1.

N (the number of sides) must be an integer greater than or equal to 3, while S (the number of vertices to "step") must be an integer greater than or equal to 1, but less than N/2. When S=1 a regular convex polygon arises. For N=3 and N=4 no star polygon can exist. When N=5, S=2, we obtain the pentagram, or star pentagon, and when N=6 and S=2, the hexagram, or star hexagon.

The example below sets N=24, S=11, F=4, and E1=1.5. Hence an irregular star 24-gon is created, in which six of the vertices are at distance 1.5 (and lie on the vertices of a regular hexagon of circumradius 1.5), while the rest are at distance 1, from the center of the polygon.

Star polygons get "pointier" as S approaches N/2.

The six user-defined parameters and their defaults are listed below.

1. N, the number of sides; N>=3. Default: N=24.
2. S, how many vertices to step,S<N/2. Default: S=11.
3. R1, radius of spheres. Default: .05
4. R2, radius of cylinders. Default: .025
5. F , a factor of N, 1<=F<=N. Default: F=4.
6. E1, a scaling value, E1>0. Default: E1=1.5.
*/

#version 3.0
global_settings { assumed_gamma 2.2 }
#include "colors.inc"
#include "metals.inc"
#include "textures.inc"
#default { texture { pigment {color White} finish {phong 0.01 ambient 0.2 diffuse 0.6} }}

//begin user-defined parameters
#declare N = 24 //an integer >= 3
#declare S = 11 // 1<=S<(N/2)
#declare R1 = .05 //radius of spheres
#declare R2 = .025 //radius of cylinders
#declare F = 4 //every Fth point
#declare E1 = 1.5 //is at distance E1; else 1
//end user-defined parameters

#declare STAR = union{//create star polygon

#declare J = 1 //initialize outer loop

#while (J <= N)

#if (mod(J, F)=0)
#declare E = E1
#else
#declare E = 1
#end

#declare A = <E*cos(J*2*pi/N), E*sin(J*2*pi/N), 0>

#if (mod(J+S, F)=0)
#declare E = E1
#else
#declare E = 1
#end

#declare B = <E*cos((J+S)*2*pi/N), E*sin((J+S)*2*pi/N), 0>

sphere{A, R1 texture{T_Brass_4B} }
cylinder{A, B, R2 texture{T_Chrome_4B} }

#declare J = J+1
#end

}//star polygon created

camera {
location <0, -.1, 6>
direction <0, 0, 2>
up <0, 0, 1>
right <4/3, 0, 0> //aspect ratio 4:3
sky <0, 0, 1>
look_at <0,0,0> //look at center of star polygon
}

light_source {<-25, -25, 50> color rgb <.5, .5, .5>}
light_source {<25, -25, 50> color rgb <1, 1, 1>}

object{STAR scale<1, 1, .15>}//squished in the z axis

plane { z, -.25
pigment {
Sapphire_Agate
scale <2,.1,1>}
finish{Shiny}
}

sky_sphere {
pigment {
crackle
color_map {
[ 0.000 rgbft <0.0, 0.0, 0.0, 0.0, 0.0> ] //black
[ 1.000 rgbft <1.0, 1.0, 1.0, 0.0, 0.0> ] //white
}
cubic_wave
}

}



Back to the main POV page

Back to Russell Towle's homepage

Contact me