DEFINITION  
    output      = "pix/dproj";
    xleft = 0; xright = 323;
    ylow  = 0; yhigh  = 242;
    up          = yaxis;
    startframe  =   1.0;
    endframe    = 150.0;
    byframe     = 1;

	triple CameraView(0.0, 0.0, 0.0);
    scalar gravity( -0.5 ); /* the gravitational force */
    scalar mass(     1.0 ); /* the mass of the projectile */
    scalar angle(   45.0 ); /* the angle of elevation of the cannon */
    scalar dt(      1/30 ); /* the time increment */

    scalar x(0);            /* the position of the projectile */
    scalar y(0);
    scalar z(0);

    scalar vx(0);           /* the velocity of the projectile */
    scalar vy(0);
    scalar vz(0);

    scalar fx(0);           /* the forces acting on the projectile */
    scalar fy(0);
    scalar fz(0);

    scalar az(0);           /* the acceleration of the projectile */
    scalar ay(0);
    scalar ax(0);

    scalar drag( -0.5 );    /* the drag coefficient      */

    shader White( model = lambert, color = (255.0, 255.0, 255.0),
                  incandescence = (255, 255, 255) );

MODEL

{
    camera( eye   = (0.0, 0.0, 4.0)
           ,view  = CameraView
           ,fov   = (40.0),
            viewport = (xleft, xright, ylow, yhigh),
            aspect   = ((xright-xleft)+1)/((yhigh-ylow)+1)
    );
}
{
    if( frame == 1.0 )
    {
        x  = -1.0;
        y  =  0.0;
        z  =  0.0;
        vx =  cosd( angle );
        vy =  sind( angle );
        vz =  0.0;
    }
    fx = (vx * drag);
    fy = (vy * drag) + (gravity * mass);
    fz = (vz * drag);
    ax = (fx / mass);
    ay = (fy / mass);
    az = (fz / mass);
    vx = (vx + (ax * dt));
    vy = (vy + (ay * dt));
    vz = (vz + (az * dt));
    x  = (x + (vx * dt) + ((0.5 * ax * dt) * dt));
    y  = (y + (vy * dt) + ((0.5 * ay * dt) * dt));
    z  = (z + (vz * dt) + ((0.5 * az * dt) * dt));
    translate (x, y, z);
    scale     (0.1, 0.1, 0.1);
    patch( shader = ( White ),
           doublesided = TRUE, vclosed = TRUE, 
           subdivide = uniform, divisions = (2.0, 2.0),
           udegree = 3, vdegree = 3,
           uknots = (-0.666667, -0.333333, 0.000000, 0.333333, 0.666667,
                      1.000000,  1.333333, 1.666667),
           vknots = (-0.333333, -0.166667, 0.000000, 0.166667, 0.333333,
                      0.500000,  0.666667, 0.833333, 1.000000, 1.166667,
                      1.333333),
           cvs = ((cv( (-0.311775, -0.300000, -0.540010), 1.0 ),
                   cv( (-0.623550, -0.300000,  0.000000), 1.0 ),
                   cv( (-0.311775, -0.300000,  0.540010), 1.0 ),
                   cv( ( 0.311775, -0.300000,  0.540010), 1.0 ),
                   cv( ( 0.623549, -0.300000,  0.000000), 1.0 ),
                   cv( ( 0.311774, -0.300000, -0.540010), 1.0 ),
                   cv( (-0.311775, -0.300000, -0.540010), 1.0 ),
                   cv( (-0.623550, -0.300000,  0.000000), 1.0 ),
                   cv( (-0.311775, -0.300000,  0.540010), 1.0 )),
                  (cv( ( 0.000000, -0.600000,  0.000000), 1.0 ),
                   cv( ( 0.000000, -0.600000,  0.000000), 1.0 ),
                   cv( ( 0.000000, -0.600000,  0.000000), 1.0 ),
                   cv( ( 0.000000, -0.600000,  0.000000), 1.0 ),
                   cv( ( 0.000000, -0.600000,  0.000000), 1.0 ),
                   cv( ( 0.000000, -0.600000,  0.000000), 1.0 ),
                   cv( ( 0.000000, -0.600000,  0.000000), 1.0 ),
                   cv( ( 0.000000, -0.600000,  0.000000), 1.0 ),
                   cv( ( 0.000000, -0.600000,  0.000000), 1.0 )),
                  (cv( ( 0.311769, -0.300000,  0.539999), 1.0 ),
                   cv( ( 0.623538, -0.300000,  0.000000), 1.0 ),
                   cv( ( 0.311769, -0.300000, -0.539999), 1.0 ),
                   cv( (-0.311769, -0.300000, -0.539999), 1.0 ),
                   cv( (-0.623538, -0.300000,  0.000000), 1.0 ),
                   cv( (-0.311769, -0.300000,  0.539999), 1.0 ),
                   cv( ( 0.311769, -0.300000,  0.539999), 1.0 ),
                   cv( ( 0.623538, -0.300000,  0.000000), 1.0 ),
                   cv( ( 0.311769, -0.300000, -0.539999), 1.0 )),
                  (cv( ( 0.311769,  0.300000,  0.539999), 1.0 ),
                   cv( ( 0.623537,  0.300000,  0.000000), 1.0 ),
                   cv( ( 0.311769,  0.300000, -0.539999), 1.0 ),
                   cv( (-0.311769,  0.300000, -0.539999), 1.0 ),
                   cv( (-0.623537,  0.300000,  0.000000), 1.0 ),
                   cv( (-0.311768,  0.300000,  0.539999), 1.0 ),
                   cv( ( 0.311769,  0.300000,  0.539999), 1.0 ),
                   cv( ( 0.623537,  0.300000,  0.000000), 1.0 ),
                   cv( ( 0.311769,  0.300000, -0.539999), 1.0 )),
                  (cv( ( 0.000000,  0.599999,  0.000000), 1.0 ),
                   cv( ( 0.000000,  0.599999,  0.000000), 1.0 ),
                   cv( ( 0.000000,  0.599999,  0.000000), 1.0 ),
                   cv( ( 0.000000,  0.599999,  0.000000), 1.0 ),
                   cv( ( 0.000000,  0.599999,  0.000000), 1.0 ),
                   cv( ( 0.000000,  0.599999,  0.000000), 1.0 ),
                   cv( ( 0.000000,  0.599999,  0.000000), 1.0 ),
                   cv( ( 0.000000,  0.599999,  0.000000), 1.0 ),
                   cv( ( 0.000000,  0.599999,  0.000000), 1.0 )),
                  (cv( (-0.311775,  0.299999, -0.540010), 1.0 ),
                   cv( (-0.623549,  0.299999,  0.000000), 1.0 ),
                   cv( (-0.311775,  0.299999,  0.540010), 1.0 ),
                   cv( ( 0.311775,  0.299999,  0.540010), 1.0 ),
                   cv( ( 0.623549,  0.299999,  0.000000), 1.0 ),
                   cv( ( 0.311774,  0.299999, -0.540009), 1.0 ),
                   cv( (-0.311775,  0.299999, -0.540010), 1.0 ),
                   cv( (-0.623549,  0.299999,  0.000000), 1.0 ),
                   cv( (-0.311775,  0.299999,  0.540010), 1.0 ))
                 )
         );
}
