CCL Home Page
Up Directory CCL make-cones
#!/usr/local/bin/perl
# Make illustration of overlapping cones, produce a xyz2rgb-readable wall
# file. Name this file make-cones, and do something like this:
#    make-cones > cones
#    xyz2rgb -latitude 30 -longitude 20 -distance 45 -walls cones > cones.rgb
#    convert -size 640x480 -interlace line cones.rgb cones.bmp
#    xv cones.bmp
 
$pi = 3.1415926;
$slices = 200;
$opacity = 0.28;
$height = 15;
$rbottom = 10;
$rtop = 0;
$sep = 5;
 
printf "%d\n", 2 * $slices;     # number of walls
sub one_cone
{
    $cy = $_[0];
    for ($x = 0; $x < $slices; $x++)
    {
        # the cones' 360 degrees are sliced into $slices
        $a1 = $x * (2 * $pi / $slices);
        $a2 = ($x + 1) * (2 * $pi / $slices);
        # red, green, blue, opacity
        printf ("%d %d %d %f\n",
                $_[1], $_[2], $_[3], $opacity);
        # xyz coordinates for four corners of wall
        printf ("%f %f %f\n",
                $rtop * cos($a1),
                $cy + $rtop * sin($a1),
                $height / 2);
        printf ("%f %f %f\n",
                $rtop * cos($a2),
                $cy + $rtop * sin($a2),
                $height / 2);
        printf ("%f %f %f\n",
                $rbottom * cos($a2),
                $cy + $rbottom * sin($a2),
                -$height / 2);
        printf ("%f %f %f\n",
                $rbottom * cos($a1),
                $cy + $rbottom * sin($a1),
                -$height / 2);
    }
}
 
&one_cone(-$sep / 2, 255, 140, 50);
&one_cone($sep / 2, 50, 140, 255);
Modified: Wed Jun 11 16:00:00 1997 GMT
Page accessed 8198 times since Sat Apr 17 21:36:01 1999 GMT