POV-Ray : Newsgroups : povray.general : Creating a 5 point star? : Re: Creating a 5 point star? Server Time
3 Aug 2024 22:15:58 EDT (-0400)
  Re: Creating a 5 point star?  
From:
Date: 28 Sep 2003 20:38:17
Message: <3f777ef9@news.povray.org>
/*
NoNoNo!

prism requires 2D-vectors, so it's neccessary to construct
such vectors from the x- and y-components of P1, ... as in
the code below. I've corrected the numbering of the IP's
and added the exact value for Warp's "R". Repetition of the
first point is not neccessary here because linear-spline
prisms are automatically closed.

A second (blue) prism is calculated by simple trigonometry;
it has a variable number of 'spikes'.

This whole post is a working scene -- copy to POV-Ray,
play around with the green prism's Fat and the blue prism's
Corners and R, and enjoy!

   Sputnik

*/


// prismatic stars

// +SP8 +EP8 -FN +A0.1 +AM2 +R3


light_source { <-1, 5, -3>*100 rgb 1 }
camera { location <0, 4, -2> look_at 0.5*y }


// green prism

#declare Fat = 1; // >1: fat; <1: slim
#declare R = (3-sqrt(5))/2 * Fat;

#declare P1 = y;
#declare P2 = vrotate(y, z*360/5);
#declare P3 = vrotate(y, z*2*360/5);
#declare P4 = vrotate(y, z*3*360/5);
#declare P5 = vrotate(y, z*4*360/5);

#declare IP1 = vrotate(R*y, z*.5*360/5);
#declare IP2 = vrotate(R*y, z*1.5*360/5);
#declare IP3 = vrotate(R*y, z*2.5*360/5);
#declare IP4 = vrotate(R*y, z*3.5*360/5);
#declare IP5 = vrotate(R*y, z*4.5*360/5);

prism { linear_sweep 0, 1, 11,
  <P1.x, P1.y>, <IP1.x, IP1.y>,
  <P2.x, P2.y>, <IP2.x, IP2.y>,
  <P3.x, P3.y>, <IP3.x, IP3.y>,
  <P4.x, P4.y>, <IP4.x, IP4.y>,
  <P5.x, P5.y>, <IP5.x, IP5.y>,
  <P1.x, P1.y>
  pigment { color rgb <.6, 1, .6> }
  finish { ambient .3 diffuse .7 }
  translate -1.1*x
  }


// blue prism: shorter code,

#declare Spikes = 12;
#declare R = 0.6; // or whatever ...

prism { linear_sweep 0, 1, 2*Spikes

  #declare Count = 0;
  #while (Count<Spikes)
    #declare Angle = 2*pi/Spikes*Count;

    , <-sin(Angle), cos(Angle)>
    , <-sin(Angle+pi/Spikes), cos(Angle+pi/Spikes)> * R

    #declare Count = Count+1;
    #end//while Count

  pigment { color rgb <.6, .6, 1> }
  finish { ambient .3 diffuse .7 }
  translate 1.1*x
  }


// END


Post a reply to this message

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