Math::Zap - Zap 3d objects drawn in 2d with lighting and shadowing.

- NAME
- DESCRIPTION
- AUTHOR

# NAME

Math::Zap - Zap 3d objects drawn in 2d with lighting and shadowing.

#!perl -w #______________________________________________________________________ # Draw cube floating against triangular corner in 3d with shadows. #______________________________________________________________________

use draw; use color; use cube; use triangle; use vector;

#______________________________________________________________________ # Draw this set of objects. #______________________________________________________________________

draw ->from (vector( 10, 10, 10)) ->to (vector( 0, 0, 0)) ->horizon (vector( 1, 0.5, 0)) ->light (vector( 20, 30, -20))

        ->object(triangle(vector( 0,  0,  0), vector( 8,  0,  0), vector( 0,  8,  0)),                         'red')
        ->object(triangle(vector( 0,  0,  0), vector( 0,  0,  8), vector( 0,  8,  0)),                         'green')
        ->object(triangle(vector( 0,  0,  0), vector(12,  0,  0), vector( 0,  0, 12)) - vector(2.5,  0,  2.5), 'blue')
        ->object(triangle(vector( 0,  0,  0), vector( 8,  0,  0), vector( 0, -8,  0)),                         'pink')
        ->object(triangle(vector( 0,  0,  0), vector( 0,  0,  8), vector( 0, -8,  0)),                         'orange')
        ->object(cube::unit()*2+vector(3,5,1), 'lightblue')

->done;

# DESCRIPTION

This package supplies methods to draw a scene, containing three dimensional objects, as a two dimensional image, using lighting and shadowing to assist the human observer in reconstructing the original three dimensional scene.

There are many existing packages to perform this important task: this package is the only one to make the attempt in Pure Perl. Pending Petaflop Parallel Perl, this approach is slow. However, it is not so slow as to be completely useless for simple scenes as might be encountered inside, for instance, beam lines used in high energy particle physics, the owners of which often have large Perl computers.

The key advantage of this package is that is open: you can manipulate both the objects to be drawn and the drawing itself all in Pure Perl.

# AUTHOR

Philip R Brenan at philiprbrenan@yahoo.com