|
|
I couldn't let this go. I had to write the code!
so here it is right from my editor
// round prism
// Vers: 3.7
// Auth: Leroy Whetstone
// Email whe### [at] gmailcom
//====================================================================
#version 3.7;
global_settings {assumed_gamma 1 max_trace_level 20}
#include "colors.inc"
camera{ location <0,15,0>
look_at <0,0,0>
right x*image_width/image_height
}
light_source{<0,20,0> color White}
//-------------change-------------
#declare Pnts=4;// points >=3 3 is a little funky
#declare Rad=3; // radius
//----------end of change----------
#declare Pa=array[Pnts];//points array
#declare Ca=array[2][Pnts];// control points array
#declare Td=4*Pnts;//prism entries
#declare An=360/Pnts;// angle to place points
#declare An2=An/3;// angle of control points
#declare CL=Rad/cos(radians(An2));// length of control points from <0,0,0>
//points
#for(a,0,Pnts-1)
#declare Pa[a]=vrotate(x*Rad,y*a*An);
#end
//Base of control points
#declare D=vnormalize(vrotate(Pa[0],y*An2))*CL;
#declare Ca[0][0]=D;
#declare D=vnormalize(vrotate(Pa[0],y*An2*2))*CL;
#declare Ca[1][0]=D;
// rest of control points
#for(a,1,Pnts-1)
#declare Ca[0][a]=vrotate(Ca[0][0],y*a*An);
#declare Ca[1][a]=vrotate(Ca[1][0],y*a*An);
#end
//Show
prism{bezier_spline
-1,1,Td
#for(a,0,Pnts-1)
<Pa[a].x,Pa[a].z>
<Ca[0][a].x,Ca[0][a].z>
<Ca[1][a].x,Ca[1][a].z>
#if(a+1>Pnts-1) <Pa[0].x,Pa[0].z>
#else <Pa[a+1].x,Pa[a+1].z>
#end
#end
pigment{rgb <1,0,0>}
}
//show points
#for(a,0,Pnts-1)
sphere{<Pa[a].x,1,Pa[a].z>,.1 pigment{Blue}}
sphere{<Ca[0][a].x,1,Ca[0][a].z>,.1 pigment{Green}}
sphere{<Ca[1][a].x,1,Ca[1][a].z>,.1 pigment{Yellow}}
cylinder{<Pa[a].x,1,Pa[a].z> <Ca[0][a].x,1,Ca[0][a].z>,.05 pigment{Pink}}
cylinder{<Ca[0][a].x,1,Ca[0][a].z> <Ca[1][a].x,1,Ca[1][a].z>,.05
pigment{Pink}}
#if(a<Pnts-1)
cylinder{<Ca[1][a].x,1,Ca[1][a].z><Pa[a+1].x,1,Pa[a+1].z> ,.05 pigment{Pink}}
#end
#end
cylinder{<Ca[1][Pnts-1].x,1,Ca[1][Pnts-1].z><Pa[0].x,1,Pa[0].z> ,.05
pigment{Pink}}
After writing this I thought of another feature to add. That is SCALE !
You could make ovals.
Have Fun!
Post a reply to this message
|
|