#ifndef _SEGMENT_H_ #define _SEGMENT_H_ #include "global.h" /* * Segment Class * * This class holds a particular line segment. It also provides functionality * such as determining whether, and where, two line segments intersect. * */ class Vertex; class Segment { public: Segment(); Segment(Vertex *v1, Vertex *v2); Segment(Vertex *v1, Vertex *v2, Polygon *p); ~Segment(); void do_copy(Segment *s_copy); void SetVertex(Vertex *v, int num); Vertex *GetVertex(int num); void Flip(); int Equals(Segment *other); Vertex *Intersection(Segment *other, int bounds); int IsIntersection(Segment *other, int bounds); int Contains(Vertex *v); int VertexOnSegment(Vertex *v); void print(); fixedpt slope; int slope_inf; fixedpt y_intercept; fixedpt line_x, line_y, line_w; Polygon *neighbor; private: void compute_slope(); int compute_intersection(Segment *other, int bounds, fixedpt *hit_x, fixedpt *hit_y); Vertex *verts[2]; }; #endif /* _SEGMENT_H_ */