/* Line.c 2-D line */ #include #include #include #include #include #include "Point.h" struct line { Point start, end; }; #define EPS 1.0e-8 #define ABS(x) (((x)>=0.0)?(x):(-(x))) #include "Line.h" Line ConsLine( Point start, Point end ) { Line l; l = malloc( sizeof( struct line ) ); if ( l != NULL ) { l->start = CopyPoint( start ); l->end = CopyPoint( end ); } return l; } void DeleteLine( Line l ) { assert( l != NULL ); /* Call point destructors */ DeletePoint( l->start ); DeletePoint( l->end ); free( l ); } Point StartPoint( Line l ) { assert( l != NULL ); return l->start; } Point EndPoint( Line l ) { assert( l != NULL ); return l->end; }