# include # include # include # include # include # include "ellipsoid.h" int main ( ); void ellipsoid_area_test ( ); void timestamp ( ); /******************************************************************************/ int main ( ) /******************************************************************************/ /* Purpose: ellipsoid_test() tests ellipsoid(). Licensing: This code is distributed under the MIT license. Modified: 05 January 2022 Author: John Burkardt */ { timestamp ( ); printf ( "\n" ); printf ( "ellipsoid_test():\n" ); printf ( " C version\n" ); printf ( " Test ellipsoid().\n" ); ellipsoid_area_test ( ); /* Terminate. */ printf ( "\n" ); printf ( "ellipsoid_test():\n" ); printf ( " Normal end of execution.\n" ); printf ( "\n" ); timestamp ( ); return 0; } /******************************************************************************/ void ellipsoid_area_test ( ) /******************************************************************************/ /* Purpose: ellipsoid_test() tests ellipsoid_area(). Licensing: This code is distributed under the MIT license. Modified: 05 January 2022 Author: John Burkardt */ { double a; double b; double c; double area; printf ( "\n" ); printf ( "ellipsoid_area_test():\n" ); printf ( " ellipsoid_area() computes the surface area of and ellipsoid\n" ); printf ( " satisfying the equation:\n" ); printf ( " (x/a)^2+(y/b)^2+(z/c)^2=1\n" ); printf ( "\n" ); printf ( " A B C Area\n" ); printf ( "\n" ); a = 1.0; b = 0.8; c = 0.625; area = ellipsoid_area ( a, b, c ); printf ( " %10.4g %10.4g %10.4g %10.4g\n", a, b, c, area ); a = 1.0; b = 1.0; c = 0.5; area = ellipsoid_area ( a, b, c ); printf ( " %10.4g %10.4g %10.4g %10.4g\n", a, b, c, area ); a = 1.0; b = 1.0; c = 1.0; area = ellipsoid_area ( a, b, c ); printf ( " %10.4g %10.4g %10.4g %10.4g\n", a, b, c, area ); a = 2.0; b = 1.0; c = 0.25; area = ellipsoid_area ( a, b, c ); printf ( " %10.4g %10.4g %10.4g %10.4g\n", a, b, c, area ); a = 2.0; b = 3.0; c = 4.0; area = ellipsoid_area ( a, b, c ); printf ( " %10.4g %10.4g %10.4g %10.4g\n", a, b, c, area ); return; } /******************************************************************************/ void timestamp ( ) /******************************************************************************/ /* Purpose: timestamp() prints the current YMDHMS date as a time stamp. Example: 17 June 2014 09:45:54 AM Licensing: This code is distributed under the MIT license. Modified: 01 May 2021 Author: John Burkardt */ { # define TIME_SIZE 40 static char time_buffer[TIME_SIZE]; const struct tm *tm; time_t now; now = time ( NULL ); tm = localtime ( &now ); strftime ( time_buffer, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm ); printf ( "%s\n", time_buffer ); return; # undef TIME_SIZE }