Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

line_circle.c

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------- 00002 @COPYRIGHT : 00003 Copyright 1993,1994,1995 David MacDonald, 00004 McConnell Brain Imaging Centre, 00005 Montreal Neurological Institute, McGill University. 00006 Permission to use, copy, modify, and distribute this 00007 software and its documentation for any purpose and without 00008 fee is hereby granted, provided that the above copyright 00009 notice appear in all copies. The author and McGill University 00010 make no representations about the suitability of this 00011 software for any purpose. It is provided "as is" without 00012 express or implied warranty. 00013 ---------------------------------------------------------------------------- */ 00014 00015 #include <volume_io/internal_volume_io.h> 00016 #include <bicpl/geom.h> 00017 00018 #ifndef lint 00019 static char rcsid[] = "$Header: /software/source//libraries/bicpl/Geometry/line_circle.c,v 1.11 2000/02/06 15:30:15 stever Exp $"; 00020 #endif 00021 00022 /* ----------------------------- MNI Header ----------------------------------- 00023 @NAME : create_line_circle 00024 @INPUT : centre 00025 plane_axis 00026 x_radius 00027 y_radius 00028 n_points 00029 @OUTPUT : lines 00030 @RETURNS : 00031 @DESCRIPTION: Creates an ellipse with the given centre and x and y radius, 00032 as a closed line structure. 00033 @METHOD : 00034 @GLOBALS : 00035 @CALLS : 00036 @CREATED : 1993 David MacDonald 00037 @MODIFIED : 00038 ---------------------------------------------------------------------------- */ 00039 00040 public void create_line_circle( 00041 Point *centre, 00042 int plane_axis, 00043 Real x_radius, 00044 Real y_radius, 00045 int n_points, 00046 lines_struct *lines ) 00047 { 00048 int i, a1, a2; 00049 Real angle; 00050 00051 initialize_lines( lines, WHITE ); 00052 00053 lines->n_points = n_points; 00054 lines->n_items = 1; 00055 00056 ALLOC( lines->points, n_points ); 00057 ALLOC( lines->end_indices, 1 ); 00058 ALLOC( lines->indices, n_points+1 ); 00059 00060 a1 = (plane_axis+1) % 3; 00061 a2 = (plane_axis+2) % 3; 00062 00063 for_less( i, 0, n_points ) 00064 { 00065 angle = 2.0 * PI * (Real) i / (Real) n_points; 00066 Point_coord(lines->points[i],a1) = (Point_coord_type) 00067 ( (Real) Point_coord(*centre,a1) + x_radius * cos( angle ) ); 00068 Point_coord(lines->points[i],a2) = (Point_coord_type) 00069 ( (Real) Point_coord(*centre,a2) + y_radius * sin( angle ) ); 00070 Point_coord(lines->points[i],plane_axis) = 00071 Point_coord(*centre,plane_axis); 00072 } 00073 00074 for_less( i, 0, n_points ) 00075 lines->indices[i] = i; 00076 00077 lines->indices[n_points] = 0; 00078 00079 lines->end_indices[0] = n_points+1; 00080 }

Generated on Wed Jul 28 09:10:57 2004 for BICPL by doxygen 1.3.7