# include # include # include # include # include # include # include "tetrahedron.h" void tetrahedron_barycentric_test ( ); void tetrahedron_centroid_test ( ); void tetrahedron_contains_point_test ( ); void tetrahedron_circumsphere_test ( ); void tetrahedron_edge_length_test ( ); void tetrahedron_insphere_test ( ); void tetrahedron_lattice_layer_point_next_test ( ); void tetrahedron_lattice_point_next_test ( ); void tetrahedron_quality1_test ( ); void tetrahedron_quality2_test ( ); void tetrahedron_quality3_test ( ); void tetrahedron_quality4_test ( ); void tetrahedron_rhombic_shape_test ( ); void tetrahedron_sample_test ( ); void tetrahedron_shape_test ( ); void tetrahedron_solid_angles_test ( ); void timestamp ( ); /******************************************************************************/ int main ( ) /******************************************************************************/ /* Purpose: tetrahedron_test() tests tetrahedron(). Licensing: This code is distributed under the MIT license. Modified: 05 May 2022 Author: John Burkardt */ { timestamp ( ); printf ( "\n" ); printf ( "tetrahedron_test():\n" ); printf ( " C version\n" ); printf ( " Test tetrahedron().\n" ); tetrahedron_barycentric_test ( ); tetrahedron_centroid_test ( ); tetrahedron_contains_point_test ( ); tetrahedron_circumsphere_test ( ); tetrahedron_edge_length_test ( ); tetrahedron_insphere_test ( ); tetrahedron_lattice_layer_point_next_test ( ); tetrahedron_lattice_point_next_test ( ); tetrahedron_quality1_test ( ); tetrahedron_quality2_test ( ); tetrahedron_quality3_test ( ); tetrahedron_quality4_test ( ); tetrahedron_rhombic_shape_test ( ); tetrahedron_sample_test ( ); tetrahedron_shape_test ( ); tetrahedron_solid_angles_test ( ); /* Terminate. */ printf ( "\n" ); printf ( "tetrahedron_test():\n" ); printf ( " Normal end of execution.\n" ); printf ( "\n" ); timestamp ( ); return 0; } /******************************************************************************/ void tetrahedron_barycentric_test ( ) /******************************************************************************/ /* Purpose: tetrahedron_barycentric_test() tests tetrahedron_barycentric(). Licensing: This code is distributed under the MIT license. Modified: 05 May 2022 Author: John Burkardt */ { # define DIM_NUM 3 # define TEST_NUM 10 double p[DIM_NUM]; int seed = 123456789; double t[DIM_NUM*4] = { 1.0, 4.0, 3.0, 2.0, 4.0, 3.0, 1.0, 6.0, 3.0, 1.0, 4.0, 4.0 }; int test; double *xsi; printf ( "\n" ); printf ( "tetrahedron_barycentric_test():\n" ); printf ( " tetrahedron_barycentric() converts Cartesian to\n" ); printf ( " barycentric coordinates.\n" ); printf ( " We randomly sample the tetrahedron, getting Cartesian\n" ); printf ( " coordinates. We compute the barycentric coordinates to\n" ); printf ( " verify that the points are inside the tetrahedron.\n" ); r8mat_transpose_print ( DIM_NUM, DIM_NUM+1, t, " Tetrahedron vertices" ); printf ( "\n" ); printf ( " P Barycentric:\n" ); printf ( "\n" ); for ( test = 1; test <= TEST_NUM; test++ ) { tetrahedron_sample ( t, 1, &seed, p ); printf ( " %8f %8f %8f", p[0], p[1], p[2] ); xsi = tetrahedron_barycentric ( t, p ); printf ( " %8f %8f %8f %8f\n", xsi[0], xsi[1], xsi[2], xsi[3] ); free ( xsi ); } return; # undef DIM_NUM # undef TEST_NUM } /******************************************************************************/ void tetrahedron_centroid_test ( ) /******************************************************************************/ /* Purpose: tetrahedron_centroid_test() tests tetrahedron_centroid(). Licensing: This code is distributed under the MIT license. Modified: 05 May 2022 Author: John Burkardt */ { # define DIM_NUM 3 double *centroid; double tetra[DIM_NUM*4] = { 0.000000, 0.942809, -0.333333, -0.816496, -0.816496, -0.333333, 0.816496, -0.816496, -0.333333, 0.000000, 0.000000, 1.000000 }; printf ( "\n" ); printf ( "tetrahedron_centroid_test():\n" ); printf ( " tetrahedron_centroid() computes the centroid of a tetrahedron.\n" ); r8mat_transpose_print ( DIM_NUM, 4, tetra, " Tetrahedron vertices:" ); centroid = tetrahedron_centroid ( tetra ); r8vec_print ( DIM_NUM, centroid, " Centroid:" ); free ( centroid ); return; # undef DIM_NUM } /******************************************************************************/ void tetrahedron_contains_point_test ( ) /******************************************************************************/ /* Purpose: tetrahedron_contains_point_test() tests tetrahedron_contains_point(). Licensing: This code is distributed under the MIT license. Modified: 05 May 2022 Author: John Burkardt */ { # define DIM_NUM 3 # define TEST_NUM 3 double *c; double c_test[4*TEST_NUM] = { 0.0, 0.1, 0.2, 0.7, -1.3, 2.0, 0.2, 0.1, 0.8, 0.6, -0.5, 0.1 }; int i; int inside; int j; double p[DIM_NUM]; int test; double tetra[DIM_NUM*4] = { 0.000000, 0.942809, -0.333333, -0.816496, -0.816496, -0.333333, 0.816496, -0.816496, -0.333333, 0.000000, 0.000000, 1.000000 }; printf ( "\n" ); printf ( "tetrahedron_contains_point_test():\n" ); printf ( " tetrahedron_contains_point() finds if a point \n" ); printf ( " is inside a tetrahedron;\n" ); r8mat_transpose_print ( DIM_NUM, 4, tetra, " Tetrahedron vertices:" ); printf ( "\n" ); printf ( " P Inside_Tetra?\n" ); printf ( "\n" ); for ( test = 0; test < TEST_NUM; test++ ) { c = c_test + test * 4; r8vec_zero ( DIM_NUM, p ); for ( i = 0; i < DIM_NUM; i++ ) { for ( j = 0; j < 4; j++ ) { p[i] = p[i] + tetra[i+j*DIM_NUM] * c[j]; } } inside = tetrahedron_contains_point ( tetra, p ); printf ( " %12f %12f %12f %d\n", p[0], p[1], p[2], inside ); } return; # undef DIM_NUM # undef TEST_NUM } /******************************************************************************/ void tetrahedron_circumsphere_test ( ) /******************************************************************************/ /* Purpose: tetrahedron_circumsphere_test() tests tetrahedron_circumsphere(). Licensing: This code is distributed under the MIT license. Modified: 05 May 2022 Author: John Burkardt */ { # define DIM_NUM 3 double pc[DIM_NUM]; double r; double tetra[DIM_NUM*4] = { 0.577350269189626, 0.0, 0.0, -0.288675134594813, 0.5, 0.0, -0.288675134594813, -0.5, 0.0, 0.0, 0.0, 0.816496580927726 }; printf ( "\n" ); printf ( "tetrahedron_circumsphere_test():\n" ); printf ( " tetrahedron_circumsphere() computes the circumsphere\n" ); printf ( " of a tetrahedron.\n" ); r8mat_transpose_print ( DIM_NUM, 4, tetra, " Tetrahedron vertices:" ); tetrahedron_circumsphere ( tetra, &r, pc ); r8vec_print ( DIM_NUM, pc, " Circumsphere center:" ); printf ( "\n" ); printf ( " Circumsphere radius is %g\n", r ); return; # undef DIM_NUM } /******************************************************************************/ void tetrahedron_edge_length_test ( ) /******************************************************************************/ /* Purpose: tetrahedron_edge_length_test() tests tetrahedron_edge_length(); Licensing: This code is distributed under the MIT license. Modified: 05 May 2022 Author: John Burkardt */ { # define DIM_NUM 3 double *edge_length; double tetra[DIM_NUM*4] = { 0.577350269189626, 0.0, 0.0, -0.288675134594813, 0.5, 0.0, -0.288675134594813, -0.5, 0.0, 0.0, 0.0, 0.816496580927726 }; printf ( "\n" ); printf ( "tetrahedron_edge_length_test():\n" ); printf ( " tetrahedron_edge_length() computes the edge lengths\n" ); printf ( " of a tetrahedron.\n" ); r8mat_transpose_print ( DIM_NUM, 4, tetra, " Tetrahedron vertices:" ); edge_length = tetrahedron_edge_length ( tetra ); r8vec_print ( 6, edge_length, " Edge lengths:" ); free ( edge_length ); return; # undef DIM_NUM } /******************************************************************************/ void tetrahedron_insphere_test ( ) /******************************************************************************/ /* Purpose: tetrahedron_insphere_test() tests tetrahedron_insphere(); Licensing: This code is distributed under the MIT license. Modified: 05 May 2022 Author: John Burkardt */ { # define DIM_NUM 3 double pc[DIM_NUM]; double r; double tetra[DIM_NUM*4] = { 0.577350269189626, 0.0, 0.0, -0.288675134594813, 0.5, 0.0, -0.288675134594813, -0.5, 0.0, 0.0, 0.0, 0.816496580927726 }; printf ( "\n" ); printf ( "tetrahedron_insphere_test():\n" ); printf ( " tetrahedron_insphere() computes the insphere of a tetrahedron\n" ); r8mat_transpose_print ( DIM_NUM, 4, tetra, " Tetrahedron vertices:" ); tetrahedron_insphere ( tetra, &r, pc ); r8vec_print ( DIM_NUM, pc, " Insphere center:" ); printf ( "\n" ); printf ( " Insphere radius is %g\n", r ); return; # undef DIM_NUM } /******************************************************************************/ void tetrahedron_lattice_layer_point_next_test ( ) /******************************************************************************/ /* Purpose: tetrahedron_lattice_layer_point_next_test() tests tetrahedron_lattice_layer_point_next(). Licensing: This code is distributed under the MIT license. Modified: 05 May 2022 Author: John Burkardt */ { int c[4]; int i; int j; int layer; int more; int n = 3; int v[3]; printf ( "\n" ); printf ( "tetrahedron_lattice_layer_point_next_test():\n" ); printf ( " tetrahedron_lattice_layer_point_next() returns the next\n" ); printf ( " point in a tetrahedron lattice layer defined by:\n" ); printf ( "\n" ); printf ( " C[3] - 1 < X[0]/C[0] + X[1]/C[1] +X[2]/C[2] <= C[3].\n" ); c[0] = 2; c[1] = 3; c[2] = 4; v[0] = 0; v[1] = 0; v[2] = 0; printf ( "\n" ); printf ( " N = %d\n", n ); printf ( " C = " ); for ( i = 0; i < n; i++) { printf ( " %4d", c[i] ); } printf ( "\n" ); for ( layer = 0; layer <= 2; layer++ ) { printf ( "\n" ); printf ( " Layer %d\n", layer ); printf ( "\n" ); c[3] = layer; more = 0; i = 0; for ( ; ; ) { tetrahedron_lattice_layer_point_next ( c, v, &more ); if ( !more ) { printf ( " No more.\n" ); break; } i = i + 1; printf ( " %4d", i ); for ( j = 0; j < n; j++ ) { printf ( " %4d", v[j] ); } printf ( "\n" ); } } return; } /******************************************************************************/ void tetrahedron_lattice_point_next_test ( ) /******************************************************************************/ /* Purpose: tetrahedron_lattice_point_next_test() tests tetrahedron_lattice_point_next(). Licensing: This code is distributed under the MIT license. Modified: 05 May 2022 Author: John Burkardt */ { # define N 3 int c[N+1]; int i; int j; int more; int n = N; int v[N]; printf ( "\n" ); printf ( "tetrahedron_lattice_point_next_test():\n" ); printf ( " tetrahedron_lattice_point_next() returns the next lattice\n" ); printf ( " point in a tetrahedron defined by:\n" ); printf ( "\n" ); printf ( " 0 <= X(1)/C(1) + X(2)/C(2) + X(3)/C(3) <= C(4).\n" ); for ( i = 0; i < n + 1; i++ ) { c[i] = n + 1 - i; } for ( i = 0; i < n; i++ ) { v[i] = 0; } more = 0; printf ( "\n" ); printf ( " N = %d", n ); printf ( " C = " ); for ( i = 0; i < n + 1; i++ ) { printf ( " %4d", c[i] ); } printf ( "\n" ); printf ( "\n" ); i = 0; for ( ; ; ) { tetrahedron_lattice_point_next ( c, v, &more ); if ( ! more ) { printf ( " No more.\n" ); break; } i = i + 1; printf ( " %4d", i ); for ( j = 0; j < n; j++ ) { printf ( " %4d", v[j] ); } printf ( "\n" ); } return; # undef N } /******************************************************************************/ void tetrahedron_quality1_test ( ) /******************************************************************************/ /* Purpose: tetrahedron_quality1_test() tests tetrahedron_quality1(). Licensing: This code is distributed under the MIT license. Modified: 05 May 2022 Author: John Burkardt */ { # define DIM_NUM 3 # define TEST_NUM 2 double quality; int test; double *tetra; double tetra_test[DIM_NUM*4*TEST_NUM] = { 0.577350269189626, 0.0, 0.0, -0.288675134594813, 0.5, 0.0, -0.288675134594813, -0.5, 0.0, 0.0, 0.0, 0.816496580927726, 0.577350269189626, 0.0, 0.0, -0.288675134594813, 0.5, 0.0, -0.288675134594813, -0.5, 0.0, 0.0, 0.0, 0.408248290463863 }; printf ( "\n" ); printf ( "tetrahedron_quality1_test():\n" ); printf ( " tetrahedron_quality1() computes quality measure #1\n" ); printf ( " for a tetrahedron.\n" ); for ( test = 0; test < TEST_NUM; test++ ) { tetra = tetra_test + test * DIM_NUM * 4; r8mat_transpose_print ( DIM_NUM, 4, tetra, " Tetrahedron vertices:" ); quality = tetrahedron_quality1 ( tetra ); printf ( "\n" ); printf ( " Tetrahedron quality is %g\n", quality ); } return; # undef DIM_NUM # undef TEST_NUM } /******************************************************************************/ void tetrahedron_quality2_test ( ) /******************************************************************************/ /* Purpose: tetrahedron_quality2_test() tests tetrahedron_quality2(); Licensing: This code is distributed under the MIT license. Modified: 05 May 2022 Author: John Burkardt */ { # define DIM_NUM 3 # define TEST_NUM 2 double quality2; int test; double *tetra; double tetra_test[DIM_NUM*4*TEST_NUM] = { 0.577350269189626, 0.0, 0.0, -0.288675134594813, 0.5, 0.0, -0.288675134594813, -0.5, 0.0, 0.0, 0.0, 0.816496580927726, 0.577350269189626, 0.0, 0.0, -0.288675134594813, 0.5, 0.0, -0.288675134594813, -0.5, 0.0, 0.0, 0.0, 0.408248290463863 }; printf ( "\n" ); printf ( "tetrahedron_quality2_test():\n" ); printf ( " tetrahedron_quality2() computes quality measure #2\n" ); printf ( " for a tetrahedron.\n" ); for ( test = 0; test < TEST_NUM; test++ ) { tetra = tetra_test + test * DIM_NUM * 4; r8mat_transpose_print ( DIM_NUM, 4, tetra, " Tetrahedron vertices:" ); quality2 = tetrahedron_quality2 ( tetra ); printf ( "\n" ); printf ( " Tetrahedron quality is %g\n", quality2 ); } return; # undef DIM_NUM # undef TEST_NUM } /******************************************************************************/ void tetrahedron_quality3_test ( ) /******************************************************************************/ /* Purpose: tetrahedron_quality3_test() tests tetrahedron_quality3(); Licensing: This code is distributed under the MIT license. Modified: 05 May 2022 Author: John Burkardt */ { # define DIM_NUM 3 # define TEST_NUM 2 double quality3; int test; double *tetra; double tetra_test[DIM_NUM*4*TEST_NUM] = { 0.577350269189626, 0.0, 0.0, -0.288675134594813, 0.5, 0.0, -0.288675134594813, -0.5, 0.0, 0.0, 0.0, 0.816496580927726, 0.577350269189626, 0.0, 0.0, -0.288675134594813, 0.5, 0.0, -0.288675134594813, -0.5, 0.0, 0.0, 0.0, 0.408248290463863 }; printf ( "\n" ); printf ( "tetrahedron_quality3_test()\n" ); printf ( " tetrahedron_quality3() computes quality measure #3\n" ); printf ( " for a tetrahedron.\n" ); for ( test = 0; test < TEST_NUM; test++ ) { tetra = tetra_test + test * DIM_NUM * 4; r8mat_transpose_print ( DIM_NUM, 4, tetra, " Tetrahedron vertices:" ); quality3 = tetrahedron_quality3 ( tetra ); printf ( "\n" ); printf ( " Tetrahedron quality is %g\n", quality3 ); } return; # undef DIM_NUM # undef TEST_NUM } /******************************************************************************/ void tetrahedron_quality4_test ( ) /******************************************************************************/ /* Purpose: tetrahedron_quality4_test() tests tetrahedron_quality4(); Licensing: This code is distributed under the MIT license. Modified: 05 May 2022 Author: John Burkardt */ { # define DIM_NUM 3 # define TEST_NUM 2 double quality4; int test; double *tetra; double tetra_test[DIM_NUM*4*TEST_NUM] = { 0.577350269189626, 0.0, 0.0, -0.288675134594813, 0.5, 0.0, -0.288675134594813, -0.5, 0.0, 0.0, 0.0, 0.816496580927726, 0.577350269189626, 0.0, 0.0, -0.288675134594813, 0.5, 0.0, -0.288675134594813, -0.5, 0.0, 0.0, 0.0, 0.408248290463863 }; printf ( "\n" ); printf ( "tetrahedron_quality4_test():\n" ); printf ( " tetrahedron_quality4() computes quality measure #4\n" ); printf ( " for a tetrahedron.\n" ); for ( test = 0; test < TEST_NUM; test++ ) { tetra = tetra_test + test * DIM_NUM * 4; r8mat_transpose_print ( DIM_NUM, 4, tetra, " Tetrahedron vertices:" ); quality4 = tetrahedron_quality4 ( tetra ); printf ( "\n" ); printf ( " Tetrahedron quality is %g\n", quality4 ); } return; # undef DIM_NUM # undef TEST_NUM } /******************************************************************************/ void tetrahedron_rhombic_shape_test ( ) /******************************************************************************/ /* Purpose: tetrahedron_rhombic_shape_test() tests tetrahedron_rhombic_shape(). Licensing: This code is distributed under the MIT license. Modified: 05 May 2022 Author: John Burkardt */ { # define DIM_NUM 3 int edge_num; int face_num; int *face_order; int face_order_max; int *face_point; int point_num; double *point_coord; printf ( "\n" ); printf ( "tetrahedron_rhombic_shape_test():\n" ); printf ( " For the rhombic tetrahedron,\n" ); printf ( " tetrahedron_rhombic_size() returns dimension information;\n" ); printf ( " tetrahedron_rhombic_shape() returns face and order information.\n" ); printf ( " shape_print() prints this information.\n" ); /* Get the data sizes. */ tetrahedron_rhombic_size ( &point_num, &edge_num, &face_num, &face_order_max ); printf ( "\n" ); printf ( " Number of vertices: %d\n", point_num ); printf ( " Number of edges : %d\n", edge_num ); printf ( " Number of faces : %d\n", face_num ); printf ( " Maximum face order: %d\n", face_order_max ); /* Make room for the data. */ face_order = ( int * ) malloc ( face_num * sizeof ( int ) ); face_point = ( int * ) malloc ( face_order_max * face_num * sizeof ( int ) ); point_coord = ( double * ) malloc ( DIM_NUM * point_num * sizeof ( double ) ); /* Get the data. */ tetrahedron_rhombic_shape ( point_num, face_num, face_order_max, point_coord, face_order, face_point ); /* Print the data. */ shape_print ( point_num, face_num, face_order_max, point_coord, face_order, face_point ); free ( face_order ); free ( face_point ); free ( point_coord ); return; # undef DIM_NUM } /******************************************************************************/ void tetrahedron_sample_test ( ) /******************************************************************************/ /* Purpose: tetrahedron_sample_test() tests tetrahedron_sample(). Licensing: This code is distributed under the MIT license. Modified: 05 May 2022 Author: John Burkardt */ { # define DIM_NUM 3 # define TEST_NUM 10 double p[DIM_NUM]; int seed = 123456789; double t[DIM_NUM*4] = { 1.0, 4.0, 3.0, 2.0, 4.0, 3.0, 1.0, 6.0, 3.0, 1.0, 4.0, 4.0 }; int test; double *xsi; printf ( "\n" ); printf ( "tetrahedron_sample_test():\n" ); printf ( " tetrahedron_sample() samples a tetrahedron.\n" ); printf ( " We compute the barycentric coordinates to\n" ); printf ( " verify that the points are inside the tetrahedron.\n" ); r8mat_transpose_print ( DIM_NUM, DIM_NUM+1, t, " Tetrahedron vertices" ); printf ( "\n" ); printf ( " P Barycentric:\n" ); printf ( "\n" ); for ( test = 1; test <= TEST_NUM; test++ ) { tetrahedron_sample ( t, 1, &seed, p ); printf ( " %8f %8f %8f", p[0], p[1], p[2] ); xsi = tetrahedron_barycentric ( t, p ); printf ( " %8f %8f %8f %8f\n", xsi[0], xsi[1], xsi[2], xsi[3] ); free ( xsi ); } return; # undef DIM_NUM # undef TEST_NUM } /******************************************************************************/ void tetrahedron_shape_test ( ) /******************************************************************************/ /* Purpose: tetrahedron_shape_test() tests tetrahedron_shape(). Licensing: This code is distributed under the MIT license. Modified: 05 May 2022 Author: John Burkardt */ { # define DIM_NUM 3 int edge_num; int face_num; int *face_order; int face_order_max; int *face_point; int point_num; double *point_coord; printf ( "\n" ); printf ( "tetrahedron_shape_test():\n" ); printf ( " For the tetrahedron,\n" ); printf ( " tetrahedron_size() returns dimension information;\n" ); printf ( " tetrahedron_shape() returns face and order information.\n" ); printf ( " shape_print() prints this information.\n" ); /* Get the data sizes. */ tetrahedron_size ( &point_num, &edge_num, &face_num, &face_order_max ); printf ( "\n" ); printf ( " Number of vertices: %d\n", point_num ); printf ( " Number of edges : %d\n", edge_num ); printf ( " Number of faces : %d\n", face_num ); printf ( " Maximum face order: %d\n", face_order_max ); /* Make room for the data. */ face_order = ( int * ) malloc ( face_num * sizeof ( int ) ); face_point = ( int * ) malloc ( face_order_max * face_num * sizeof ( int ) ); point_coord = ( double * ) malloc ( DIM_NUM * point_num * sizeof ( double ) ); /* Get the data. */ tetrahedron_shape ( point_num, face_num, face_order_max, point_coord, face_order, face_point ); /* Print the data. */ shape_print ( point_num, face_num, face_order_max, point_coord, face_order, face_point ); free ( face_order ); free ( face_point ); free ( point_coord ); return; # undef DIM_NUM } /******************************************************************************/ void tetrahedron_solid_angles_test ( ) /******************************************************************************/ /* Purpose: tetrahedron_solid_angles_test() tests tetrahedron_solid_angles(); Licensing: This code is distributed under the MIT license. Modified: 05 May 2022 Author: John Burkardt */ { double *angle; double t1[3*4] = { 0.000000, 0.942809, -0.333333, -0.816496, -0.816496, -0.333333, 0.816496, -0.816496, -0.333333, 0.000000, 0.000000, 1.000000 }; double t2[3*4] = { 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000 }; double t3[3*4] = { 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 2.000000, 0.000000, 0.000000, 0.000000, 4.000000 }; double t4[3*4] = { 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 1.000000, 1.000000, 1.000000 }; printf ( "\n" ); printf ( "tetrahedron_solid_angles_test():\n" ); printf ( " tetrahedron_solid_angles() computes the solid angles\n" ); printf ( " associated with the vertices of a tetrahedron.\n" ); r8mat_transpose_print ( 3, 4, t1, " Tetrahedron #1" ); angle = tetrahedron_solid_angles ( t1 ); r8vec_print ( 4, angle, " Solid angles for tetrahedron #1" ); free ( angle ); r8mat_transpose_print ( 3, 4, t2, " Tetrahedron #2" ); angle = tetrahedron_solid_angles ( t2 ); r8vec_print ( 4, angle, " Solid angles for tetrahedron #2" ); free ( angle ); r8mat_transpose_print ( 3, 4, t3, " Tetrahedron #3" ); angle = tetrahedron_solid_angles ( t3 ); r8vec_print ( 4, angle, " Solid angles for tetrahedron #3" ); free ( angle ); r8mat_transpose_print ( 3, 4, t4, " Tetrahedron #4" ); angle = tetrahedron_solid_angles ( t4 ); r8vec_print ( 4, angle, " Solid angles for tetrahedron #4" ); free ( angle ); return; # undef DIM_NUM } /******************************************************************************/ void tetrahedron_volume_test ( ) /******************************************************************************/ /* Purpose: tetrahedron_volume_test() tests tetrahedron_volume(); Licensing: This code is distributed under the MIT license. Modified: 05 May 2022 Author: John Burkardt */ { # define DIM_NUM 3 double tetra[DIM_NUM*(DIM_NUM+1)] = { 0.000000, 0.942809, -0.333333, -0.816496, -0.816496, -0.333333, 0.816496, -0.816496, -0.333333, 0.000000, 0.000000, 1.000000 }; double volume; printf ( "\n" ); printf ( "tetrahedron_volume_test():\n" ); printf ( " tetrahedron_volume() computes the volume of a tetrahedron;\n" ); r8mat_transpose_print ( DIM_NUM, DIM_NUM+1, tetra, " Tetrahedron vertices" ); volume = tetrahedron_volume ( tetra ); printf ( "\n" ); printf ( " Volume = %g\n", volume ); return; # undef DIM_NUM } /******************************************************************************/ 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: 05 May 2022 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 }