|
![](/i/fill.gif) |
Wasn't it CreeD who wrote:
>Hi,
> I see that POV has a basic triangle built in shape, but I'm looking to do
>some CSG involving a large triangular shape. What I'm eventually looking
>for is a prism on the xz plane with 6 points. It's shaped like an
>equilateral triangle with the 3 points clipped off. In other words, viewed
>from above it's a hexagon with 3 long sides and 3 short ones. The short
>sides should equal exactly 1/3rd of the long ones. Can someone give me the
>gist of how to come up with some exact coordinates for such a shape (or,
>ideally, post the code?)
One way to do it is to start with one of the corners at <0,0> and walk
round the shape, calculating the position of the next point relative to
the last one.
The second point is 3 units x-wards of the first point, so we can
declare it as
#declare P2 = <3,0>;
The next point is 1 unit away from P2 at an angle of 60 degrees, so
that's cos(60) x-wards and sin(60) z-wards, i.e.
#declare P3 = P2 + <COS60,SIN60>;
because POV uses radians rather than degrees, we declare COS60 and SIN60
as
#declare SIN60=sin(pi/3);
#declare COS60=cos(pi/3);
Once we've declared all the points, we can build a prism object,
something like this:-
//====================================================
camera { location <1.5, 4, -2> look_at <1.5, 0, 1.5>}
light_source {<-100,200,-100> colour rgb 2}
plane { y, 0 pigment {rgb y/2}}
#declare SIN60=sin(pi/3);
#declare COS60=cos(pi/3);
#declare P1 = <0,0>;
#declare P2 = <3,0>;
#declare P3 = P2 + <COS60,SIN60>;
#declare P4 = P3 + <-3*COS60,3*SIN60>;
#declare P5 = P4 + <-1,0>;
#declare P6 = P5 + <-3*COS60,-3*SIN60>;
prism { linear_sweep linear_spline
0, // base height
1, // top height
7, // number of points
P1, P2, P3, P4, P5, P6, P1 // the points we calculated earlier
pigment {rgb x}
}
--
Mike Williams
Gentleman of Leisure
Post a reply to this message
|
![](/i/fill.gif) |