POV-Ray : Newsgroups : povray.general : Regular Polygons & Prisms : Re: Regular Polygons & Prisms Server Time
11 Aug 2024 07:18:42 EDT (-0400)
  Re: Regular Polygons & Prisms  
From: Remco de Korte
Date: 8 Oct 1999 20:23:18
Message: <37FE8B28.8415B51B@xs4all.nl>
Andrea Ryan wrote:
> 
> After a little testing, I found that the macro worked fine for prisms with
> a odd number of sides, but it doesn't work prisms that have an even number
> of sides.
> I think the problem is in this code:
> 
> #local rotation_no = 0;
> #while (rotation_no<sides)
> #local angle_of_rotation = 360/sides;
> #local temp_vec=vrotate(<0,1,0>,<0,1,angle_of_rotation*rotation_no>);
> #local vec=<temp_vec.y,temp_vec.z>;
> #local rotation_no = rotation_no+1;
> //the stuff that writes to the data file
> #end
> 
> When a prism with a even number of sides is created, one of the points has
> a coordinate with an incorrect sign. Thanks for your help.
> Brendan Ryan
> 
> Andrea Ryan wrote:
> 

I don't know exactly what caused your problem but the code above has some typos.

Here is what I made of it:

#declare sides=5;

prism {
  linear_sweep
  linear_spline
  -0.5,
   0.5,
  sides+1,
   
#local rotation_no = 0;
#while (rotation_no<sides)
#local angle_of_rotation = 360/sides;
//#local temp_vec=vrotate(<0,1,0>,<0,1,angle_of_rotation*rotation_no>);   
#local temp_vec=vrotate(<0,1,0>,<0,0,angle_of_rotation*rotation_no>);   
//#local vec=<temp_vec.y,temp_vec.z>;
#local vec=<temp_vec.x,temp_vec.y>;
#if (rotation_no=0)
  #declare vec0=vec;
#end
vec,
#local rotation_no = rotation_no+1;
#end
vec0
pigment{rgb 1}
rotate x*90
}

When I tried this it worked fine.

Remco


Post a reply to this message

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