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