/* 
 * Author:     Wil Schrader
 * Date:       9/13/2009
 * Version:    1.0
 * Class:      CIT 131 / Fall 2009 
 *
 * Assignment: 3a) 3D Distance
 *                Calulate the distance between two 3D points.
 */
#include <stdio.h>
#include <math.h>

/* Function Prototype */
float dist3d( float ux, float uy, float uz,
              float vx, float vy, float vz );

/* Main Function */
int main( void )
{

   /* Print out the results */
   printf( "Distance between (1, 2, 3) and (0, 0, 0) is %f\n", dist3d( 1, 2, 3, 0, 0, 0 ) );
   printf( "Distance between (1, 2, 3) and (1, 2, 3) is %f\n", dist3d( 1, 2, 3, 1, 2, 3 ) );
   printf( "Distance between (1, 2, 3) and (7, -4, 5) is %f\n", dist3d( 1, 2, 3, 7, -4, 5 ) );

   return 0; /* Program ended successfully */

} /* End Main Function */

/* 3D Distance Function */
float dist3d( float ux, float uy, float uz,
                    float vx, float vy, float vz )
{

   /* Calculate the distance and return the result */
   return sqrt( pow((vx - ux), 2) + pow((vy - uy), 2) + pow((vz - uz), 2) );

} /* End 3D Distance Function */