changeset 613:5052596b7cc8

check_in_all
author david <david>
date Mon, 26 Sep 1994 14:05:23 +0000
parents 3ca70e61820f
children e8eb933109e9
files volume_io/Geometry/points.c volume_io/Geometry/transforms.c volume_io/Include/volume_io/basic.h volume_io/Prog_utils/alloc.c volume_io/Prog_utils/print.c volume_io/Testing/convert_volume_to_byte.c volume_io/example/convert_volume_to_byte.c
diffstat 7 files changed, 89 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/volume_io/Geometry/points.c
+++ b/volume_io/Geometry/points.c
@@ -179,3 +179,30 @@
         Vector_z(vectors[i]) = -Vector_z(vectors[i]);
     }
 }
+
+public  Real  get_angle_between_points(
+    Point  *prev,
+    Point  *this,
+    Point  *next )
+{
+    Real    angle, x, y;
+    Vector  v1, v2, x_axis, y_axis;
+
+    SUB_POINTS( v1, *prev, *this );
+    SUB_POINTS( v2, *next, *this );
+
+    NORMALIZE_VECTOR( v1, v1 );
+    NORMALIZE_VECTOR( v2, v2 );
+
+    x = DOT_VECTORS( v1, v2 );
+
+    SCALE_VECTOR( x_axis, v1, x );
+
+    SUB_VECTORS( y_axis, v2, x_axis );
+
+    y = MAGNITUDE( y_axis );
+
+    angle = compute_clockwise_rotation( x, y );
+
+    return( angle );
+}
--- a/volume_io/Geometry/transforms.c
+++ b/volume_io/Geometry/transforms.c
@@ -571,6 +571,8 @@
 
 public  Real  compute_clockwise_rotation( Real x, Real y )
 {
+    Real   radians;
+
     if( x == 0.0 )
     {
         if( y < 0.0 )
@@ -588,7 +590,14 @@
             return( PI );
     }
     else
-        return( - (Real) atan2( (double) y, (double) x ) );
+    {
+        radians = - (Real) atan2( (double) y, (double) x );
+
+        if( radians < 0.0 )
+            radians += 2.0 * PI;
+
+        return( radians );
+    }
 }
 
 public  void  make_identity_transform_2d( Transform_2d *transform )
--- a/volume_io/Include/volume_io/basic.h
+++ b/volume_io/Include/volume_io/basic.h
@@ -162,11 +162,6 @@
              } Status;
 
 #define  HANDLE_INTERNAL_ERROR( X )                                           \
-         {                                                                    \
-             push_print_function();                                      \
-             print( "Internal error:  %s\n", X );                             \
-             abort_if_allowed();                                              \
-             pop_print_function();                                      \
-         }
+         handle_internal_error( X )
 
 #endif
--- a/volume_io/Prog_utils/alloc.c
+++ b/volume_io/Prog_utils/alloc.c
@@ -108,45 +108,6 @@
     }
 }
 
-/* ----------------------------- MNI Header -----------------------------------
-@NAME       : abort_if_allowed
-@INPUT      : 
-@OUTPUT     : 
-@RETURNS    : 
-@DESCRIPTION: Checks if the user wants to abort.
-@METHOD     : 
-@GLOBALS    : 
-@CALLS      : 
-@CREATED    :                      David MacDonald
-@MODIFIED   : 
----------------------------------------------------------------------------- */
-
-public  void  abort_if_allowed( void )
-{
-    char  ch;
-
-    if( !ENV_EXISTS( "NO_ABORT" ) )
-    {
-        set_print_function( NULL );
-
-        print( "Do you wish to abort (y/n): " );
-        do
-        {
-            ch = getchar();
-        }
-        while( ch != 'y' && ch != 'n' );
-
-        while( getchar() != '\n' )
-        {
-        }
-
-        if( ch == 'y' )
-        {
-            abort();
-        }
-    }
-}
-
 #include  <stdio.h>
 
 private  FILE  *file;
--- a/volume_io/Prog_utils/print.c
+++ b/volume_io/Prog_utils/print.c
@@ -94,3 +94,50 @@
     else
         (*print_function) ( print_buffer );
 }
+
+public  void   handle_internal_error( char  str[] )
+{
+    push_print_function();
+    print( "Internal error:  %s\n", str );
+    abort_if_allowed();
+    pop_print_function();
+}
+
+/* ----------------------------- MNI Header -----------------------------------
+@NAME       : abort_if_allowed
+@INPUT      : 
+@OUTPUT     : 
+@RETURNS    : 
+@DESCRIPTION: Checks if the user wants to abort.
+@METHOD     : 
+@GLOBALS    : 
+@CALLS      : 
+@CREATED    :                      David MacDonald
+@MODIFIED   : 
+---------------------------------------------------------------------------- */
+
+public  void  abort_if_allowed( void )
+{
+    char  ch;
+
+    if( !ENV_EXISTS( "NO_ABORT" ) )
+    {
+        set_print_function( NULL );
+
+        print( "Do you wish to abort (y/n): " );
+        do
+        {
+            ch = getchar();
+        }
+        while( ch != 'y' && ch != 'n' );
+
+        while( getchar() != '\n' )
+        {
+        }
+
+        if( ch == 'y' )
+        {
+            abort();
+        }
+    }
+}
--- a/volume_io/Testing/convert_volume_to_byte.c
+++ b/volume_io/Testing/convert_volume_to_byte.c
@@ -13,7 +13,8 @@
 
     if( argc < 3 )
     {
-        print( "Usage: %s  input_volume output_volume  [min max new_value]\n" );
+        print( "Usage: %s  input_volume output_volume  [min max new_value]\n",
+               argv[0] );
         return( 1 );
     }
 
--- a/volume_io/example/convert_volume_to_byte.c
+++ b/volume_io/example/convert_volume_to_byte.c
@@ -13,7 +13,8 @@
 
     if( argc < 3 )
     {
-        print( "Usage: %s  input_volume output_volume  [min max new_value]\n" );
+        print( "Usage: %s  input_volume output_volume  [min max new_value]\n",
+               argv[0] );
         return( 1 );
     }