Class Segment - Segment.h, Segment.cc



 
Definition:
A segment is a holder for two points.
Typedefs:
None
Included:
#include "Point.h"



Variable Index
 
oPoint one
The first point.
oPoint two
The second point.

Constructor Index
 
o Segment()
Default constructor.  Sets both points to have position (0,0).
o Segment(int x1,int y1,int x2,int y2)
Sets Point one to position (x1,y1) and Point two to position (x2,y2).
o ~Segment()
Destructor.

Method Index
 
o void setPointOne(int x, int y)
Sets Point one to position (x,y).
o void setPointTwo(int x, int y)
Sets Point two to position (x,y).
o void setPointOne(Point x)
Sets Point one as specified by point 'x'
o void setPointTwo(Point x)
Sets Point two as specified by point 'x'
o void setPoints(Point x, Point y)
Sets Point one and two as specified by points 'x' and 'y', respectively.
o Point * getPointOne()
Returns a pointer to one.
o Point * getPointTwo()
Returns a pointer to two.
o bool isHorizontal()
Determines if the segment is horizontal.  If horizontal, function returns 'true'.
o bool isVertical()
Determines if the segment is vertical.  If vertical, the function returns 'false'.
o bool isSamePoint()
Determines if point one has the same location as point two.  If they are the same, function returns 'true'.  Equivalent to determining if the segment has a length of 0.
o bool overlap(Segment * seg)
Determines if this segment overlaps with the passed segment 'seg'.  If they overlap, function returns true.
o double getLength()
Returns the length of the segment.  NOTE: the actual length, not the Manhattan length.
o void print()
Debugging function.  Prints the specifics of this instance to cout.